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

Side by Side Diff: chrome/browser/net/chrome_url_request_context.cc

Issue 6201005: Initial support for partitioning cookies for isolated apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix automation_util and thread issue. Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/net/chrome_url_request_context.h" 5 #include "chrome/browser/net/chrome_url_request_context.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/io_thread.h" 10 #include "chrome/browser/io_thread.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 : profile_io_data_(profile_io_data) {} 70 : profile_io_data_(profile_io_data) {}
71 71
72 virtual scoped_refptr<ChromeURLRequestContext> Create() { 72 virtual scoped_refptr<ChromeURLRequestContext> Create() {
73 return profile_io_data_->GetExtensionsRequestContext(); 73 return profile_io_data_->GetExtensionsRequestContext();
74 } 74 }
75 75
76 private: 76 private:
77 const scoped_refptr<const ProfileIOData> profile_io_data_; 77 const scoped_refptr<const ProfileIOData> profile_io_data_;
78 }; 78 };
79 79
80 // Factory that creates the ChromeURLRequestContext for a given isolated app.
81 class FactoryForIsolatedApp : public ChromeURLRequestContextFactory {
82 public:
83 FactoryForIsolatedApp(const ProfileIOData* profile_io_data,
84 const Extension* installed_app,
85 ChromeURLRequestContextGetter* main_context)
86 : profile_io_data_(profile_io_data),
87 installed_app_(installed_app),
88 main_request_context_getter_(main_context) {}
89
90 virtual scoped_refptr<ChromeURLRequestContext> Create() {
91 // We will copy most of the state from the main request context.
92 return profile_io_data_->GetIsolatedAppRequestContext(
93 main_request_context_getter_->GetIOContext(), installed_app_);
94 }
95
96 private:
97 const scoped_refptr<const ProfileIOData> profile_io_data_;
98 const scoped_refptr<const Extension> installed_app_;
99 scoped_refptr<ChromeURLRequestContextGetter>
100 main_request_context_getter_;
101 };
102
80 // Factory that creates the ChromeURLRequestContext for media. 103 // Factory that creates the ChromeURLRequestContext for media.
81 class FactoryForMedia : public ChromeURLRequestContextFactory { 104 class FactoryForMedia : public ChromeURLRequestContextFactory {
82 public: 105 public:
83 explicit FactoryForMedia(const ProfileIOData* profile_io_data) 106 explicit FactoryForMedia(const ProfileIOData* profile_io_data)
84 : profile_io_data_(profile_io_data) { 107 : profile_io_data_(profile_io_data) {
85 } 108 }
86 109
87 virtual scoped_refptr<ChromeURLRequestContext> Create() { 110 virtual scoped_refptr<ChromeURLRequestContext> Create() {
88 return profile_io_data_->GetMediaRequestContext(); 111 return profile_io_data_->GetMediaRequestContext();
89 } 112 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 ChromeURLRequestContextGetter::CreateOriginalForExtensions( 231 ChromeURLRequestContextGetter::CreateOriginalForExtensions(
209 Profile* profile, const ProfileIOData* profile_io_data) { 232 Profile* profile, const ProfileIOData* profile_io_data) {
210 DCHECK(!profile->IsOffTheRecord()); 233 DCHECK(!profile->IsOffTheRecord());
211 return new ChromeURLRequestContextGetter( 234 return new ChromeURLRequestContextGetter(
212 profile, 235 profile,
213 new FactoryForExtensions(profile_io_data)); 236 new FactoryForExtensions(profile_io_data));
214 } 237 }
215 238
216 // static 239 // static
217 ChromeURLRequestContextGetter* 240 ChromeURLRequestContextGetter*
241 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp(
242 Profile* profile,
243 const ProfileIOData* profile_io_data,
244 const Extension* installed_app) {
245 DCHECK(!profile->IsOffTheRecord());
246 ChromeURLRequestContextGetter* main_context =
247 static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext());
248 return new ChromeURLRequestContextGetter(
249 profile,
250 new FactoryForIsolatedApp(profile_io_data, installed_app, main_context));
251 }
252
253 // static
254 ChromeURLRequestContextGetter*
218 ChromeURLRequestContextGetter::CreateOffTheRecord( 255 ChromeURLRequestContextGetter::CreateOffTheRecord(
219 Profile* profile, const ProfileIOData* profile_io_data) { 256 Profile* profile, const ProfileIOData* profile_io_data) {
220 DCHECK(profile->IsOffTheRecord()); 257 DCHECK(profile->IsOffTheRecord());
221 return new ChromeURLRequestContextGetter( 258 return new ChromeURLRequestContextGetter(
222 profile, new FactoryForMain(profile_io_data)); 259 profile, new FactoryForMain(profile_io_data));
223 } 260 }
224 261
225 // static 262 // static
226 ChromeURLRequestContextGetter* 263 ChromeURLRequestContextGetter*
227 ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions( 264 ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions(
228 Profile* profile, const ProfileIOData* profile_io_data) { 265 Profile* profile, const ProfileIOData* profile_io_data) {
229 DCHECK(profile->IsOffTheRecord()); 266 DCHECK(profile->IsOffTheRecord());
230 return new ChromeURLRequestContextGetter( 267 return new ChromeURLRequestContextGetter(
231 profile, new FactoryForExtensions(profile_io_data)); 268 profile, new FactoryForExtensions(profile_io_data));
232 } 269 }
233 270
271 // static
272 ChromeURLRequestContextGetter*
273 ChromeURLRequestContextGetter::CreateOffTheRecordForIsolatedApp(
274 Profile* profile,
275 const ProfileIOData* profile_io_data,
276 const Extension* installed_app) {
277 DCHECK(profile->IsOffTheRecord());
278 ChromeURLRequestContextGetter* main_context =
279 static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext());
280 return new ChromeURLRequestContextGetter(
281 profile,
282 new FactoryForIsolatedApp(profile_io_data, installed_app, main_context));
283 }
284
234 void ChromeURLRequestContextGetter::CleanupOnUIThread() { 285 void ChromeURLRequestContextGetter::CleanupOnUIThread() {
235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 286 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
236 // Unregister for pref notifications. 287 // Unregister for pref notifications.
237 DCHECK(!registrar_.IsEmpty()) << "Called more than once!"; 288 DCHECK(!registrar_.IsEmpty()) << "Called more than once!";
238 registrar_.RemoveAll(); 289 registrar_.RemoveAll();
239 } 290 }
240 291
241 // NotificationObserver implementation. 292 // NotificationObserver implementation.
242 void ChromeURLRequestContextGetter::Observe( 293 void ChromeURLRequestContextGetter::Observe(
243 NotificationType type, 294 NotificationType type,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 368
318 // ---------------------------------------------------------------------------- 369 // ----------------------------------------------------------------------------
319 // ChromeURLRequestContext 370 // ChromeURLRequestContext
320 // ---------------------------------------------------------------------------- 371 // ----------------------------------------------------------------------------
321 372
322 ChromeURLRequestContext::ChromeURLRequestContext() 373 ChromeURLRequestContext::ChromeURLRequestContext()
323 : is_off_the_record_(false) { 374 : is_off_the_record_(false) {
324 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 375 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
325 } 376 }
326 377
378 void ChromeURLRequestContext::CopyFrom(ChromeURLRequestContext* other) {
379 // Copy ChromeURLRequestContext parameters.
380 set_user_script_dir_path(other->user_script_dir_path());
381 set_appcache_service(other->appcache_service());
382 set_database_tracker(other->database_tracker());
383 set_chrome_cookie_policy(other->chrome_cookie_policy_);
384 set_host_content_settings_map(other->host_content_settings_map());
385 set_host_zoom_map(other->host_zoom_map_);
386 set_blob_storage_context(other->blob_storage_context());
387 set_file_system_context(other->file_system_context());
388 set_extension_info_map(other->extension_info_map_);
389 set_prerender_manager(other->prerender_manager());
390 // ChromeURLDataManagerBackend is unique per context.
391 set_protocol_handler_registry(other->protocol_handler_registry_);
392 set_is_off_the_record(other->is_off_the_record());
393
394 // Copy URLRequestContext parameters.
395 set_net_log(other->net_log());
396 set_host_resolver(other->host_resolver());
397 set_cert_verifier(other->cert_verifier());
398 set_dnsrr_resolver(other->dnsrr_resolver());
399 set_dns_cert_checker(other->dns_cert_checker());
400 set_http_auth_handler_factory(other->http_auth_handler_factory());
401 set_proxy_service(other->proxy_service());
402 set_ssl_config_service(other->ssl_config_service());
403 set_network_delegate(other->network_delegate());
404 set_cookie_store(other->cookie_store());
405 // Cookie policy is set above, via set_chrome_cookie_policy.
406 set_transport_security_state(other->transport_security_state());
407 // FTPAuthCache is unique per context.
408 set_accept_language(other->accept_language());
409 set_accept_charset(other->accept_charset());
410 set_referrer_charset(other->referrer_charset());
411 set_http_transaction_factory(other->http_transaction_factory());
412 set_ftp_transaction_factory(other->ftp_transaction_factory());
413 }
414
327 void ChromeURLRequestContext::set_chrome_cookie_policy( 415 void ChromeURLRequestContext::set_chrome_cookie_policy(
328 ChromeCookiePolicy* cookie_policy) { 416 ChromeCookiePolicy* cookie_policy) {
329 chrome_cookie_policy_ = cookie_policy; // Take a strong reference. 417 chrome_cookie_policy_ = cookie_policy; // Take a strong reference.
330 set_cookie_policy(cookie_policy); 418 set_cookie_policy(cookie_policy);
331 } 419 }
332 420
333 ChromeURLDataManagerBackend* 421 ChromeURLDataManagerBackend*
334 ChromeURLRequestContext::GetChromeURLDataManagerBackend() { 422 ChromeURLRequestContext::GetChromeURLDataManagerBackend() {
335 if (!chrome_url_data_manager_backend_.get()) 423 if (!chrome_url_data_manager_backend_.get())
336 chrome_url_data_manager_backend_.reset(new ChromeURLDataManagerBackend()); 424 chrome_url_data_manager_backend_.reset(new ChromeURLDataManagerBackend());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 net::HttpUtil::GenerateAcceptLanguageHeader(accept_language)); 465 net::HttpUtil::GenerateAcceptLanguageHeader(accept_language));
378 } 466 }
379 467
380 void ChromeURLRequestContext::OnDefaultCharsetChange( 468 void ChromeURLRequestContext::OnDefaultCharsetChange(
381 const std::string& default_charset) { 469 const std::string& default_charset) {
382 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 470 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
383 set_referrer_charset(default_charset); 471 set_referrer_charset(default_charset);
384 set_accept_charset( 472 set_accept_charset(
385 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset)); 473 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset));
386 } 474 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698