1 // Copyright 2015 The Chromium Embedded Framework Authors. 2 // Portions copyright 2014 The Chromium Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 6 #ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSIONS_BROWSER_CLIENT_H_ 7 #define CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSIONS_BROWSER_CLIENT_H_ 8 9 #include "base/compiler_specific.h" 10 #include "extensions/browser/extensions_browser_client.h" 11 12 namespace extensions { 13 14 class ExtensionsAPIClient; 15 16 // An ExtensionsBrowserClient that supports a single content::BrowserContent 17 // with no related incognito context. 18 class CefExtensionsBrowserClient : public ExtensionsBrowserClient { 19 public: 20 CefExtensionsBrowserClient(); 21 22 CefExtensionsBrowserClient(const CefExtensionsBrowserClient&) = delete; 23 CefExtensionsBrowserClient& operator=(const CefExtensionsBrowserClient&) = 24 delete; 25 26 ~CefExtensionsBrowserClient() override; 27 28 // Returns the singleton CefExtensionsBrowserClient instance. 29 static CefExtensionsBrowserClient* Get(); 30 31 // ExtensionsBrowserClient overrides: 32 bool IsShuttingDown() override; 33 bool AreExtensionsDisabled(const base::CommandLine& command_line, 34 content::BrowserContext* context) override; 35 bool IsValidContext(content::BrowserContext* context) override; 36 bool IsSameContext(content::BrowserContext* first, 37 content::BrowserContext* second) override; 38 bool HasOffTheRecordContext(content::BrowserContext* context) override; 39 content::BrowserContext* GetOffTheRecordContext( 40 content::BrowserContext* context) override; 41 content::BrowserContext* GetOriginalContext( 42 content::BrowserContext* context) override; 43 bool IsGuestSession(content::BrowserContext* context) const override; 44 bool IsExtensionIncognitoEnabled( 45 const std::string& extension_id, 46 content::BrowserContext* context) const override; 47 bool CanExtensionCrossIncognito( 48 const Extension* extension, 49 content::BrowserContext* context) const override; 50 base::FilePath GetBundleResourcePath( 51 const network::ResourceRequest& request, 52 const base::FilePath& extension_resources_path, 53 int* resource_id) const override; 54 void LoadResourceFromResourceBundle( 55 const network::ResourceRequest& request, 56 mojo::PendingReceiver<network::mojom::URLLoader> loader, 57 const base::FilePath& resource_relative_path, 58 const int resource_id, 59 scoped_refptr<net::HttpResponseHeaders> headers, 60 mojo::PendingRemote<network::mojom::URLLoaderClient> client) override; 61 bool AllowCrossRendererResourceLoad( 62 const network::ResourceRequest& request, 63 network::mojom::RequestDestination destination, 64 ui::PageTransition page_transition, 65 int child_id, 66 bool is_incognito, 67 const Extension* extension, 68 const ExtensionSet& extensions, 69 const ProcessMap& process_map) override; 70 PrefService* GetPrefServiceForContext( 71 content::BrowserContext* context) override; 72 void GetEarlyExtensionPrefsObservers( 73 content::BrowserContext* context, 74 std::vector<EarlyExtensionPrefsObserver*>* observers) const override; 75 ProcessManagerDelegate* GetProcessManagerDelegate() const override; 76 std::unique_ptr<ExtensionHostDelegate> CreateExtensionHostDelegate() override; 77 bool CreateBackgroundExtensionHost(const Extension* extension, 78 content::BrowserContext* browser_context, 79 const GURL& url, 80 ExtensionHost** host) override; 81 bool DidVersionUpdate(content::BrowserContext* context) override; 82 void PermitExternalProtocolHandler() override; 83 bool IsInDemoMode() override; 84 bool IsScreensaverInDemoMode(const std::string& app_id) override; 85 bool IsRunningInForcedAppMode() override; 86 bool IsAppModeForcedForApp(const ExtensionId& extension_id) override; 87 bool IsLoggedInAsPublicAccount() override; 88 ExtensionSystemProvider* GetExtensionSystemFactory() override; 89 void RegisterBrowserInterfaceBindersForFrame( 90 mojo::BinderMapWithContext<content::RenderFrameHost*>* binder_map, 91 content::RenderFrameHost* render_frame_host, 92 const Extension* extension) const override; 93 std::unique_ptr<RuntimeAPIDelegate> CreateRuntimeAPIDelegate( 94 content::BrowserContext* context) const override; 95 const ComponentExtensionResourceManager* 96 GetComponentExtensionResourceManager() override; 97 void BroadcastEventToRenderers( 98 events::HistogramValue histogram_value, 99 const std::string& event_name, 100 std::unique_ptr<base::ListValue> args, 101 bool dispatch_to_off_the_record_profiles) override; 102 ExtensionCache* GetExtensionCache() override; 103 bool IsBackgroundUpdateAllowed() override; 104 bool IsMinBrowserVersionSupported(const std::string& min_version) override; 105 ExtensionWebContentsObserver* GetExtensionWebContentsObserver( 106 content::WebContents* web_contents) override; 107 KioskDelegate* GetKioskDelegate() override; 108 bool IsLockScreenContext(content::BrowserContext* context) override; 109 std::string GetApplicationLocale() override; 110 111 private: 112 // Support for extension APIs. 113 std::unique_ptr<ExtensionsAPIClient> api_client_; 114 115 // Resource manager used to supply resources from pak files. 116 std::unique_ptr<ComponentExtensionResourceManager> resource_manager_; 117 118 std::unique_ptr<KioskDelegate> kiosk_delegate_; 119 }; 120 121 } // namespace extensions 122 123 #endif // CEF_LIBCEF_BROWSER_EXTENSIONS_EXTENSIONS_BROWSER_CLIENT_H_ 124