• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that
3 // can be found in the LICENSE file.
4 
5 #ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_BROWSER_EXTENSIONS_UTIL_H_
6 #define CEF_LIBCEF_BROWSER_EXTENSIONS_BROWSER_EXTENSIONS_UTIL_H_
7 
8 #include <vector>
9 
10 #include "include/internal/cef_ptr.h"
11 
12 #include "url/gurl.h"
13 
14 namespace content {
15 class BrowserContext;
16 class RenderFrameHost;
17 class RenderViewHost;
18 class WebContents;
19 }  // namespace content
20 
21 class CefBrowserHostBase;
22 class AlloyBrowserHostImpl;
23 
24 namespace extensions {
25 
26 class Extension;
27 
28 // Returns the full-page guest WebContents for the specified |owner|, if any.
29 content::WebContents* GetFullPageGuestForOwnerContents(
30     content::WebContents* owner);
31 
32 // Populates |guests| with all guest WebContents with the specified |owner|.
33 void GetAllGuestsForOwnerContents(content::WebContents* owner,
34                                   std::vector<content::WebContents*>* guests);
35 
36 // Returns the WebContents that owns the specified |guest|, if any.
37 content::WebContents* GetOwnerForGuestContents(content::WebContents* guest);
38 
39 // Returns the CefBrowserHostBase that owns the host identified by the specified
40 // routing IDs, if any. |is_guest_view| will be set to true if the IDs
41 // match a guest view associated with the returned browser instead of the
42 // browser itself.
43 CefRefPtr<CefBrowserHostBase> GetOwnerBrowserForFrameRoute(
44     int render_process_id,
45     int render_routing_id,
46     bool* is_guest_view);
47 
48 // Returns the CefBrowserHostBase that owns the specified |host|, if any.
49 // |is_guest_view| will be set to true if the host matches a guest view
50 // associated with the returned browser instead of the browser itself.
51 // TODO(cef): Delete the RVH variant once the remaining use case
52 // (via AlloyContentBrowserClient::OverrideWebkitPrefs) has been removed.
53 CefRefPtr<CefBrowserHostBase> GetOwnerBrowserForHost(
54     content::RenderViewHost* host,
55     bool* is_guest_view);
56 CefRefPtr<CefBrowserHostBase> GetOwnerBrowserForHost(
57     content::RenderFrameHost* host,
58     bool* is_guest_view);
59 
60 // Returns the browser matching |tab_id| and |browser_context|. Returns false if
61 // |tab_id| is < 0 or a matching browser cannot be found within
62 // |browser_context|. Similar in concept to ExtensionTabUtil::GetTabById.
63 CefRefPtr<AlloyBrowserHostImpl> GetBrowserForTabId(
64     int tab_id,
65     content::BrowserContext* browser_context);
66 
67 // Returns the extension associated with |url| in |profile|. Returns nullptr
68 // if the extension does not exist.
69 const Extension* GetExtensionForUrl(content::BrowserContext* browser_context,
70                                     const GURL& url);
71 
72 }  // namespace extensions
73 
74 #endif  // CEF_LIBCEF_BROWSER_EXTENSIONS_BROWSER_EXTENSIONS_UTIL_H_
75