1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSIONS_BROWSER_CLIENT_H_
6 #define CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSIONS_BROWSER_CLIENT_H_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/lazy_instance.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/browser/extensions/chrome_notification_observer.h"
15 #include "extensions/browser/extensions_browser_client.h"
25 namespace extensions
{
27 class ChromeComponentExtensionResourceManager
;
28 class ChromeExtensionsAPIClient
;
29 class ChromeProcessManagerDelegate
;
30 class ContentSettingsPrefsObserver
;
32 // Implementation of BrowserClient for Chrome, which includes
33 // knowledge of Profiles, BrowserContexts and incognito.
35 // NOTE: Methods that do not require knowledge of browser concepts should be
36 // implemented in ChromeExtensionsClient even if they are only used in the
37 // browser process (see chrome/common/extensions/chrome_extensions_client.h).
38 class ChromeExtensionsBrowserClient
: public ExtensionsBrowserClient
{
40 ChromeExtensionsBrowserClient();
41 ~ChromeExtensionsBrowserClient() override
;
43 // ExtensionsBrowserClient overrides:
44 bool IsShuttingDown() override
;
45 bool AreExtensionsDisabled(const base::CommandLine
& command_line
,
46 content::BrowserContext
* context
) override
;
47 bool IsValidContext(content::BrowserContext
* context
) override
;
48 bool IsSameContext(content::BrowserContext
* first
,
49 content::BrowserContext
* second
) override
;
50 bool HasOffTheRecordContext(content::BrowserContext
* context
) override
;
51 content::BrowserContext
* GetOffTheRecordContext(
52 content::BrowserContext
* context
) override
;
53 content::BrowserContext
* GetOriginalContext(
54 content::BrowserContext
* context
) override
;
55 #if defined(OS_CHROMEOS)
56 std::string
GetUserIdHashFromContext(
57 content::BrowserContext
* context
) override
;
59 bool IsGuestSession(content::BrowserContext
* context
) const override
;
60 bool IsExtensionIncognitoEnabled(
61 const std::string
& extension_id
,
62 content::BrowserContext
* context
) const override
;
63 bool CanExtensionCrossIncognito(
64 const Extension
* extension
,
65 content::BrowserContext
* context
) const override
;
66 net::URLRequestJob
* MaybeCreateResourceBundleRequestJob(
67 net::URLRequest
* request
,
68 net::NetworkDelegate
* network_delegate
,
69 const base::FilePath
& directory_path
,
70 const std::string
& content_security_policy
,
71 bool send_cors_header
) override
;
72 bool AllowCrossRendererResourceLoad(net::URLRequest
* request
,
74 const Extension
* extension
,
75 InfoMap
* extension_info_map
) override
;
76 PrefService
* GetPrefServiceForContext(
77 content::BrowserContext
* context
) override
;
78 void GetEarlyExtensionPrefsObservers(
79 content::BrowserContext
* context
,
80 std::vector
<ExtensionPrefsObserver
*>* observers
) const override
;
81 ProcessManagerDelegate
* GetProcessManagerDelegate() const override
;
82 scoped_ptr
<ExtensionHostDelegate
> CreateExtensionHostDelegate() override
;
83 bool DidVersionUpdate(content::BrowserContext
* context
) override
;
84 void PermitExternalProtocolHandler() override
;
85 scoped_ptr
<AppSorting
> CreateAppSorting(
86 content::BrowserContext
* context
) override
;
87 bool IsRunningInForcedAppMode() override
;
88 ApiActivityMonitor
* GetApiActivityMonitor(
89 content::BrowserContext
* context
) override
;
90 ExtensionSystemProvider
* GetExtensionSystemFactory() override
;
91 void RegisterExtensionFunctions(
92 ExtensionFunctionRegistry
* registry
) const override
;
93 void RegisterMojoServices(content::RenderFrameHost
* render_frame_host
,
94 const Extension
* extension
) const override
;
95 scoped_ptr
<RuntimeAPIDelegate
> CreateRuntimeAPIDelegate(
96 content::BrowserContext
* context
) const override
;
97 const ComponentExtensionResourceManager
*
98 GetComponentExtensionResourceManager() override
;
99 void BroadcastEventToRenderers(events::HistogramValue histogram_value
,
100 const std::string
& event_name
,
101 scoped_ptr
<base::ListValue
> args
) override
;
102 net::NetLog
* GetNetLog() override
;
103 ExtensionCache
* GetExtensionCache() override
;
104 bool IsBackgroundUpdateAllowed() override
;
105 bool IsMinBrowserVersionSupported(const std::string
& min_version
) override
;
106 ExtensionWebContentsObserver
* GetExtensionWebContentsObserver(
107 content::WebContents
* web_contents
) override
;
108 void ReportError(content::BrowserContext
* context
,
109 scoped_ptr
<ExtensionError
> error
) override
;
110 void CleanUpWebView(int embedder_process_id
, int view_instance_id
) override
;
113 friend struct base::DefaultLazyInstanceTraits
<ChromeExtensionsBrowserClient
>;
115 // Observer for Chrome-specific notifications.
116 ChromeNotificationObserver notification_observer_
;
118 // Support for ProcessManager.
119 scoped_ptr
<ChromeProcessManagerDelegate
> process_manager_delegate_
;
121 // Client for API implementations.
122 scoped_ptr
<ChromeExtensionsAPIClient
> api_client_
;
124 scoped_ptr
<ChromeComponentExtensionResourceManager
> resource_manager_
;
126 scoped_ptr
<ExtensionCache
> extension_cache_
;
128 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsBrowserClient
);
131 } // namespace extensions
133 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSIONS_BROWSER_CLIENT_H_