• 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 struct GlobalRenderFrameHostId;
17 class RenderFrameHost;
18 class RenderViewHost;
19 class WebContents;
20 }  // namespace content
21 
22 class CefBrowserHostBase;
23 class AlloyBrowserHostImpl;
24 
25 namespace extensions {
26 
27 class Extension;
28 
29 // Populates |guests| with all guest WebContents with the specified |owner|.
30 void GetAllGuestsForOwnerContents(content::WebContents* owner,
31                                   std::vector<content::WebContents*>* guests);
32 
33 // Returns the WebContents that owns the specified |guest|, if any.
34 content::WebContents* GetOwnerForGuestContents(content::WebContents* guest);
35 
36 // Returns the CefBrowserHostBase that owns the host identified by the specified
37 // global ID, if any. |is_guest_view| will be set to true if the ID
38 // matches a guest view associated with the returned browser instead of the
39 // browser itself.
40 CefRefPtr<CefBrowserHostBase> GetOwnerBrowserForGlobalId(
41     const content::GlobalRenderFrameHostId& global_id,
42     bool* is_guest_view);
43 
44 // Returns the CefBrowserHostBase that owns the specified |host|, if any.
45 // |is_guest_view| will be set to true if the host matches a guest view
46 // associated with the returned browser instead of the browser itself.
47 // TODO(cef): Delete the RVH variant once the remaining use case
48 // (via AlloyContentBrowserClient::OverrideWebkitPrefs) has been removed.
49 CefRefPtr<CefBrowserHostBase> GetOwnerBrowserForHost(
50     content::RenderViewHost* host,
51     bool* is_guest_view);
52 CefRefPtr<CefBrowserHostBase> GetOwnerBrowserForHost(
53     content::RenderFrameHost* host,
54     bool* is_guest_view);
55 
56 // Returns the browser matching |tab_id| and |browser_context|. Returns false if
57 // |tab_id| is < 0 or a matching browser cannot be found within
58 // |browser_context|. Similar in concept to ExtensionTabUtil::GetTabById.
59 CefRefPtr<AlloyBrowserHostImpl> GetBrowserForTabId(
60     int tab_id,
61     content::BrowserContext* browser_context);
62 
63 // Returns the extension associated with |url| in |profile|. Returns nullptr
64 // if the extension does not exist.
65 const Extension* GetExtensionForUrl(content::BrowserContext* browser_context,
66                                     const GURL& url);
67 
68 }  // namespace extensions
69 
70 #endif  // CEF_LIBCEF_BROWSER_EXTENSIONS_BROWSER_EXTENSIONS_UTIL_H_
71