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

Side by Side Diff: chrome/browser/profiles/profile_impl.cc

Issue 12546016: Remove the Extensions URLRequestContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android webview init fix merged in. Created 7 years, 3 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
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/profiles/profile_impl_io_data.h » ('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) 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 "chrome/browser/profiles/profile_impl.h" 5 #include "chrome/browser/profiles/profile_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 30 matching lines...) Expand all
41 #include "chrome/browser/extensions/extension_special_storage_policy.h" 41 #include "chrome/browser/extensions/extension_special_storage_policy.h"
42 #include "chrome/browser/extensions/extension_system.h" 42 #include "chrome/browser/extensions/extension_system.h"
43 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" 43 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h"
44 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_facto ry.h" 44 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_facto ry.h"
45 #include "chrome/browser/history/shortcuts_backend.h" 45 #include "chrome/browser/history/shortcuts_backend.h"
46 #include "chrome/browser/history/top_sites.h" 46 #include "chrome/browser/history/top_sites.h"
47 #include "chrome/browser/media/chrome_midi_permission_context.h" 47 #include "chrome/browser/media/chrome_midi_permission_context.h"
48 #include "chrome/browser/media/chrome_midi_permission_context_factory.h" 48 #include "chrome/browser/media/chrome_midi_permission_context_factory.h"
49 #include "chrome/browser/metrics/metrics_service.h" 49 #include "chrome/browser/metrics/metrics_service.h"
50 #include "chrome/browser/net/chrome_url_request_context.h" 50 #include "chrome/browser/net/chrome_url_request_context.h"
51 #include "chrome/browser/net/cookie_store_util.h"
51 #include "chrome/browser/net/net_pref_observer.h" 52 #include "chrome/browser/net/net_pref_observer.h"
52 #include "chrome/browser/net/predictor.h" 53 #include "chrome/browser/net/predictor.h"
53 #include "chrome/browser/net/pref_proxy_config_tracker.h" 54 #include "chrome/browser/net/pref_proxy_config_tracker.h"
54 #include "chrome/browser/net/proxy_service_factory.h" 55 #include "chrome/browser/net/proxy_service_factory.h"
55 #include "chrome/browser/net/ssl_config_service_manager.h" 56 #include "chrome/browser/net/ssl_config_service_manager.h"
56 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" 57 #include "chrome/browser/plugins/chrome_plugin_service_filter.h"
57 #include "chrome/browser/plugins/plugin_prefs.h" 58 #include "chrome/browser/plugins/plugin_prefs.h"
58 #include "chrome/browser/policy/profile_policy_connector.h" 59 #include "chrome/browser/policy/profile_policy_connector.h"
59 #include "chrome/browser/policy/profile_policy_connector_factory.h" 60 #include "chrome/browser/policy/profile_policy_connector_factory.h"
60 #include "chrome/browser/prefs/browser_prefs.h" 61 #include "chrome/browser/prefs/browser_prefs.h"
(...skipping 18 matching lines...) Expand all
79 #include "chrome/common/chrome_switches.h" 80 #include "chrome/common/chrome_switches.h"
80 #include "chrome/common/chrome_version_info.h" 81 #include "chrome/common/chrome_version_info.h"
81 #include "chrome/common/net/url_fixer_upper.h" 82 #include "chrome/common/net/url_fixer_upper.h"
82 #include "chrome/common/pref_names.h" 83 #include "chrome/common/pref_names.h"
83 #include "chrome/common/startup_metric_utils.h" 84 #include "chrome/common/startup_metric_utils.h"
84 #include "chrome/common/url_constants.h" 85 #include "chrome/common/url_constants.h"
85 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" 86 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h"
86 #include "components/user_prefs/pref_registry_syncable.h" 87 #include "components/user_prefs/pref_registry_syncable.h"
87 #include "components/user_prefs/user_prefs.h" 88 #include "components/user_prefs/user_prefs.h"
88 #include "content/public/browser/browser_thread.h" 89 #include "content/public/browser/browser_thread.h"
90 #include "content/public/browser/cookie_store_factory.h"
89 #include "content/public/browser/dom_storage_context.h" 91 #include "content/public/browser/dom_storage_context.h"
90 #include "content/public/browser/host_zoom_map.h" 92 #include "content/public/browser/host_zoom_map.h"
91 #include "content/public/browser/notification_service.h" 93 #include "content/public/browser/notification_service.h"
92 #include "content/public/browser/render_process_host.h" 94 #include "content/public/browser/render_process_host.h"
93 #include "content/public/browser/storage_partition.h" 95 #include "content/public/browser/storage_partition.h"
94 #include "content/public/browser/user_metrics.h" 96 #include "content/public/browser/user_metrics.h"
95 #include "content/public/common/content_constants.h" 97 #include "content/public/common/content_constants.h"
96 #include "grit/chromium_strings.h" 98 #include "grit/chromium_strings.h"
97 #include "grit/generated_resources.h" 99 #include "grit/generated_resources.h"
98 #include "ui/base/l10n/l10n_util.h" 100 #include "ui/base/l10n/l10n_util.h"
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 bool init_background_mode_manager = true; 492 bool init_background_mode_manager = true;
491 #if defined(OS_CHROMEOS) 493 #if defined(OS_CHROMEOS)
492 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kKeepAliveForTest)) 494 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kKeepAliveForTest))
493 init_background_mode_manager = false; 495 init_background_mode_manager = false;
494 #endif 496 #endif
495 if (init_background_mode_manager) { 497 if (init_background_mode_manager) {
496 if (g_browser_process->background_mode_manager()) 498 if (g_browser_process->background_mode_manager())
497 g_browser_process->background_mode_manager()->RegisterProfile(this); 499 g_browser_process->background_mode_manager()->RegisterProfile(this);
498 } 500 }
499 501
500 base::FilePath cookie_path = GetPath();
501 cookie_path = cookie_path.Append(chrome::kCookieFilename);
502 base::FilePath server_bound_cert_path = GetPath(); 502 base::FilePath server_bound_cert_path = GetPath();
503 server_bound_cert_path = 503 server_bound_cert_path =
504 server_bound_cert_path.Append(chrome::kOBCertFilename); 504 server_bound_cert_path.Append(chrome::kOBCertFilename);
505 base::FilePath cache_path = base_cache_path_; 505 base::FilePath cache_path = base_cache_path_;
506 int cache_max_size; 506 int cache_max_size;
507 GetCacheParameters(false, &cache_path, &cache_max_size); 507 GetCacheParameters(false, &cache_path, &cache_max_size);
508 cache_path = GetCachePath(cache_path); 508 cache_path = GetCachePath(cache_path);
509 509
510 base::FilePath media_cache_path = base_cache_path_; 510 base::FilePath media_cache_path = base_cache_path_;
511 int media_cache_max_size; 511 int media_cache_max_size;
512 GetCacheParameters(true, &media_cache_path, &media_cache_max_size); 512 GetCacheParameters(true, &media_cache_path, &media_cache_max_size);
513 media_cache_path = GetMediaCachePath(media_cache_path); 513 media_cache_path = GetMediaCachePath(media_cache_path);
514 514
515 base::FilePath extensions_cookie_path = GetPath(); 515 base::FilePath extensions_cookie_path = GetPath();
516 extensions_cookie_path = 516 extensions_cookie_path =
517 extensions_cookie_path.Append(chrome::kExtensionsCookieFilename); 517 extensions_cookie_path.Append(chrome::kExtensionsCookieFilename);
518 518
519 base::FilePath infinite_cache_path = GetPath(); 519 base::FilePath infinite_cache_path = GetPath();
520 infinite_cache_path = 520 infinite_cache_path =
521 infinite_cache_path.Append(FILE_PATH_LITERAL("Infinite Cache")); 521 infinite_cache_path.Append(FILE_PATH_LITERAL("Infinite Cache"));
522 522
523 #if defined(OS_ANDROID)
524 SessionStartupPref::Type startup_pref_type =
525 SessionStartupPref::GetDefaultStartupType();
526 #else
527 SessionStartupPref::Type startup_pref_type =
528 StartupBrowserCreator::GetSessionStartupPref(
529 *CommandLine::ForCurrentProcess(), this).type;
530 #endif
531 bool restore_old_session_cookies =
532 (GetLastSessionExitType() == Profile::EXIT_CRASHED ||
533 startup_pref_type == SessionStartupPref::LAST);
534
535 InitHostZoomMap(); 523 InitHostZoomMap();
536 524
537 // Make sure we initialize the ProfileIOData after everything else has been 525 // Make sure we initialize the ProfileIOData after everything else has been
538 // initialized that we might be reading from the IO thread. 526 // initialized that we might be reading from the IO thread.
539 527
540 io_data_.Init(cookie_path, server_bound_cert_path, cache_path, 528 io_data_.Init(server_bound_cert_path, cache_path,
541 cache_max_size, media_cache_path, media_cache_max_size, 529 cache_max_size, media_cache_path, media_cache_max_size,
542 extensions_cookie_path, GetPath(), infinite_cache_path, 530 GetPath(), infinite_cache_path, predictor_,
543 predictor_,
544 restore_old_session_cookies,
545 GetSpecialStoragePolicy()); 531 GetSpecialStoragePolicy());
546 532
547 #if defined(ENABLE_PLUGINS) 533 #if defined(ENABLE_PLUGINS)
548 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( 534 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext(
549 PluginPrefs::GetForProfile(this).get(), 535 PluginPrefs::GetForProfile(this).get(),
550 io_data_.GetResourceContextNoInit()); 536 io_data_.GetResourceContextNoInit());
551 #endif 537 #endif
552 538
553 // Delay README creation to not impact startup performance. 539 // Delay README creation to not impact startup performance.
554 BrowserThread::PostDelayedTask( 540 BrowserThread::PostDelayedTask(
555 BrowserThread::FILE, FROM_HERE, 541 BrowserThread::FILE, FROM_HERE,
556 base::Bind(&EnsureReadmeFile, GetPath()), 542 base::Bind(&EnsureReadmeFile, GetPath()),
557 base::TimeDelta::FromMilliseconds(create_readme_delay_ms)); 543 base::TimeDelta::FromMilliseconds(create_readme_delay_ms));
558 544
559 if (!CommandLine::ForCurrentProcess()->HasSwitch( 545 if (!CommandLine::ForCurrentProcess()->HasSwitch(
560 switches::kDisableRestoreSessionState)) { 546 switches::kDisableRestoreSessionState)) {
561 TRACE_EVENT0("browser", "ProfileImpl::SetSaveSessionStorageOnDisk") 547 TRACE_EVENT0("browser", "ProfileImpl::SetSaveSessionStorageOnDisk")
562 content::BrowserContext::GetDefaultStoragePartition(this)-> 548 GetDefaultStoragePartition(this)->
563 GetDOMStorageContext()->SetSaveSessionStorageOnDisk(); 549 GetDOMStorageContext()->SetSaveSessionStorageOnDisk();
564 } 550 }
565 551
566 // Creation has been finished. 552 // Creation has been finished.
567 if (delegate_) { 553 if (delegate_) {
568 TRACE_EVENT0("browser", "ProfileImpl::DoFileInit:DelegateOnProfileCreated") 554 TRACE_EVENT0("browser", "ProfileImpl::DoFileInit:DelegateOnProfileCreated")
569 delegate_->OnProfileCreated(this, true, IsNewProfile()); 555 delegate_->OnProfileCreated(this, true, IsNewProfile());
570 } 556 }
571 557
572 content::NotificationService::current()->Notify( 558 content::NotificationService::current()->Notify(
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 652
667 base::FilePath ProfileImpl::GetPath() const { 653 base::FilePath ProfileImpl::GetPath() const {
668 return path_; 654 return path_;
669 } 655 }
670 656
671 scoped_refptr<base::SequencedTaskRunner> ProfileImpl::GetIOTaskRunner() { 657 scoped_refptr<base::SequencedTaskRunner> ProfileImpl::GetIOTaskRunner() {
672 return JsonPrefStore::GetTaskRunnerForFile( 658 return JsonPrefStore::GetTaskRunnerForFile(
673 GetPath(), BrowserThread::GetBlockingPool()); 659 GetPath(), BrowserThread::GetBlockingPool());
674 } 660 }
675 661
676 bool ProfileImpl::IsOffTheRecord() const { 662 void ProfileImpl::OverrideCookieStoreConfigs(
677 return false; 663 const base::FilePath& partition_path,
664 bool in_memory_partition,
665 bool is_default_partition,
666 CookieSchemeMap* configs) {
667 using content::CookieStoreConfig;
668 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
669
670 // The delegate is stateless so it's silly to create more than one per
671 // profile.
672 if (!cookie_delegate_) {
673 cookie_delegate_ = chrome_browser_net::CreateCookieDelegate(this);
674 }
675
676 #if defined(OS_ANDROID)
677 SessionStartupPref::Type startup_pref_type =
678 SessionStartupPref::GetDefaultStartupType();
679 #else
680 SessionStartupPref::Type startup_pref_type =
681 StartupBrowserCreator::GetSessionStartupPref(
682 *CommandLine::ForCurrentProcess(), this).type;
683 #endif
684
685 CookieStoreConfig::SessionCookieMode session_cookie_mode =
686 CookieStoreConfig::PERSISTANT_SESSION_COOKIES;
687 if (GetLastSessionExitType() == Profile::EXIT_CRASHED ||
688 startup_pref_type == SessionStartupPref::LAST) {
689 session_cookie_mode = CookieStoreConfig::RESTORED_SESSION_COOKIES;
690 }
691
692 chrome_browser_net::SetCookieStoreConfigs(
693 partition_path, in_memory_partition, is_default_partition,
694 session_cookie_mode, GetSpecialStoragePolicy(), cookie_delegate_,
695 configs);
678 } 696 }
679 697
680 Profile* ProfileImpl::GetOffTheRecordProfile() { 698 Profile* ProfileImpl::GetOffTheRecordProfile() {
681 if (!off_the_record_profile_) { 699 if (!off_the_record_profile_) {
682 scoped_ptr<Profile> p(CreateOffTheRecordProfile()); 700 scoped_ptr<Profile> p(CreateOffTheRecordProfile());
683 off_the_record_profile_.swap(p); 701 off_the_record_profile_.swap(p);
684 702
685 content::NotificationService::current()->Notify( 703 content::NotificationService::current()->Notify(
686 chrome::NOTIFICATION_PROFILE_CREATED, 704 chrome::NOTIFICATION_PROFILE_CREATED,
687 content::Source<Profile>(off_the_record_profile_.get()), 705 content::Source<Profile>(off_the_record_profile_.get()),
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 context->RequestMIDISysExPermission(render_process_id, 895 context->RequestMIDISysExPermission(render_process_id,
878 render_view_id, 896 render_view_id,
879 requesting_frame, 897 requesting_frame,
880 callback); 898 callback);
881 } 899 }
882 900
883 content::ResourceContext* ProfileImpl::GetResourceContext() { 901 content::ResourceContext* ProfileImpl::GetResourceContext() {
884 return io_data_.GetResourceContext(); 902 return io_data_.GetResourceContext();
885 } 903 }
886 904
887 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() {
888 return io_data_.GetExtensionsRequestContextGetter().get();
889 }
890
891 net::URLRequestContextGetter* 905 net::URLRequestContextGetter*
892 ProfileImpl::CreateRequestContextForStoragePartition( 906 ProfileImpl::CreateRequestContextForStoragePartition(
893 const base::FilePath& partition_path, 907 const base::FilePath& partition_path,
894 bool in_memory, 908 bool in_memory,
895 content::ProtocolHandlerMap* protocol_handlers) { 909 content::ProtocolHandlerMap* protocol_handlers) {
896 return io_data_.CreateIsolatedAppRequestContextGetter( 910 return io_data_.CreateIsolatedAppRequestContextGetter(
897 partition_path, in_memory, protocol_handlers).get(); 911 partition_path, in_memory, protocol_handlers).get();
898 } 912 }
899 913
900 net::SSLConfigService* ProfileImpl::GetSSLConfigService() { 914 net::SSLConfigService* ProfileImpl::GetSSLConfigService() {
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() { 1187 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() {
1174 #if defined(OS_CHROMEOS) 1188 #if defined(OS_CHROMEOS)
1175 if (chromeos::ProfileHelper::IsSigninProfile(this)) { 1189 if (chromeos::ProfileHelper::IsSigninProfile(this)) {
1176 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( 1190 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState(
1177 g_browser_process->local_state()); 1191 g_browser_process->local_state());
1178 } 1192 }
1179 #endif // defined(OS_CHROMEOS) 1193 #endif // defined(OS_CHROMEOS)
1180 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( 1194 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile(
1181 GetPrefs(), g_browser_process->local_state()); 1195 GetPrefs(), g_browser_process->local_state());
1182 } 1196 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/profiles/profile_impl_io_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698