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 ShellBrowserContext::ShellResourceContext::ShellResourceContext() |
33 public: | 31 : getter_(NULL) { |
34 ShellResourceContext() : getter_(NULL) {} | 32 } |
35 virtual ~ShellResourceContext() {} | |
36 | 33 |
37 // ResourceContext implementation: | 34 ShellBrowserContext::ShellResourceContext::~ShellResourceContext() { |
38 virtual net::HostResolver* GetHostResolver() override { | 35 } |
39 CHECK(getter_); | |
40 return getter_->host_resolver(); | |
41 } | |
42 virtual net::URLRequestContext* GetRequestContext() override { | |
43 CHECK(getter_); | |
44 return getter_->GetURLRequestContext(); | |
45 } | |
46 | 36 |
47 void set_url_request_context_getter(ShellURLRequestContextGetter* getter) { | 37 net::HostResolver* |
48 getter_ = getter; | 38 ShellBrowserContext::ShellResourceContext::GetHostResolver() { |
49 } | 39 CHECK(getter_); |
| 40 return getter_->host_resolver(); |
| 41 } |
50 | 42 |
51 private: | 43 net::URLRequestContext* |
52 ShellURLRequestContextGetter* getter_; | 44 ShellBrowserContext::ShellResourceContext::GetRequestContext() { |
53 | 45 CHECK(getter_); |
54 DISALLOW_COPY_AND_ASSIGN(ShellResourceContext); | 46 return getter_->GetURLRequestContext(); |
55 }; | 47 } |
56 | 48 |
57 ShellBrowserContext::ShellBrowserContext(bool off_the_record, | 49 ShellBrowserContext::ShellBrowserContext(bool off_the_record, |
58 net::NetLog* net_log) | 50 net::NetLog* net_log) |
59 : off_the_record_(off_the_record), | 51 : resource_context_(new ShellResourceContext), |
| 52 off_the_record_(off_the_record), |
60 net_log_(net_log), | 53 net_log_(net_log), |
61 ignore_certificate_errors_(false), | 54 ignore_certificate_errors_(false), |
62 guest_manager_(NULL), | 55 guest_manager_(NULL) { |
63 resource_context_(new ShellResourceContext) { | |
64 InitWhileIOAllowed(); | 56 InitWhileIOAllowed(); |
65 } | 57 } |
66 | 58 |
67 ShellBrowserContext::~ShellBrowserContext() { | 59 ShellBrowserContext::~ShellBrowserContext() { |
68 if (resource_context_) { | 60 if (resource_context_) { |
69 BrowserThread::DeleteSoon( | 61 BrowserThread::DeleteSoon( |
70 BrowserThread::IO, FROM_HERE, resource_context_.release()); | 62 BrowserThread::IO, FROM_HERE, resource_context_.release()); |
71 } | 63 } |
72 } | 64 } |
73 | 65 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 188 |
197 PushMessagingService* ShellBrowserContext::GetPushMessagingService() { | 189 PushMessagingService* ShellBrowserContext::GetPushMessagingService() { |
198 return NULL; | 190 return NULL; |
199 } | 191 } |
200 | 192 |
201 SSLHostStateDelegate* ShellBrowserContext::GetSSLHostStateDelegate() { | 193 SSLHostStateDelegate* ShellBrowserContext::GetSSLHostStateDelegate() { |
202 return NULL; | 194 return NULL; |
203 } | 195 } |
204 | 196 |
205 } // namespace content | 197 } // namespace content |
OLD | NEW |