Update V8 to version 4.7.16.
[chromium-blink-merge.git] / extensions / browser / test_extensions_browser_client.h
blob86f0576555d348205f01707b96cbc744faeae7d7
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_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_
6 #define EXTENSIONS_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_
8 #include "base/compiler_specific.h"
9 #include "extensions/browser/extensions_browser_client.h"
10 #include "extensions/browser/updater/extension_cache.h"
12 namespace extensions {
14 // A simplified ExtensionsBrowserClient for a single normal browser context and
15 // an optional incognito browser context associated with it. A test that uses
16 // this class should call ExtensionsBrowserClient::Set() with its instance.
17 class TestExtensionsBrowserClient : public ExtensionsBrowserClient {
18 public:
19 // |main_context| is required and must not be an incognito context.
20 explicit TestExtensionsBrowserClient(content::BrowserContext* main_context);
21 ~TestExtensionsBrowserClient() override;
23 void set_process_manager_delegate(ProcessManagerDelegate* delegate) {
24 process_manager_delegate_ = delegate;
26 void set_extension_system_factory(ExtensionSystemProvider* factory) {
27 extension_system_factory_ = factory;
29 void set_extension_cache(scoped_ptr<ExtensionCache> extension_cache) {
30 extension_cache_ = extension_cache.Pass();
33 // Associates an incognito context with |main_context_|.
34 void SetIncognitoContext(content::BrowserContext* incognito_context);
36 // ExtensionsBrowserClient overrides:
37 bool IsShuttingDown() override;
38 bool AreExtensionsDisabled(const base::CommandLine& command_line,
39 content::BrowserContext* context) override;
40 bool IsValidContext(content::BrowserContext* context) override;
41 bool IsSameContext(content::BrowserContext* first,
42 content::BrowserContext* second) override;
43 bool HasOffTheRecordContext(content::BrowserContext* context) override;
44 content::BrowserContext* GetOffTheRecordContext(
45 content::BrowserContext* context) override;
46 content::BrowserContext* GetOriginalContext(
47 content::BrowserContext* context) override;
48 #if defined(OS_CHROMEOS)
49 std::string GetUserIdHashFromContext(
50 content::BrowserContext* context) override;
51 #endif
52 bool IsGuestSession(content::BrowserContext* context) const override;
53 bool IsExtensionIncognitoEnabled(
54 const std::string& extension_id,
55 content::BrowserContext* context) const override;
56 bool CanExtensionCrossIncognito(
57 const extensions::Extension* extension,
58 content::BrowserContext* context) const override;
59 net::URLRequestJob* MaybeCreateResourceBundleRequestJob(
60 net::URLRequest* request,
61 net::NetworkDelegate* network_delegate,
62 const base::FilePath& directory_path,
63 const std::string& content_security_policy,
64 bool send_cors_header) override;
65 bool AllowCrossRendererResourceLoad(net::URLRequest* request,
66 bool is_incognito,
67 const Extension* extension,
68 InfoMap* extension_info_map) override;
69 PrefService* GetPrefServiceForContext(
70 content::BrowserContext* context) override;
71 void GetEarlyExtensionPrefsObservers(
72 content::BrowserContext* context,
73 std::vector<ExtensionPrefsObserver*>* observers) const override;
74 ProcessManagerDelegate* GetProcessManagerDelegate() const override;
75 scoped_ptr<ExtensionHostDelegate> CreateExtensionHostDelegate() override;
76 bool DidVersionUpdate(content::BrowserContext* context) override;
77 void PermitExternalProtocolHandler() override;
78 bool IsRunningInForcedAppMode() override;
79 ApiActivityMonitor* GetApiActivityMonitor(
80 content::BrowserContext* context) override;
81 ExtensionSystemProvider* GetExtensionSystemFactory() override;
82 void RegisterExtensionFunctions(
83 ExtensionFunctionRegistry* registry) const override;
84 void RegisterMojoServices(content::RenderFrameHost* render_frame_host,
85 const Extension* extension) const override;
86 scoped_ptr<RuntimeAPIDelegate> CreateRuntimeAPIDelegate(
87 content::BrowserContext* context) const override;
88 const ComponentExtensionResourceManager*
89 GetComponentExtensionResourceManager() override;
90 void BroadcastEventToRenderers(events::HistogramValue histogram_value,
91 const std::string& event_name,
92 scoped_ptr<base::ListValue> args) override;
93 net::NetLog* GetNetLog() override;
94 ExtensionCache* GetExtensionCache() override;
95 bool IsBackgroundUpdateAllowed() override;
96 bool IsMinBrowserVersionSupported(const std::string& min_version) override;
97 ExtensionWebContentsObserver* GetExtensionWebContentsObserver(
98 content::WebContents* web_contents) override;
100 private:
101 content::BrowserContext* main_context_; // Not owned.
102 content::BrowserContext* incognito_context_; // Not owned, defaults to NULL.
104 // Not owned, defaults to NULL.
105 ProcessManagerDelegate* process_manager_delegate_;
107 // Not owned, defaults to NULL.
108 ExtensionSystemProvider* extension_system_factory_;
110 scoped_ptr<ExtensionCache> extension_cache_;
112 DISALLOW_COPY_AND_ASSIGN(TestExtensionsBrowserClient);
115 } // namespace extensions
117 #endif // EXTENSIONS_BROWSER_TEST_EXTENSIONS_BROWSER_CLIENT_H_