| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "extensions/browser/test_extensions_browser_client.h" | 5 #include "extensions/browser/test_extensions_browser_client.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "content/public/browser/browser_context.h" | 9 #include "content/public/browser/browser_context.h" |
| 10 #include "extensions/browser/extension_host_delegate.h" | 10 #include "extensions/browser/extension_host_delegate.h" |
| 11 #include "extensions/browser/test_runtime_api_delegate.h" | 11 #include "extensions/browser/test_runtime_api_delegate.h" |
| 12 #include "extensions/browser/updater/null_extension_cache.h" | 12 #include "extensions/browser/updater/null_extension_cache.h" |
| 13 | 13 |
| 14 #if defined(OS_CHROMEOS) | 14 #if defined(OS_CHROMEOS) |
| 15 #include "chromeos/login/login_state.h" | 15 #include "chromeos/login/login_state.h" |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 using content::BrowserContext; | 18 using content::BrowserContext; |
| 19 | 19 |
| 20 namespace extensions { | 20 namespace extensions { |
| 21 | 21 |
| 22 TestExtensionsBrowserClient::TestExtensionsBrowserClient( | 22 TestExtensionsBrowserClient::TestExtensionsBrowserClient( |
| 23 BrowserContext* main_context) | 23 BrowserContext* main_context) |
| 24 : main_context_(main_context), | 24 : main_context_(main_context), |
| 25 incognito_context_(NULL), | 25 incognito_context_(nullptr), |
| 26 process_manager_delegate_(NULL), | 26 lock_screen_context_(nullptr), |
| 27 extension_system_factory_(NULL), | 27 process_manager_delegate_(nullptr), |
| 28 extension_system_factory_(nullptr), |
| 28 extension_cache_(new NullExtensionCache) { | 29 extension_cache_(new NullExtensionCache) { |
| 29 DCHECK(main_context_); | 30 DCHECK(main_context_); |
| 30 DCHECK(!main_context_->IsOffTheRecord()); | 31 DCHECK(!main_context_->IsOffTheRecord()); |
| 31 } | 32 } |
| 32 | 33 |
| 33 TestExtensionsBrowserClient::~TestExtensionsBrowserClient() {} | 34 TestExtensionsBrowserClient::~TestExtensionsBrowserClient() {} |
| 34 | 35 |
| 35 void TestExtensionsBrowserClient::SetUpdateClientFactory( | 36 void TestExtensionsBrowserClient::SetUpdateClientFactory( |
| 36 const base::Callback<update_client::UpdateClient*(void)>& factory) { | 37 const base::Callback<update_client::UpdateClient*(void)>& factory) { |
| 37 update_client_factory_ = factory; | 38 update_client_factory_ = factory; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 60 BrowserContext* second) { | 61 BrowserContext* second) { |
| 61 DCHECK(first); | 62 DCHECK(first); |
| 62 DCHECK(second); | 63 DCHECK(second); |
| 63 return first == second || | 64 return first == second || |
| 64 (first == main_context_ && second == incognito_context_) || | 65 (first == main_context_ && second == incognito_context_) || |
| 65 (first == incognito_context_ && second == main_context_); | 66 (first == incognito_context_ && second == main_context_); |
| 66 } | 67 } |
| 67 | 68 |
| 68 bool TestExtensionsBrowserClient::HasOffTheRecordContext( | 69 bool TestExtensionsBrowserClient::HasOffTheRecordContext( |
| 69 BrowserContext* context) { | 70 BrowserContext* context) { |
| 70 return context == main_context_ && incognito_context_ != NULL; | 71 return context == main_context_ && incognito_context_ != nullptr; |
| 71 } | 72 } |
| 72 | 73 |
| 73 BrowserContext* TestExtensionsBrowserClient::GetOffTheRecordContext( | 74 BrowserContext* TestExtensionsBrowserClient::GetOffTheRecordContext( |
| 74 BrowserContext* context) { | 75 BrowserContext* context) { |
| 75 if (context == main_context_) | 76 if (context == main_context_) |
| 76 return incognito_context_; | 77 return incognito_context_; |
| 77 return NULL; | 78 return nullptr; |
| 78 } | 79 } |
| 79 | 80 |
| 80 BrowserContext* TestExtensionsBrowserClient::GetOriginalContext( | 81 BrowserContext* TestExtensionsBrowserClient::GetOriginalContext( |
| 81 BrowserContext* context) { | 82 BrowserContext* context) { |
| 82 return main_context_; | 83 return main_context_; |
| 83 } | 84 } |
| 84 | 85 |
| 85 #if defined(OS_CHROMEOS) | 86 #if defined(OS_CHROMEOS) |
| 86 std::string TestExtensionsBrowserClient::GetUserIdHashFromContext( | 87 std::string TestExtensionsBrowserClient::GetUserIdHashFromContext( |
| 87 content::BrowserContext* context) { | 88 content::BrowserContext* context) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 108 return false; | 109 return false; |
| 109 } | 110 } |
| 110 | 111 |
| 111 net::URLRequestJob* | 112 net::URLRequestJob* |
| 112 TestExtensionsBrowserClient::MaybeCreateResourceBundleRequestJob( | 113 TestExtensionsBrowserClient::MaybeCreateResourceBundleRequestJob( |
| 113 net::URLRequest* request, | 114 net::URLRequest* request, |
| 114 net::NetworkDelegate* network_delegate, | 115 net::NetworkDelegate* network_delegate, |
| 115 const base::FilePath& directory_path, | 116 const base::FilePath& directory_path, |
| 116 const std::string& content_security_policy, | 117 const std::string& content_security_policy, |
| 117 bool send_cors_header) { | 118 bool send_cors_header) { |
| 118 return NULL; | 119 return nullptr; |
| 119 } | 120 } |
| 120 | 121 |
| 121 bool TestExtensionsBrowserClient::AllowCrossRendererResourceLoad( | 122 bool TestExtensionsBrowserClient::AllowCrossRendererResourceLoad( |
| 122 net::URLRequest* request, | 123 net::URLRequest* request, |
| 123 bool is_incognito, | 124 bool is_incognito, |
| 124 const Extension* extension, | 125 const Extension* extension, |
| 125 InfoMap* extension_info_map) { | 126 InfoMap* extension_info_map) { |
| 126 return false; | 127 return false; |
| 127 } | 128 } |
| 128 | 129 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 } | 174 } |
| 174 | 175 |
| 175 std::unique_ptr<RuntimeAPIDelegate> | 176 std::unique_ptr<RuntimeAPIDelegate> |
| 176 TestExtensionsBrowserClient::CreateRuntimeAPIDelegate( | 177 TestExtensionsBrowserClient::CreateRuntimeAPIDelegate( |
| 177 content::BrowserContext* context) const { | 178 content::BrowserContext* context) const { |
| 178 return std::unique_ptr<RuntimeAPIDelegate>(new TestRuntimeAPIDelegate()); | 179 return std::unique_ptr<RuntimeAPIDelegate>(new TestRuntimeAPIDelegate()); |
| 179 } | 180 } |
| 180 | 181 |
| 181 const ComponentExtensionResourceManager* | 182 const ComponentExtensionResourceManager* |
| 182 TestExtensionsBrowserClient::GetComponentExtensionResourceManager() { | 183 TestExtensionsBrowserClient::GetComponentExtensionResourceManager() { |
| 183 return NULL; | 184 return nullptr; |
| 184 } | 185 } |
| 185 | 186 |
| 186 void TestExtensionsBrowserClient::BroadcastEventToRenderers( | 187 void TestExtensionsBrowserClient::BroadcastEventToRenderers( |
| 187 events::HistogramValue histogram_value, | 188 events::HistogramValue histogram_value, |
| 188 const std::string& event_name, | 189 const std::string& event_name, |
| 189 std::unique_ptr<base::ListValue> args) {} | 190 std::unique_ptr<base::ListValue> args) {} |
| 190 | 191 |
| 191 net::NetLog* TestExtensionsBrowserClient::GetNetLog() { | 192 net::NetLog* TestExtensionsBrowserClient::GetNetLog() { |
| 192 return NULL; | 193 return nullptr; |
| 193 } | 194 } |
| 194 | 195 |
| 195 ExtensionCache* TestExtensionsBrowserClient::GetExtensionCache() { | 196 ExtensionCache* TestExtensionsBrowserClient::GetExtensionCache() { |
| 196 return extension_cache_.get(); | 197 return extension_cache_.get(); |
| 197 } | 198 } |
| 198 | 199 |
| 199 bool TestExtensionsBrowserClient::IsBackgroundUpdateAllowed() { | 200 bool TestExtensionsBrowserClient::IsBackgroundUpdateAllowed() { |
| 200 return true; | 201 return true; |
| 201 } | 202 } |
| 202 | 203 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 218 scoped_refptr<update_client::UpdateClient> | 219 scoped_refptr<update_client::UpdateClient> |
| 219 TestExtensionsBrowserClient::CreateUpdateClient( | 220 TestExtensionsBrowserClient::CreateUpdateClient( |
| 220 content::BrowserContext* context) { | 221 content::BrowserContext* context) { |
| 221 return update_client_factory_.is_null() | 222 return update_client_factory_.is_null() |
| 222 ? nullptr | 223 ? nullptr |
| 223 : make_scoped_refptr(update_client_factory_.Run()); | 224 : make_scoped_refptr(update_client_factory_.Run()); |
| 224 } | 225 } |
| 225 | 226 |
| 226 bool TestExtensionsBrowserClient::IsLockScreenContext( | 227 bool TestExtensionsBrowserClient::IsLockScreenContext( |
| 227 content::BrowserContext* context) { | 228 content::BrowserContext* context) { |
| 228 return false; | 229 return lock_screen_context_ && context == lock_screen_context_; |
| 229 } | 230 } |
| 230 | 231 |
| 231 } // namespace extensions | 232 } // namespace extensions |
| OLD | NEW |