| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "content/shell/browser/shell_browser_context.h" | 5 #include "content/shell/browser/shell_browser_context.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/environment.h" | 9 #include "base/environment.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/resource_context.h" | |
| 16 #include "content/public/browser/storage_partition.h" | 15 #include "content/public/browser/storage_partition.h" |
| 17 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
| 18 #include "content/shell/browser/shell_download_manager_delegate.h" | 17 #include "content/shell/browser/shell_download_manager_delegate.h" |
| 19 #include "content/shell/browser/shell_url_request_context_getter.h" | |
| 20 #include "content/shell/common/shell_switches.h" | 18 #include "content/shell/common/shell_switches.h" |
| 21 | 19 |
| 22 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
| 23 #include "base/base_paths_win.h" | 21 #include "base/base_paths_win.h" |
| 24 #elif defined(OS_LINUX) | 22 #elif defined(OS_LINUX) |
| 25 #include "base/nix/xdg_util.h" | 23 #include "base/nix/xdg_util.h" |
| 26 #elif defined(OS_MACOSX) | 24 #elif defined(OS_MACOSX) |
| 27 #include "base/base_paths_mac.h" | 25 #include "base/base_paths_mac.h" |
| 28 #endif | 26 #endif |
| 29 | 27 |
| 30 namespace content { | 28 namespace content { |
| 31 | 29 |
| 32 class ShellBrowserContext::ShellResourceContext : public ResourceContext { | 30 net::HostResolver* |
| 33 public: | 31 ShellBrowserContext::ShellResourceContext::GetHostResolver() { |
| 34 ShellResourceContext() : getter_(NULL) {} | 32 CHECK(getter_); |
| 35 virtual ~ShellResourceContext() {} | 33 return getter_->host_resolver(); |
| 34 } |
| 36 | 35 |
| 37 // ResourceContext implementation: | 36 net::URLRequestContext* |
| 38 virtual net::HostResolver* GetHostResolver() override { | 37 ShellBrowserContext::ShellResourceContext::GetRequestContext() { |
| 39 CHECK(getter_); | 38 CHECK(getter_); |
| 40 return getter_->host_resolver(); | 39 return getter_->GetURLRequestContext(); |
| 41 } | 40 } |
| 42 virtual net::URLRequestContext* GetRequestContext() override { | |
| 43 CHECK(getter_); | |
| 44 return getter_->GetURLRequestContext(); | |
| 45 } | |
| 46 | |
| 47 void set_url_request_context_getter(ShellURLRequestContextGetter* getter) { | |
| 48 getter_ = getter; | |
| 49 } | |
| 50 | |
| 51 private: | |
| 52 ShellURLRequestContextGetter* getter_; | |
| 53 | |
| 54 DISALLOW_COPY_AND_ASSIGN(ShellResourceContext); | |
| 55 }; | |
| 56 | 41 |
| 57 ShellBrowserContext::ShellBrowserContext(bool off_the_record, | 42 ShellBrowserContext::ShellBrowserContext(bool off_the_record, |
| 58 net::NetLog* net_log) | 43 net::NetLog* net_log) |
| 59 : off_the_record_(off_the_record), | 44 : resource_context_(new ShellResourceContext), |
| 45 off_the_record_(off_the_record), |
| 60 net_log_(net_log), | 46 net_log_(net_log), |
| 61 ignore_certificate_errors_(false), | 47 ignore_certificate_errors_(false), |
| 62 guest_manager_(NULL), | 48 guest_manager_(NULL) { |
| 63 resource_context_(new ShellResourceContext) { | |
| 64 InitWhileIOAllowed(); | 49 InitWhileIOAllowed(); |
| 65 } | 50 } |
| 66 | 51 |
| 67 ShellBrowserContext::~ShellBrowserContext() { | 52 ShellBrowserContext::~ShellBrowserContext() { |
| 68 if (resource_context_) { | 53 if (resource_context_) { |
| 69 BrowserThread::DeleteSoon( | 54 BrowserThread::DeleteSoon( |
| 70 BrowserThread::IO, FROM_HERE, resource_context_.release()); | 55 BrowserThread::IO, FROM_HERE, resource_context_.release()); |
| 71 } | 56 } |
| 72 } | 57 } |
| 73 | 58 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 181 |
| 197 PushMessagingService* ShellBrowserContext::GetPushMessagingService() { | 182 PushMessagingService* ShellBrowserContext::GetPushMessagingService() { |
| 198 return NULL; | 183 return NULL; |
| 199 } | 184 } |
| 200 | 185 |
| 201 SSLHostStateDelegate* ShellBrowserContext::GetSSLHostStateDelegate() { | 186 SSLHostStateDelegate* ShellBrowserContext::GetSSLHostStateDelegate() { |
| 202 return NULL; | 187 return NULL; |
| 203 } | 188 } |
| 204 | 189 |
| 205 } // namespace content | 190 } // namespace content |
| OLD | NEW |