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_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/lazy_instance.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/extensions/chrome_notification_observer.h"
13 #include "extensions/browser/extensions_browser_client.h"
23 namespace extensions
{
25 class ChromeExtensionsAPIClient
;
26 class ContentSettingsPrefsObserver
;
28 // Implementation of extensions::BrowserClient for Chrome, which includes
29 // knowledge of Profiles, BrowserContexts and incognito.
31 // NOTE: Methods that do not require knowledge of browser concepts should be
32 // implemented in ChromeExtensionsClient even if they are only used in the
33 // browser process (see chrome/common/extensions/chrome_extensions_client.h).
34 class ChromeExtensionsBrowserClient
: public ExtensionsBrowserClient
{
36 ChromeExtensionsBrowserClient();
37 virtual ~ChromeExtensionsBrowserClient();
39 // BrowserClient overrides:
40 virtual bool IsShuttingDown() OVERRIDE
;
41 virtual bool AreExtensionsDisabled(const base::CommandLine
& command_line
,
42 content::BrowserContext
* context
) OVERRIDE
;
43 virtual bool IsValidContext(content::BrowserContext
* context
) OVERRIDE
;
44 virtual bool IsSameContext(content::BrowserContext
* first
,
45 content::BrowserContext
* second
) OVERRIDE
;
46 virtual bool HasOffTheRecordContext(
47 content::BrowserContext
* context
) OVERRIDE
;
48 virtual content::BrowserContext
* GetOffTheRecordContext(
49 content::BrowserContext
* context
) OVERRIDE
;
50 virtual content::BrowserContext
* GetOriginalContext(
51 content::BrowserContext
* context
) OVERRIDE
;
52 virtual bool IsGuestSession(content::BrowserContext
* context
) const OVERRIDE
;
53 virtual bool IsExtensionIncognitoEnabled(
54 const std::string
& extension_id
,
55 content::BrowserContext
* context
) const OVERRIDE
;
56 virtual bool CanExtensionCrossIncognito(
57 const extensions::Extension
* extension
,
58 content::BrowserContext
* context
) const OVERRIDE
;
59 virtual bool IsWebViewRequest(net::URLRequest
* request
) const OVERRIDE
;
60 virtual net::URLRequestJob
* MaybeCreateResourceBundleRequestJob(
61 net::URLRequest
* request
,
62 net::NetworkDelegate
* network_delegate
,
63 const base::FilePath
& directory_path
,
64 const std::string
& content_security_policy
,
65 bool send_cors_header
) OVERRIDE
;
66 virtual bool AllowCrossRendererResourceLoad(net::URLRequest
* request
,
68 const Extension
* extension
,
69 InfoMap
* extension_info_map
)
71 virtual PrefService
* GetPrefServiceForContext(
72 content::BrowserContext
* context
) OVERRIDE
;
73 virtual void GetEarlyExtensionPrefsObservers(
74 content::BrowserContext
* context
,
75 std::vector
<ExtensionPrefsObserver
*>* observers
) const OVERRIDE
;
76 virtual bool DeferLoadingBackgroundHosts(
77 content::BrowserContext
* context
) const OVERRIDE
;
78 virtual bool IsBackgroundPageAllowed(
79 content::BrowserContext
* context
) const OVERRIDE
;
80 virtual scoped_ptr
<ExtensionHostDelegate
> CreateExtensionHostDelegate()
82 virtual bool DidVersionUpdate(content::BrowserContext
* context
) OVERRIDE
;
83 virtual scoped_ptr
<AppSorting
> CreateAppSorting() OVERRIDE
;
84 virtual bool IsRunningInForcedAppMode() OVERRIDE
;
85 virtual ApiActivityMonitor
* GetApiActivityMonitor(
86 content::BrowserContext
* context
) OVERRIDE
;
87 virtual ExtensionSystemProvider
* GetExtensionSystemFactory() OVERRIDE
;
88 virtual void RegisterExtensionFunctions(
89 ExtensionFunctionRegistry
* registry
) const OVERRIDE
;
90 virtual scoped_ptr
<extensions::RuntimeAPIDelegate
> CreateRuntimeAPIDelegate(
91 content::BrowserContext
* context
) const OVERRIDE
;
94 friend struct base::DefaultLazyInstanceTraits
<ChromeExtensionsBrowserClient
>;
96 // Observer for Chrome-specific notifications.
97 ChromeNotificationObserver notification_observer_
;
99 #if defined(ENABLE_EXTENSIONS)
100 // Client for API implementations.
101 scoped_ptr
<ChromeExtensionsAPIClient
> api_client_
;
104 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsBrowserClient
);
107 } // namespace extensions
109 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSIONS_BROWSER_CLIENT_H_