| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "headless/lib/browser/headless_browser_context_impl.h" | 5 #include "headless/lib/browser/headless_browser_context_impl.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/guid.h" | 12 #include "base/guid.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/resource_context.h" | 16 #include "content/public/browser/resource_context.h" |
| 17 #include "content/public/browser/storage_partition.h" | 17 #include "content/public/browser/storage_partition.h" |
| 18 #include "headless/lib/browser/headless_browser_context_options.h" | 18 #include "headless/lib/browser/headless_browser_context_options.h" |
| 19 #include "headless/lib/browser/headless_browser_impl.h" | 19 #include "headless/lib/browser/headless_browser_impl.h" |
| 20 #include "headless/lib/browser/headless_permission_manager.h" |
| 20 #include "headless/lib/browser/headless_url_request_context_getter.h" | 21 #include "headless/lib/browser/headless_url_request_context_getter.h" |
| 21 #include "headless/public/util/black_hole_protocol_handler.h" | 22 #include "headless/public/util/black_hole_protocol_handler.h" |
| 22 #include "headless/public/util/in_memory_protocol_handler.h" | 23 #include "headless/public/util/in_memory_protocol_handler.h" |
| 23 #include "net/url_request/url_request_context.h" | 24 #include "net/url_request/url_request_context.h" |
| 24 | 25 |
| 25 namespace headless { | 26 namespace headless { |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 const char kHeadlessMojomProtocol[] = "headless-mojom"; | 29 const char kHeadlessMojomProtocol[] = "headless-mojom"; |
| 29 } | 30 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 CHECK(url_request_context_getter_); | 77 CHECK(url_request_context_getter_); |
| 77 return url_request_context_getter_->GetURLRequestContext(); | 78 return url_request_context_getter_->GetURLRequestContext(); |
| 78 } | 79 } |
| 79 | 80 |
| 80 HeadlessBrowserContextImpl::HeadlessBrowserContextImpl( | 81 HeadlessBrowserContextImpl::HeadlessBrowserContextImpl( |
| 81 HeadlessBrowserImpl* browser, | 82 HeadlessBrowserImpl* browser, |
| 82 std::unique_ptr<HeadlessBrowserContextOptions> context_options) | 83 std::unique_ptr<HeadlessBrowserContextOptions> context_options) |
| 83 : browser_(browser), | 84 : browser_(browser), |
| 84 context_options_(std::move(context_options)), | 85 context_options_(std::move(context_options)), |
| 85 resource_context_(new HeadlessResourceContext), | 86 resource_context_(new HeadlessResourceContext), |
| 87 permission_manager_(new HeadlessPermissionManager()), |
| 86 id_(base::GenerateGUID()) { | 88 id_(base::GenerateGUID()) { |
| 87 InitWhileIOAllowed(); | 89 InitWhileIOAllowed(); |
| 88 } | 90 } |
| 89 | 91 |
| 90 HeadlessBrowserContextImpl::~HeadlessBrowserContextImpl() { | 92 HeadlessBrowserContextImpl::~HeadlessBrowserContextImpl() { |
| 91 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 93 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 92 | 94 |
| 93 // Destroy all web contents before shutting down storage partitions. | 95 // Destroy all web contents before shutting down storage partitions. |
| 94 web_contents_map_.clear(); | 96 web_contents_map_.clear(); |
| 95 | 97 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 HeadlessBrowserContextImpl::GetPushMessagingService() { | 194 HeadlessBrowserContextImpl::GetPushMessagingService() { |
| 193 return nullptr; | 195 return nullptr; |
| 194 } | 196 } |
| 195 | 197 |
| 196 content::SSLHostStateDelegate* | 198 content::SSLHostStateDelegate* |
| 197 HeadlessBrowserContextImpl::GetSSLHostStateDelegate() { | 199 HeadlessBrowserContextImpl::GetSSLHostStateDelegate() { |
| 198 return nullptr; | 200 return nullptr; |
| 199 } | 201 } |
| 200 | 202 |
| 201 content::PermissionManager* HeadlessBrowserContextImpl::GetPermissionManager() { | 203 content::PermissionManager* HeadlessBrowserContextImpl::GetPermissionManager() { |
| 202 return nullptr; | 204 if (!permission_manager_.get()) |
| 205 permission_manager_.reset(new HeadlessPermissionManager()); |
| 206 return permission_manager_.get(); |
| 203 } | 207 } |
| 204 | 208 |
| 205 content::BackgroundSyncController* | 209 content::BackgroundSyncController* |
| 206 HeadlessBrowserContextImpl::GetBackgroundSyncController() { | 210 HeadlessBrowserContextImpl::GetBackgroundSyncController() { |
| 207 return nullptr; | 211 return nullptr; |
| 208 } | 212 } |
| 209 | 213 |
| 210 net::URLRequestContextGetter* HeadlessBrowserContextImpl::CreateRequestContext( | 214 net::URLRequestContextGetter* HeadlessBrowserContextImpl::CreateRequestContext( |
| 211 content::ProtocolHandlerMap* protocol_handlers, | 215 content::ProtocolHandlerMap* protocol_handlers, |
| 212 content::URLRequestInterceptorScopedVector request_interceptors) { | 216 content::URLRequestInterceptorScopedVector request_interceptors) { |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 HeadlessBrowserContext::Builder::MojoBindings::MojoBindings() {} | 416 HeadlessBrowserContext::Builder::MojoBindings::MojoBindings() {} |
| 413 | 417 |
| 414 HeadlessBrowserContext::Builder::MojoBindings::MojoBindings( | 418 HeadlessBrowserContext::Builder::MojoBindings::MojoBindings( |
| 415 const std::string& mojom_name, | 419 const std::string& mojom_name, |
| 416 const std::string& js_bindings) | 420 const std::string& js_bindings) |
| 417 : mojom_name(mojom_name), js_bindings(js_bindings) {} | 421 : mojom_name(mojom_name), js_bindings(js_bindings) {} |
| 418 | 422 |
| 419 HeadlessBrowserContext::Builder::MojoBindings::~MojoBindings() {} | 423 HeadlessBrowserContext::Builder::MojoBindings::~MojoBindings() {} |
| 420 | 424 |
| 421 } // namespace headless | 425 } // namespace headless |
| OLD | NEW |