| 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" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 net::URLRequestContext* | 43 net::URLRequestContext* |
| 44 ShellBrowserContext::ShellResourceContext::GetRequestContext() { | 44 ShellBrowserContext::ShellResourceContext::GetRequestContext() { |
| 45 CHECK(getter_); | 45 CHECK(getter_); |
| 46 return getter_->GetURLRequestContext(); | 46 return getter_->GetURLRequestContext(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 ShellBrowserContext::ShellBrowserContext(bool off_the_record, | 49 ShellBrowserContext::ShellBrowserContext(bool off_the_record, |
| 50 net::NetLog* net_log) | 50 net::NetLog* net_log) |
| 51 : resource_context_(new ShellResourceContext), | 51 : resource_context_(new ShellResourceContext), |
| 52 ignore_certificate_errors_(false), |
| 52 off_the_record_(off_the_record), | 53 off_the_record_(off_the_record), |
| 53 net_log_(net_log), | 54 net_log_(net_log), |
| 54 ignore_certificate_errors_(false), | |
| 55 guest_manager_(NULL) { | 55 guest_manager_(NULL) { |
| 56 InitWhileIOAllowed(); | 56 InitWhileIOAllowed(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 ShellBrowserContext::~ShellBrowserContext() { | 59 ShellBrowserContext::~ShellBrowserContext() { |
| 60 if (resource_context_) { | 60 if (resource_context_) { |
| 61 BrowserThread::DeleteSoon( | 61 BrowserThread::DeleteSoon( |
| 62 BrowserThread::IO, FROM_HERE, resource_context_.release()); | 62 BrowserThread::IO, FROM_HERE, resource_context_.release()); |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 void ShellBrowserContext::InitWhileIOAllowed() { | 66 void ShellBrowserContext::InitWhileIOAllowed() { |
| 67 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 67 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 68 if (cmd_line->HasSwitch(switches::kIgnoreCertificateErrors) || | 68 if (cmd_line->HasSwitch(switches::kIgnoreCertificateErrors)) |
| 69 cmd_line->HasSwitch(switches::kDumpRenderTree)) { | |
| 70 ignore_certificate_errors_ = true; | 69 ignore_certificate_errors_ = true; |
| 71 } | |
| 72 if (cmd_line->HasSwitch(switches::kContentShellDataPath)) { | 70 if (cmd_line->HasSwitch(switches::kContentShellDataPath)) { |
| 73 path_ = cmd_line->GetSwitchValuePath(switches::kContentShellDataPath); | 71 path_ = cmd_line->GetSwitchValuePath(switches::kContentShellDataPath); |
| 74 return; | 72 return; |
| 75 } | 73 } |
| 76 #if defined(OS_WIN) | 74 #if defined(OS_WIN) |
| 77 CHECK(PathService::Get(base::DIR_LOCAL_APP_DATA, &path_)); | 75 CHECK(PathService::Get(base::DIR_LOCAL_APP_DATA, &path_)); |
| 78 path_ = path_.Append(std::wstring(L"content_shell")); | 76 path_ = path_.Append(std::wstring(L"content_shell")); |
| 79 #elif defined(OS_LINUX) | 77 #elif defined(OS_LINUX) |
| 80 scoped_ptr<base::Environment> env(base::Environment::Create()); | 78 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 81 base::FilePath config_dir( | 79 base::FilePath config_dir( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 99 | 97 |
| 100 base::FilePath ShellBrowserContext::GetPath() const { | 98 base::FilePath ShellBrowserContext::GetPath() const { |
| 101 return path_; | 99 return path_; |
| 102 } | 100 } |
| 103 | 101 |
| 104 bool ShellBrowserContext::IsOffTheRecord() const { | 102 bool ShellBrowserContext::IsOffTheRecord() const { |
| 105 return off_the_record_; | 103 return off_the_record_; |
| 106 } | 104 } |
| 107 | 105 |
| 108 DownloadManagerDelegate* ShellBrowserContext::GetDownloadManagerDelegate() { | 106 DownloadManagerDelegate* ShellBrowserContext::GetDownloadManagerDelegate() { |
| 109 DownloadManager* manager = BrowserContext::GetDownloadManager(this); | |
| 110 | |
| 111 if (!download_manager_delegate_.get()) { | 107 if (!download_manager_delegate_.get()) { |
| 112 download_manager_delegate_.reset(new ShellDownloadManagerDelegate()); | 108 download_manager_delegate_.reset(new ShellDownloadManagerDelegate()); |
| 113 download_manager_delegate_->SetDownloadManager(manager); | 109 download_manager_delegate_->SetDownloadManager( |
| 114 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 110 BrowserContext::GetDownloadManager(this)); |
| 115 if (cmd_line->HasSwitch(switches::kDumpRenderTree)) { | |
| 116 download_manager_delegate_->SetDownloadBehaviorForTesting( | |
| 117 path_.Append(FILE_PATH_LITERAL("downloads"))); | |
| 118 } | |
| 119 } | 111 } |
| 120 | 112 |
| 121 return download_manager_delegate_.get(); | 113 return download_manager_delegate_.get(); |
| 122 } | 114 } |
| 123 | 115 |
| 124 net::URLRequestContextGetter* ShellBrowserContext::GetRequestContext() { | 116 net::URLRequestContextGetter* ShellBrowserContext::GetRequestContext() { |
| 125 return GetDefaultStoragePartition(this)->GetURLRequestContext(); | 117 return GetDefaultStoragePartition(this)->GetURLRequestContext(); |
| 126 } | 118 } |
| 127 | 119 |
| 128 net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext( | 120 net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext( |
| 129 ProtocolHandlerMap* protocol_handlers, | 121 ProtocolHandlerMap* protocol_handlers, |
| 130 URLRequestInterceptorScopedVector request_interceptors) { | 122 URLRequestInterceptorScopedVector request_interceptors) { |
| 131 DCHECK(!url_request_getter_.get()); | 123 DCHECK(!url_request_getter_.get()); |
| 132 url_request_getter_ = new ShellURLRequestContextGetter( | 124 url_request_getter_ = new ShellURLRequestContextGetter( |
| 133 ignore_certificate_errors_, | 125 ignore_certificate_errors_, |
| 134 GetPath(), | 126 GetPath(), |
| 135 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO), | 127 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO), |
| 136 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE), | 128 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE), |
| 137 protocol_handlers, | 129 protocol_handlers, |
| 138 request_interceptors.Pass(), | 130 request_interceptors.Pass(), |
| 139 net_log_); | 131 net_log_); |
| 140 resource_context_->set_url_request_context_getter(url_request_getter_.get()); | 132 static_cast<ShellResourceContext*>(resource_context_.get()) |
| 133 ->set_url_request_context_getter(url_request_getter_.get()); |
| 141 return url_request_getter_.get(); | 134 return url_request_getter_.get(); |
| 142 } | 135 } |
| 143 | 136 |
| 144 net::URLRequestContextGetter* | 137 net::URLRequestContextGetter* |
| 145 ShellBrowserContext::GetRequestContextForRenderProcess( | 138 ShellBrowserContext::GetRequestContextForRenderProcess( |
| 146 int renderer_child_id) { | 139 int renderer_child_id) { |
| 147 return GetRequestContext(); | 140 return GetRequestContext(); |
| 148 } | 141 } |
| 149 | 142 |
| 150 net::URLRequestContextGetter* | 143 net::URLRequestContextGetter* |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 | 181 |
| 189 PushMessagingService* ShellBrowserContext::GetPushMessagingService() { | 182 PushMessagingService* ShellBrowserContext::GetPushMessagingService() { |
| 190 return NULL; | 183 return NULL; |
| 191 } | 184 } |
| 192 | 185 |
| 193 SSLHostStateDelegate* ShellBrowserContext::GetSSLHostStateDelegate() { | 186 SSLHostStateDelegate* ShellBrowserContext::GetSSLHostStateDelegate() { |
| 194 return NULL; | 187 return NULL; |
| 195 } | 188 } |
| 196 | 189 |
| 197 } // namespace content | 190 } // namespace content |
| OLD | NEW |