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

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

Issue 567037: Initial work on making extensions work in incognito mode. (Closed)
Patch Set: added experimental requirement Created 10 years, 10 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
« no previous file with comments | « chrome/browser/net/chrome_url_request_context.h ('k') | chrome/browser/profile.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chrome_thread.h" 10 #include "chrome/browser/chrome_thread.h"
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 context->set_ftp_transaction_factory( 276 context->set_ftp_transaction_factory(
277 new net::FtpNetworkLayer(context->host_resolver())); 277 new net::FtpNetworkLayer(context->host_resolver()));
278 278
279 // Create a separate AppCacheService for OTR mode. 279 // Create a separate AppCacheService for OTR mode.
280 context->set_appcache_service( 280 context->set_appcache_service(
281 new ChromeAppCacheService(profile_dir_path_, context)); 281 new ChromeAppCacheService(profile_dir_path_, context));
282 282
283 return context; 283 return context;
284 } 284 }
285 285
286 // Factory that creates the ChromeURLRequestContext for extensions in incognito
287 // mode.
288 class FactoryForOffTheRecordExtensions
289 : public ChromeURLRequestContextFactory {
290 public:
291 explicit FactoryForOffTheRecordExtensions(Profile* profile)
292 : ChromeURLRequestContextFactory(profile) {}
293
294 virtual ChromeURLRequestContext* Create();
295 };
296
297 ChromeURLRequestContext* FactoryForOffTheRecordExtensions::Create() {
298 ChromeURLRequestContext* context = new ChromeURLRequestContext;
299 ApplyProfileParametersToContext(context);
300
301 net::CookieMonster* cookie_monster = new net::CookieMonster;
302
303 // Enable cookies for extension URLs only.
304 const char* schemes[] = {chrome::kExtensionScheme};
305 cookie_monster->SetCookieableSchemes(schemes, 1);
306 context->set_cookie_store(cookie_monster);
307 // No dynamic cookie policy for extensions.
308
309 return context;
310 }
311
312 // Factory that creates the ChromeURLRequestContext for media. 286 // Factory that creates the ChromeURLRequestContext for media.
313 class FactoryForMedia : public ChromeURLRequestContextFactory { 287 class FactoryForMedia : public ChromeURLRequestContextFactory {
314 public: 288 public:
315 FactoryForMedia(Profile* profile, 289 FactoryForMedia(Profile* profile,
316 const FilePath& disk_cache_path, 290 const FilePath& disk_cache_path,
317 int cache_size, 291 int cache_size,
318 bool off_the_record) 292 bool off_the_record)
319 : ChromeURLRequestContextFactory(profile), 293 : ChromeURLRequestContextFactory(profile),
320 main_context_getter_( 294 main_context_getter_(
321 static_cast<ChromeURLRequestContextGetter*>( 295 static_cast<ChromeURLRequestContextGetter*>(
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 } 468 }
495 469
496 // static 470 // static
497 ChromeURLRequestContextGetter* 471 ChromeURLRequestContextGetter*
498 ChromeURLRequestContextGetter::CreateOffTheRecord(Profile* profile) { 472 ChromeURLRequestContextGetter::CreateOffTheRecord(Profile* profile) {
499 DCHECK(profile->IsOffTheRecord()); 473 DCHECK(profile->IsOffTheRecord());
500 return new ChromeURLRequestContextGetter( 474 return new ChromeURLRequestContextGetter(
501 profile, new FactoryForOffTheRecord(profile)); 475 profile, new FactoryForOffTheRecord(profile));
502 } 476 }
503 477
504 // static
505 ChromeURLRequestContextGetter*
506 ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions(
507 Profile* profile) {
508 DCHECK(profile->IsOffTheRecord());
509 return new ChromeURLRequestContextGetter(
510 profile,
511 new FactoryForOffTheRecordExtensions(profile));
512 }
513
514 void ChromeURLRequestContextGetter::CleanupOnUIThread() { 478 void ChromeURLRequestContextGetter::CleanupOnUIThread() {
515 CheckCurrentlyOnMainThread(); 479 CheckCurrentlyOnMainThread();
516 480
517 if (prefs_) { 481 if (prefs_) {
518 // Unregister for pref notifications. 482 // Unregister for pref notifications.
519 prefs_->RemovePrefObserver(prefs::kAcceptLanguages, this); 483 prefs_->RemovePrefObserver(prefs::kAcceptLanguages, this);
520 prefs_->RemovePrefObserver(prefs::kDefaultCharset, this); 484 prefs_->RemovePrefObserver(prefs::kDefaultCharset, this);
521 prefs_ = NULL; 485 prefs_ = NULL;
522 } 486 }
523 } 487 }
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 } 924 }
961 925
962 if (command_line.HasSwitch(switches::kProxyBypassList)) { 926 if (command_line.HasSwitch(switches::kProxyBypassList)) {
963 proxy_config->ParseNoProxyList( 927 proxy_config->ParseNoProxyList(
964 WideToASCII(command_line.GetSwitchValue( 928 WideToASCII(command_line.GetSwitchValue(
965 switches::kProxyBypassList))); 929 switches::kProxyBypassList)));
966 } 930 }
967 931
968 return proxy_config; 932 return proxy_config;
969 } 933 }
OLDNEW
« no previous file with comments | « chrome/browser/net/chrome_url_request_context.h ('k') | chrome/browser/profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698