Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(592)

Side by Side Diff: content/shell/browser/shell_browser_context.cc

Issue 641203004: Revert of Content Shell: Introduce LayoutTestBrowserContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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),
53 off_the_record_(off_the_record), 52 off_the_record_(off_the_record),
54 net_log_(net_log), 53 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)) {
69 ignore_certificate_errors_ = true; 70 ignore_certificate_errors_ = true;
71 }
70 if (cmd_line->HasSwitch(switches::kContentShellDataPath)) { 72 if (cmd_line->HasSwitch(switches::kContentShellDataPath)) {
71 path_ = cmd_line->GetSwitchValuePath(switches::kContentShellDataPath); 73 path_ = cmd_line->GetSwitchValuePath(switches::kContentShellDataPath);
72 return; 74 return;
73 } 75 }
74 #if defined(OS_WIN) 76 #if defined(OS_WIN)
75 CHECK(PathService::Get(base::DIR_LOCAL_APP_DATA, &path_)); 77 CHECK(PathService::Get(base::DIR_LOCAL_APP_DATA, &path_));
76 path_ = path_.Append(std::wstring(L"content_shell")); 78 path_ = path_.Append(std::wstring(L"content_shell"));
77 #elif defined(OS_LINUX) 79 #elif defined(OS_LINUX)
78 scoped_ptr<base::Environment> env(base::Environment::Create()); 80 scoped_ptr<base::Environment> env(base::Environment::Create());
79 base::FilePath config_dir( 81 base::FilePath config_dir(
(...skipping 17 matching lines...) Expand all
97 99
98 base::FilePath ShellBrowserContext::GetPath() const { 100 base::FilePath ShellBrowserContext::GetPath() const {
99 return path_; 101 return path_;
100 } 102 }
101 103
102 bool ShellBrowserContext::IsOffTheRecord() const { 104 bool ShellBrowserContext::IsOffTheRecord() const {
103 return off_the_record_; 105 return off_the_record_;
104 } 106 }
105 107
106 DownloadManagerDelegate* ShellBrowserContext::GetDownloadManagerDelegate() { 108 DownloadManagerDelegate* ShellBrowserContext::GetDownloadManagerDelegate() {
109 DownloadManager* manager = BrowserContext::GetDownloadManager(this);
110
107 if (!download_manager_delegate_.get()) { 111 if (!download_manager_delegate_.get()) {
108 download_manager_delegate_.reset(new ShellDownloadManagerDelegate()); 112 download_manager_delegate_.reset(new ShellDownloadManagerDelegate());
109 download_manager_delegate_->SetDownloadManager( 113 download_manager_delegate_->SetDownloadManager(manager);
110 BrowserContext::GetDownloadManager(this)); 114 CommandLine* cmd_line = CommandLine::ForCurrentProcess();
115 if (cmd_line->HasSwitch(switches::kDumpRenderTree)) {
116 download_manager_delegate_->SetDownloadBehaviorForTesting(
117 path_.Append(FILE_PATH_LITERAL("downloads")));
118 }
111 } 119 }
112 120
113 return download_manager_delegate_.get(); 121 return download_manager_delegate_.get();
114 } 122 }
115 123
116 net::URLRequestContextGetter* ShellBrowserContext::GetRequestContext() { 124 net::URLRequestContextGetter* ShellBrowserContext::GetRequestContext() {
117 return GetDefaultStoragePartition(this)->GetURLRequestContext(); 125 return GetDefaultStoragePartition(this)->GetURLRequestContext();
118 } 126 }
119 127
120 net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext( 128 net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext(
121 ProtocolHandlerMap* protocol_handlers, 129 ProtocolHandlerMap* protocol_handlers,
122 URLRequestInterceptorScopedVector request_interceptors) { 130 URLRequestInterceptorScopedVector request_interceptors) {
123 DCHECK(!url_request_getter_.get()); 131 DCHECK(!url_request_getter_.get());
124 url_request_getter_ = new ShellURLRequestContextGetter( 132 url_request_getter_ = new ShellURLRequestContextGetter(
125 ignore_certificate_errors_, 133 ignore_certificate_errors_,
126 GetPath(), 134 GetPath(),
127 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO), 135 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO),
128 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE), 136 BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE),
129 protocol_handlers, 137 protocol_handlers,
130 request_interceptors.Pass(), 138 request_interceptors.Pass(),
131 net_log_); 139 net_log_);
132 static_cast<ShellResourceContext*>(resource_context_.get()) 140 resource_context_->set_url_request_context_getter(url_request_getter_.get());
133 ->set_url_request_context_getter(url_request_getter_.get());
134 return url_request_getter_.get(); 141 return url_request_getter_.get();
135 } 142 }
136 143
137 net::URLRequestContextGetter* 144 net::URLRequestContextGetter*
138 ShellBrowserContext::GetRequestContextForRenderProcess( 145 ShellBrowserContext::GetRequestContextForRenderProcess(
139 int renderer_child_id) { 146 int renderer_child_id) {
140 return GetRequestContext(); 147 return GetRequestContext();
141 } 148 }
142 149
143 net::URLRequestContextGetter* 150 net::URLRequestContextGetter*
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 188
182 PushMessagingService* ShellBrowserContext::GetPushMessagingService() { 189 PushMessagingService* ShellBrowserContext::GetPushMessagingService() {
183 return NULL; 190 return NULL;
184 } 191 }
185 192
186 SSLHostStateDelegate* ShellBrowserContext::GetSSLHostStateDelegate() { 193 SSLHostStateDelegate* ShellBrowserContext::GetSSLHostStateDelegate() {
187 return NULL; 194 return NULL;
188 } 195 }
189 196
190 } // namespace content 197 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/browser/shell_browser_context.h ('k') | content/shell/browser/shell_browser_main_parts.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698