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

Side by Side Diff: content/shell/shell_url_request_context_getter.cc

Issue 11896113: Add chrome-search: access from Instant overlay (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Charlie's comments. Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
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_url_request_context_getter.h" 5 #include "content/shell/shell_url_request_context_getter.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 23 matching lines...) Expand all
34 #include "net/url_request/url_request_job_factory_impl.h" 34 #include "net/url_request/url_request_job_factory_impl.h"
35 35
36 namespace content { 36 namespace content {
37 37
38 ShellURLRequestContextGetter::ShellURLRequestContextGetter( 38 ShellURLRequestContextGetter::ShellURLRequestContextGetter(
39 bool ignore_certificate_errors, 39 bool ignore_certificate_errors,
40 const base::FilePath& base_path, 40 const base::FilePath& base_path,
41 MessageLoop* io_loop, 41 MessageLoop* io_loop,
42 MessageLoop* file_loop, 42 MessageLoop* file_loop,
43 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> 43 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
44 blob_protocol_handler,
45 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
46 file_system_protocol_handler,
47 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
48 developer_protocol_handler, 44 developer_protocol_handler,
49 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> 45 content::ProtocolHandlerMap* protocol_handlers)
50 chrome_protocol_handler,
51 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
52 chrome_devtools_protocol_handler)
53 : ignore_certificate_errors_(ignore_certificate_errors), 46 : ignore_certificate_errors_(ignore_certificate_errors),
54 base_path_(base_path), 47 base_path_(base_path),
55 io_loop_(io_loop), 48 io_loop_(io_loop),
56 file_loop_(file_loop), 49 file_loop_(file_loop),
57 blob_protocol_handler_(blob_protocol_handler.Pass()), 50 developer_protocol_handler_(developer_protocol_handler.Pass()) {
58 file_system_protocol_handler_(file_system_protocol_handler.Pass()),
59 developer_protocol_handler_(developer_protocol_handler.Pass()),
60 chrome_protocol_handler_(chrome_protocol_handler.Pass()),
61 chrome_devtools_protocol_handler_(
62 chrome_devtools_protocol_handler.Pass()) {
63 // Must first be created on the UI thread. 51 // Must first be created on the UI thread.
64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 52 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
65 53
54 std::swap(protocol_handlers_, *protocol_handlers));
55
66 // We must create the proxy config service on the UI loop on Linux because it 56 // We must create the proxy config service on the UI loop on Linux because it
67 // must synchronously run on the glib message loop. This will be passed to 57 // must synchronously run on the glib message loop. This will be passed to
68 // the URLRequestContextStorage on the IO thread in GetURLRequestContext(). 58 // the URLRequestContextStorage on the IO thread in GetURLRequestContext().
69 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { 59 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) {
70 proxy_config_service_.reset( 60 proxy_config_service_.reset(
71 net::ProxyService::CreateSystemProxyConfigService( 61 net::ProxyService::CreateSystemProxyConfigService(
72 io_loop_->message_loop_proxy(), file_loop_)); 62 io_loop_->message_loop_proxy(), file_loop_));
73 } 63 }
74 } 64 }
75 65
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 storage_->set_host_resolver(host_resolver.Pass()); 156 storage_->set_host_resolver(host_resolver.Pass());
167 network_session_params.host_resolver = 157 network_session_params.host_resolver =
168 url_request_context_->host_resolver(); 158 url_request_context_->host_resolver();
169 159
170 net::HttpCache* main_cache = new net::HttpCache( 160 net::HttpCache* main_cache = new net::HttpCache(
171 network_session_params, main_backend); 161 network_session_params, main_backend);
172 storage_->set_http_transaction_factory(main_cache); 162 storage_->set_http_transaction_factory(main_cache);
173 163
174 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( 164 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory(
175 new net::URLRequestJobFactoryImpl()); 165 new net::URLRequestJobFactoryImpl());
176 bool set_protocol = job_factory->SetProtocolHandler( 166 ContentBrowserClient::InstallProtocolHandlers(job_factory.get(),
177 chrome::kBlobScheme, blob_protocol_handler_.release()); 167 &protocol_handlers_);
178 DCHECK(set_protocol);
179 set_protocol = job_factory->SetProtocolHandler(
180 chrome::kFileSystemScheme, file_system_protocol_handler_.release());
181 DCHECK(set_protocol);
182 set_protocol = job_factory->SetProtocolHandler(
183 chrome::kChromeUIScheme, chrome_protocol_handler_.release());
184 DCHECK(set_protocol);
185 set_protocol = job_factory->SetProtocolHandler(
186 chrome::kChromeDevToolsScheme,
187 chrome_devtools_protocol_handler_.release());
188 DCHECK(set_protocol);
189 storage_->set_job_factory(new net::ProtocolInterceptJobFactory( 168 storage_->set_job_factory(new net::ProtocolInterceptJobFactory(
190 job_factory.PassAs<net::URLRequestJobFactory>(), 169 job_factory.PassAs<net::URLRequestJobFactory>(),
191 developer_protocol_handler_.Pass())); 170 developer_protocol_handler_.Pass()));
192 } 171 }
193 172
194 return url_request_context_.get(); 173 return url_request_context_.get();
195 } 174 }
196 175
197 scoped_refptr<base::SingleThreadTaskRunner> 176 scoped_refptr<base::SingleThreadTaskRunner>
198 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { 177 ShellURLRequestContextGetter::GetNetworkTaskRunner() const {
199 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); 178 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
200 } 179 }
201 180
202 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { 181 net::HostResolver* ShellURLRequestContextGetter::host_resolver() {
203 return url_request_context_->host_resolver(); 182 return url_request_context_->host_resolver();
204 } 183 }
205 184
206 } // namespace content 185 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698