1 // Copyright 2014 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 EXTENSIONS_SHELL_BROWSER_SHELL_EXTENSIONS_BROWSER_CLIENT_H_
6 #define EXTENSIONS_SHELL_BROWSER_SHELL_EXTENSIONS_BROWSER_CLIENT_H_
8 #include "base/compiler_specific.h"
9 #include "extensions/browser/extensions_browser_client.h"
13 namespace extensions
{
15 class ExtensionsAPIClient
;
17 // An ExtensionsBrowserClient that supports a single content::BrowserContent
18 // with no related incognito context.
19 class ShellExtensionsBrowserClient
: public ExtensionsBrowserClient
{
21 // |context| is the single BrowserContext used for IsValidContext() below.
22 // |pref_service| is used for GetPrefServiceForContext() below.
23 ShellExtensionsBrowserClient(content::BrowserContext
* context
,
24 PrefService
* pref_service
);
25 ~ShellExtensionsBrowserClient() override
;
27 // ExtensionsBrowserClient overrides:
28 bool IsShuttingDown() override
;
29 bool AreExtensionsDisabled(const base::CommandLine
& command_line
,
30 content::BrowserContext
* context
) override
;
31 bool IsValidContext(content::BrowserContext
* context
) override
;
32 bool IsSameContext(content::BrowserContext
* first
,
33 content::BrowserContext
* second
) override
;
34 bool HasOffTheRecordContext(content::BrowserContext
* context
) override
;
35 content::BrowserContext
* GetOffTheRecordContext(
36 content::BrowserContext
* context
) override
;
37 content::BrowserContext
* GetOriginalContext(
38 content::BrowserContext
* context
) override
;
39 #if defined(OS_CHROMEOS)
40 std::string
GetUserIdHashFromContext(
41 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 net::URLRequestJob
* MaybeCreateResourceBundleRequestJob(
51 net::URLRequest
* request
,
52 net::NetworkDelegate
* network_delegate
,
53 const base::FilePath
& directory_path
,
54 const std::string
& content_security_policy
,
55 bool send_cors_header
) override
;
56 bool AllowCrossRendererResourceLoad(net::URLRequest
* request
,
58 const Extension
* extension
,
59 InfoMap
* extension_info_map
) override
;
60 PrefService
* GetPrefServiceForContext(
61 content::BrowserContext
* context
) override
;
62 void GetEarlyExtensionPrefsObservers(
63 content::BrowserContext
* context
,
64 std::vector
<ExtensionPrefsObserver
*>* observers
) const override
;
65 ProcessManagerDelegate
* GetProcessManagerDelegate() const override
;
66 scoped_ptr
<ExtensionHostDelegate
> CreateExtensionHostDelegate() override
;
67 bool DidVersionUpdate(content::BrowserContext
* context
) override
;
68 void PermitExternalProtocolHandler() override
;
69 scoped_ptr
<AppSorting
> CreateAppSorting() override
;
70 bool IsRunningInForcedAppMode() override
;
71 ApiActivityMonitor
* GetApiActivityMonitor(
72 content::BrowserContext
* context
) override
;
73 ExtensionSystemProvider
* GetExtensionSystemFactory() override
;
74 void RegisterExtensionFunctions(
75 ExtensionFunctionRegistry
* registry
) const override
;
76 void RegisterMojoServices(content::RenderFrameHost
* render_frame_host
,
77 const Extension
* extension
) const override
;
78 scoped_ptr
<RuntimeAPIDelegate
> CreateRuntimeAPIDelegate(
79 content::BrowserContext
* context
) const override
;
80 const ComponentExtensionResourceManager
*
81 GetComponentExtensionResourceManager() override
;
82 void BroadcastEventToRenderers(const std::string
& event_name
,
83 scoped_ptr
<base::ListValue
> args
) override
;
84 net::NetLog
* GetNetLog() override
;
85 ExtensionCache
* GetExtensionCache() override
;
86 bool IsBackgroundUpdateAllowed() override
;
87 bool IsMinBrowserVersionSupported(const std::string
& min_version
) override
;
89 // Sets the API client.
90 void SetAPIClientForTest(ExtensionsAPIClient
* api_client
);
93 // The single BrowserContext for app_shell. Not owned.
94 content::BrowserContext
* browser_context_
;
96 // The PrefService for |browser_context_|. Not owned.
97 PrefService
* pref_service_
;
99 // Support for extension APIs.
100 scoped_ptr
<ExtensionsAPIClient
> api_client_
;
102 // The extension cache used for download and installation.
103 scoped_ptr
<ExtensionCache
> extension_cache_
;
105 DISALLOW_COPY_AND_ASSIGN(ShellExtensionsBrowserClient
);
108 } // namespace extensions
110 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_EXTENSIONS_BROWSER_CLIENT_H_