Roll src/third_party/WebKit f298044:aa8346d (svn 202628:202629)
[chromium-blink-merge.git] / chrome / browser / extensions / chrome_extensions_browser_client.h
blob852a27c5d416261d6c88f43d3f7f73030017fc3e
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 <map>
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"
17 namespace base {
18 class CommandLine;
21 namespace content {
22 class BrowserContext;
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 {
39 public:
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;
58 #endif
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,
73 bool is_incognito,
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 bool IsRunningInForcedAppMode() override;
86 ApiActivityMonitor* GetApiActivityMonitor(
87 content::BrowserContext* context) override;
88 ExtensionSystemProvider* GetExtensionSystemFactory() override;
89 void RegisterExtensionFunctions(
90 ExtensionFunctionRegistry* registry) const override;
91 void RegisterMojoServices(content::RenderFrameHost* render_frame_host,
92 const Extension* extension) const override;
93 scoped_ptr<RuntimeAPIDelegate> CreateRuntimeAPIDelegate(
94 content::BrowserContext* context) const override;
95 const ComponentExtensionResourceManager*
96 GetComponentExtensionResourceManager() override;
97 void BroadcastEventToRenderers(events::HistogramValue histogram_value,
98 const std::string& event_name,
99 scoped_ptr<base::ListValue> args) override;
100 net::NetLog* GetNetLog() override;
101 ExtensionCache* GetExtensionCache() override;
102 bool IsBackgroundUpdateAllowed() override;
103 bool IsMinBrowserVersionSupported(const std::string& min_version) override;
104 ExtensionWebContentsObserver* GetExtensionWebContentsObserver(
105 content::WebContents* web_contents) override;
106 void ReportError(content::BrowserContext* context,
107 scoped_ptr<ExtensionError> error) override;
108 void CleanUpWebView(content::BrowserContext* browser_context,
109 int embedder_process_id,
110 int view_instance_id) override;
111 void AttachExtensionTaskManagerTag(content::WebContents* web_contents,
112 ViewType view_type) override;
114 private:
115 friend struct base::DefaultLazyInstanceTraits<ChromeExtensionsBrowserClient>;
117 // Observer for Chrome-specific notifications.
118 ChromeNotificationObserver notification_observer_;
120 // Support for ProcessManager.
121 scoped_ptr<ChromeProcessManagerDelegate> process_manager_delegate_;
123 // Client for API implementations.
124 scoped_ptr<ChromeExtensionsAPIClient> api_client_;
126 scoped_ptr<ChromeComponentExtensionResourceManager> resource_manager_;
128 scoped_ptr<ExtensionCache> extension_cache_;
130 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsBrowserClient);
133 } // namespace extensions
135 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSIONS_BROWSER_CLIENT_H_