| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/shell_browser_context.h" | 5 #include "content/shell/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/file_util.h" | 10 #include "base/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/shell/shell_download_manager_delegate.h" | 15 #include "content/shell/shell_download_manager_delegate.h" |
| 16 #include "content/shell/shell_resource_context.h" | |
| 17 #include "content/shell/shell_switches.h" | 16 #include "content/shell/shell_switches.h" |
| 18 #include "content/shell/shell_url_request_context_getter.h" | 17 #include "content/shell/shell_url_request_context_getter.h" |
| 19 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
| 20 | 19 |
| 21 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
| 22 #include "base/base_paths_win.h" | 21 #include "base/base_paths_win.h" |
| 23 #elif defined(OS_LINUX) | 22 #elif defined(OS_LINUX) |
| 24 #include "base/nix/xdg_util.h" | 23 #include "base/nix/xdg_util.h" |
| 25 #elif defined(OS_MACOSX) | 24 #elif defined(OS_MACOSX) |
| 26 #include "base/base_paths_mac.h" | 25 #include "base/base_paths_mac.h" |
| 27 #endif | 26 #endif |
| 28 | 27 |
| 29 namespace content { | 28 namespace content { |
| 30 | 29 |
| 31 ShellBrowserContext::ShellBrowserContext(bool off_the_record) | 30 ShellBrowserContext::ShellBrowserContext(bool off_the_record) |
| 32 : off_the_record_(off_the_record), | 31 : off_the_record_(off_the_record), |
| 33 ignore_certificate_errors_(false) { | 32 ignore_certificate_errors_(false), |
| 33 resource_context_(new ShellResourceContext()) { |
| 34 InitWhileIOAllowed(); | 34 InitWhileIOAllowed(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 ShellBrowserContext::~ShellBrowserContext() { | 37 ShellBrowserContext::~ShellBrowserContext() { |
| 38 if (resource_context_.get()) { | 38 if (resource_context_.get()) { |
| 39 BrowserThread::DeleteSoon( | 39 BrowserThread::DeleteSoon( |
| 40 BrowserThread::IO, FROM_HERE, resource_context_.release()); | 40 BrowserThread::IO, FROM_HERE, resource_context_.release()); |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 | 43 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 93 |
| 94 if (!download_manager_delegate_.get()) { | 94 if (!download_manager_delegate_.get()) { |
| 95 download_manager_delegate_ = new ShellDownloadManagerDelegate(); | 95 download_manager_delegate_ = new ShellDownloadManagerDelegate(); |
| 96 download_manager_delegate_->SetDownloadManager(manager); | 96 download_manager_delegate_->SetDownloadManager(manager); |
| 97 } | 97 } |
| 98 | 98 |
| 99 return download_manager_delegate_.get(); | 99 return download_manager_delegate_.get(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 net::URLRequestContextGetter* ShellBrowserContext::GetRequestContext() { | 102 net::URLRequestContextGetter* ShellBrowserContext::GetRequestContext() { |
| 103 if (!url_request_getter_) { | 103 DCHECK(url_request_getter_.get()); |
| 104 url_request_getter_ = new ShellURLRequestContextGetter( | 104 return url_request_getter_.get(); |
| 105 ignore_certificate_errors_, | 105 } |
| 106 GetPath(), | 106 |
| 107 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO), | 107 net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext( |
| 108 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE)); | 108 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 109 } | 109 blob_protocol_handler, |
| 110 return url_request_getter_; | 110 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 111 file_system_protocol_handler, |
| 112 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 113 developer_protocol_handler) { |
| 114 DCHECK(!url_request_getter_.get()); |
| 115 url_request_getter_ = new ShellURLRequestContextGetter( |
| 116 ignore_certificate_errors_, |
| 117 GetPath(), |
| 118 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO), |
| 119 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE), |
| 120 blob_protocol_handler.Pass(), |
| 121 file_system_protocol_handler.Pass(), |
| 122 developer_protocol_handler.Pass()); |
| 123 resource_context_->getter_ = url_request_getter_.get(); |
| 124 return url_request_getter_.get(); |
| 111 } | 125 } |
| 112 | 126 |
| 113 net::URLRequestContextGetter* | 127 net::URLRequestContextGetter* |
| 114 ShellBrowserContext::GetRequestContextForRenderProcess( | 128 ShellBrowserContext::GetRequestContextForRenderProcess( |
| 115 int renderer_child_id) { | 129 int renderer_child_id) { |
| 116 return GetRequestContext(); | 130 return GetRequestContext(); |
| 117 } | 131 } |
| 118 | 132 |
| 119 net::URLRequestContextGetter* | 133 net::URLRequestContextGetter* |
| 120 ShellBrowserContext::GetMediaRequestContext() { | 134 ShellBrowserContext::GetMediaRequestContext() { |
| 121 return GetRequestContext(); | 135 return GetRequestContext(); |
| 122 } | 136 } |
| 123 | 137 |
| 124 net::URLRequestContextGetter* | 138 net::URLRequestContextGetter* |
| 125 ShellBrowserContext::GetMediaRequestContextForRenderProcess( | 139 ShellBrowserContext::GetMediaRequestContextForRenderProcess( |
| 126 int renderer_child_id) { | 140 int renderer_child_id) { |
| 127 return GetRequestContext(); | 141 return GetRequestContext(); |
| 128 } | 142 } |
| 129 | 143 |
| 130 net::URLRequestContextGetter* | 144 net::URLRequestContextGetter* |
| 131 ShellBrowserContext::GetMediaRequestContextForStoragePartition( | 145 ShellBrowserContext::GetMediaRequestContextForStoragePartition( |
| 132 const FilePath& partition_path, | 146 const FilePath& partition_path, |
| 133 bool in_memory) { | 147 bool in_memory) { |
| 134 return GetRequestContext(); | 148 return GetRequestContext(); |
| 135 } | 149 } |
| 136 | 150 |
| 137 net::URLRequestContextGetter* | 151 net::URLRequestContextGetter* |
| 138 ShellBrowserContext::GetRequestContextForStoragePartition( | 152 ShellBrowserContext::CreateRequestContextForStoragePartition( |
| 139 const FilePath& partition_path, | 153 const FilePath& partition_path, |
| 140 bool in_memory) { | 154 bool in_memory, |
| 155 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 156 blob_protocol_handler, |
| 157 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 158 file_system_protocol_handler, |
| 159 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 160 developer_protocol_handler) { |
| 141 return NULL; | 161 return NULL; |
| 142 } | 162 } |
| 143 | 163 |
| 144 ResourceContext* ShellBrowserContext::GetResourceContext() { | 164 ResourceContext* ShellBrowserContext::GetResourceContext() { |
| 145 if (!resource_context_.get()) { | |
| 146 resource_context_.reset(new ShellResourceContext( | |
| 147 static_cast<ShellURLRequestContextGetter*>(GetRequestContext()))); | |
| 148 } | |
| 149 return resource_context_.get(); | 165 return resource_context_.get(); |
| 150 } | 166 } |
| 151 | 167 |
| 152 GeolocationPermissionContext* | 168 GeolocationPermissionContext* |
| 153 ShellBrowserContext::GetGeolocationPermissionContext() { | 169 ShellBrowserContext::GetGeolocationPermissionContext() { |
| 154 return NULL; | 170 return NULL; |
| 155 } | 171 } |
| 156 | 172 |
| 157 SpeechRecognitionPreferences* | 173 SpeechRecognitionPreferences* |
| 158 ShellBrowserContext::GetSpeechRecognitionPreferences() { | 174 ShellBrowserContext::GetSpeechRecognitionPreferences() { |
| 159 return NULL; | 175 return NULL; |
| 160 } | 176 } |
| 161 | 177 |
| 162 quota::SpecialStoragePolicy* ShellBrowserContext::GetSpecialStoragePolicy() { | 178 quota::SpecialStoragePolicy* ShellBrowserContext::GetSpecialStoragePolicy() { |
| 163 return NULL; | 179 return NULL; |
| 164 } | 180 } |
| 165 | 181 |
| 182 ShellBrowserContext::ShellResourceContext::ShellResourceContext() { |
| 183 } |
| 184 |
| 185 ShellBrowserContext::ShellResourceContext::~ShellResourceContext() { |
| 186 } |
| 187 |
| 188 net::HostResolver* |
| 189 ShellBrowserContext::ShellResourceContext::GetHostResolver() { |
| 190 return getter_->host_resolver(); |
| 191 } |
| 192 |
| 193 net::URLRequestContext* |
| 194 ShellBrowserContext::ShellResourceContext::GetRequestContext() { |
| 195 return getter_->GetURLRequestContext(); |
| 196 } |
| 197 |
| 198 |
| 199 |
| 166 } // namespace content | 200 } // namespace content |
| OLD | NEW |