Update V8 to version 4.7.16.
[chromium-blink-merge.git] / extensions / browser / test_extensions_browser_client.cc
blobbe9e4b5c30e99da966f3e29ba93d99e5f3d42be5
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 #include "extensions/browser/test_extensions_browser_client.h"
7 #include "base/values.h"
8 #include "content/public/browser/browser_context.h"
9 #include "extensions/browser/extension_host_delegate.h"
10 #include "extensions/browser/test_runtime_api_delegate.h"
11 #include "extensions/browser/updater/null_extension_cache.h"
13 using content::BrowserContext;
15 namespace extensions {
17 TestExtensionsBrowserClient::TestExtensionsBrowserClient(
18 BrowserContext* main_context)
19 : main_context_(main_context),
20 incognito_context_(NULL),
21 process_manager_delegate_(NULL),
22 extension_system_factory_(NULL),
23 extension_cache_(new NullExtensionCache) {
24 DCHECK(main_context_);
25 DCHECK(!main_context_->IsOffTheRecord());
28 TestExtensionsBrowserClient::~TestExtensionsBrowserClient() {}
30 void TestExtensionsBrowserClient::SetIncognitoContext(BrowserContext* context) {
31 // If a context is provided it must be off-the-record.
32 DCHECK(!context || context->IsOffTheRecord());
33 incognito_context_ = context;
36 bool TestExtensionsBrowserClient::IsShuttingDown() { return false; }
38 bool TestExtensionsBrowserClient::AreExtensionsDisabled(
39 const base::CommandLine& command_line,
40 BrowserContext* context) {
41 return false;
44 bool TestExtensionsBrowserClient::IsValidContext(BrowserContext* context) {
45 return context == main_context_ ||
46 (incognito_context_ && context == incognito_context_);
49 bool TestExtensionsBrowserClient::IsSameContext(BrowserContext* first,
50 BrowserContext* second) {
51 DCHECK(first);
52 DCHECK(second);
53 return first == second ||
54 (first == main_context_ && second == incognito_context_) ||
55 (first == incognito_context_ && second == main_context_);
58 bool TestExtensionsBrowserClient::HasOffTheRecordContext(
59 BrowserContext* context) {
60 return context == main_context_ && incognito_context_ != NULL;
63 BrowserContext* TestExtensionsBrowserClient::GetOffTheRecordContext(
64 BrowserContext* context) {
65 if (context == main_context_)
66 return incognito_context_;
67 return NULL;
70 BrowserContext* TestExtensionsBrowserClient::GetOriginalContext(
71 BrowserContext* context) {
72 return main_context_;
75 #if defined(OS_CHROMEOS)
76 std::string TestExtensionsBrowserClient::GetUserIdHashFromContext(
77 content::BrowserContext* context) {
78 return "";
80 #endif
82 bool TestExtensionsBrowserClient::IsGuestSession(
83 BrowserContext* context) const {
84 return false;
87 bool TestExtensionsBrowserClient::IsExtensionIncognitoEnabled(
88 const std::string& extension_id,
89 content::BrowserContext* context) const {
90 return false;
93 bool TestExtensionsBrowserClient::CanExtensionCrossIncognito(
94 const extensions::Extension* extension,
95 content::BrowserContext* context) const {
96 return false;
99 net::URLRequestJob*
100 TestExtensionsBrowserClient::MaybeCreateResourceBundleRequestJob(
101 net::URLRequest* request,
102 net::NetworkDelegate* network_delegate,
103 const base::FilePath& directory_path,
104 const std::string& content_security_policy,
105 bool send_cors_header) {
106 return NULL;
109 bool TestExtensionsBrowserClient::AllowCrossRendererResourceLoad(
110 net::URLRequest* request,
111 bool is_incognito,
112 const Extension* extension,
113 InfoMap* extension_info_map) {
114 return false;
117 PrefService* TestExtensionsBrowserClient::GetPrefServiceForContext(
118 BrowserContext* context) {
119 return NULL;
122 void TestExtensionsBrowserClient::GetEarlyExtensionPrefsObservers(
123 content::BrowserContext* context,
124 std::vector<ExtensionPrefsObserver*>* observers) const {}
126 ProcessManagerDelegate* TestExtensionsBrowserClient::GetProcessManagerDelegate()
127 const {
128 return process_manager_delegate_;
131 scoped_ptr<ExtensionHostDelegate>
132 TestExtensionsBrowserClient::CreateExtensionHostDelegate() {
133 return scoped_ptr<ExtensionHostDelegate>();
136 bool TestExtensionsBrowserClient::DidVersionUpdate(BrowserContext* context) {
137 return false;
140 void TestExtensionsBrowserClient::PermitExternalProtocolHandler() {
143 bool TestExtensionsBrowserClient::IsRunningInForcedAppMode() { return false; }
145 ApiActivityMonitor* TestExtensionsBrowserClient::GetApiActivityMonitor(
146 BrowserContext* context) {
147 return NULL;
150 ExtensionSystemProvider*
151 TestExtensionsBrowserClient::GetExtensionSystemFactory() {
152 DCHECK(extension_system_factory_);
153 return extension_system_factory_;
156 void TestExtensionsBrowserClient::RegisterExtensionFunctions(
157 ExtensionFunctionRegistry* registry) const {}
159 void TestExtensionsBrowserClient::RegisterMojoServices(
160 content::RenderFrameHost* render_frame_host,
161 const Extension* extension) const {
164 scoped_ptr<RuntimeAPIDelegate>
165 TestExtensionsBrowserClient::CreateRuntimeAPIDelegate(
166 content::BrowserContext* context) const {
167 return scoped_ptr<RuntimeAPIDelegate>(new TestRuntimeAPIDelegate());
170 const ComponentExtensionResourceManager*
171 TestExtensionsBrowserClient::GetComponentExtensionResourceManager() {
172 return NULL;
175 void TestExtensionsBrowserClient::BroadcastEventToRenderers(
176 events::HistogramValue histogram_value,
177 const std::string& event_name,
178 scoped_ptr<base::ListValue> args) {}
180 net::NetLog* TestExtensionsBrowserClient::GetNetLog() {
181 return NULL;
184 ExtensionCache* TestExtensionsBrowserClient::GetExtensionCache() {
185 return extension_cache_.get();
188 bool TestExtensionsBrowserClient::IsBackgroundUpdateAllowed() {
189 return true;
192 bool TestExtensionsBrowserClient::IsMinBrowserVersionSupported(
193 const std::string& min_version) {
194 return true;
197 ExtensionWebContentsObserver*
198 TestExtensionsBrowserClient::GetExtensionWebContentsObserver(
199 content::WebContents* web_contents) {
200 return nullptr;
203 } // namespace extensions