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

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: Refactor and address comments. 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/browser_thread.h" 10 #include "chrome/browser/browser_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 explicit FactoryForIsolatedApp(const ProfileIOData* profile_io_data,
84 const Extension* installed_app)
85 : profile_io_data_(profile_io_data),
86 installed_app_(installed_app) {}
87
88 virtual scoped_refptr<ChromeURLRequestContext> Create() {
89 return profile_io_data_->GetIsolatedAppRequestContext(installed_app_);
90 }
91
92 private:
93 const scoped_refptr<const ProfileIOData> profile_io_data_;
94 const scoped_refptr<const Extension> installed_app_;
95 };
96
80 // Factory that creates the ChromeURLRequestContext for media. 97 // Factory that creates the ChromeURLRequestContext for media.
81 class FactoryForMedia : public ChromeURLRequestContextFactory { 98 class FactoryForMedia : public ChromeURLRequestContextFactory {
82 public: 99 public:
83 explicit FactoryForMedia(const ProfileIOData* profile_io_data) 100 explicit FactoryForMedia(const ProfileIOData* profile_io_data)
84 : profile_io_data_(profile_io_data) { 101 : profile_io_data_(profile_io_data) {
85 } 102 }
86 103
87 virtual scoped_refptr<ChromeURLRequestContext> Create() { 104 virtual scoped_refptr<ChromeURLRequestContext> Create() {
88 return profile_io_data_->GetMediaRequestContext(); 105 return profile_io_data_->GetMediaRequestContext();
89 } 106 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 ChromeURLRequestContextGetter::CreateOriginalForExtensions( 225 ChromeURLRequestContextGetter::CreateOriginalForExtensions(
209 Profile* profile, const ProfileIOData* profile_io_data) { 226 Profile* profile, const ProfileIOData* profile_io_data) {
210 DCHECK(!profile->IsOffTheRecord()); 227 DCHECK(!profile->IsOffTheRecord());
211 return new ChromeURLRequestContextGetter( 228 return new ChromeURLRequestContextGetter(
212 profile, 229 profile,
213 new FactoryForExtensions(profile_io_data)); 230 new FactoryForExtensions(profile_io_data));
214 } 231 }
215 232
216 // static 233 // static
217 ChromeURLRequestContextGetter* 234 ChromeURLRequestContextGetter*
235 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp(Profile* profile,
willchan no longer on Chromium 2011/03/01 23:39:24 http://google-styleguide.googlecode.com/svn/trunk/
Charlie Reis 2011/03/03 01:08:05 Done.
236 const ProfileIOData* profile_io_data, const Extension* installed_app) {
237 DCHECK(!profile->IsOffTheRecord());
238 return new ChromeURLRequestContextGetter(
239 profile,
240 new FactoryForIsolatedApp(profile_io_data, installed_app));
241 }
242
243 // static
244 ChromeURLRequestContextGetter*
218 ChromeURLRequestContextGetter::CreateOffTheRecord( 245 ChromeURLRequestContextGetter::CreateOffTheRecord(
219 Profile* profile, const ProfileIOData* profile_io_data) { 246 Profile* profile, const ProfileIOData* profile_io_data) {
220 DCHECK(profile->IsOffTheRecord()); 247 DCHECK(profile->IsOffTheRecord());
221 return new ChromeURLRequestContextGetter( 248 return new ChromeURLRequestContextGetter(
222 profile, new FactoryForMain(profile_io_data)); 249 profile, new FactoryForMain(profile_io_data));
223 } 250 }
224 251
225 // static 252 // static
226 ChromeURLRequestContextGetter* 253 ChromeURLRequestContextGetter*
227 ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions( 254 ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions(
228 Profile* profile, const ProfileIOData* profile_io_data) { 255 Profile* profile, const ProfileIOData* profile_io_data) {
229 DCHECK(profile->IsOffTheRecord()); 256 DCHECK(profile->IsOffTheRecord());
230 return new ChromeURLRequestContextGetter( 257 return new ChromeURLRequestContextGetter(
231 profile, new FactoryForExtensions(profile_io_data)); 258 profile, new FactoryForExtensions(profile_io_data));
232 } 259 }
233 260
261 // static
262 ChromeURLRequestContextGetter*
263 ChromeURLRequestContextGetter::CreateOffTheRecordForIsolatedApp(
264 Profile* profile,
265 const ProfileIOData* profile_io_data,
266 const Extension* installed_app) {
267 DCHECK(profile->IsOffTheRecord());
268 return new ChromeURLRequestContextGetter(
269 profile, new FactoryForIsolatedApp(profile_io_data, installed_app));
270 }
271
234 void ChromeURLRequestContextGetter::CleanupOnUIThread() { 272 void ChromeURLRequestContextGetter::CleanupOnUIThread() {
235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 273 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
236 // Unregister for pref notifications. 274 // Unregister for pref notifications.
237 DCHECK(!registrar_.IsEmpty()) << "Called more than once!"; 275 DCHECK(!registrar_.IsEmpty()) << "Called more than once!";
238 registrar_.RemoveAll(); 276 registrar_.RemoveAll();
239 } 277 }
240 278
241 // NotificationObserver implementation. 279 // NotificationObserver implementation.
242 void ChromeURLRequestContextGetter::Observe( 280 void ChromeURLRequestContextGetter::Observe(
243 NotificationType type, 281 NotificationType type,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 net::HttpUtil::GenerateAcceptLanguageHeader(accept_language)); 415 net::HttpUtil::GenerateAcceptLanguageHeader(accept_language));
378 } 416 }
379 417
380 void ChromeURLRequestContext::OnDefaultCharsetChange( 418 void ChromeURLRequestContext::OnDefaultCharsetChange(
381 const std::string& default_charset) { 419 const std::string& default_charset) {
382 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 420 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
383 set_referrer_charset(default_charset); 421 set_referrer_charset(default_charset);
384 set_accept_charset( 422 set_accept_charset(
385 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset)); 423 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset));
386 } 424 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698