| OLD | NEW |
| 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 28 matching lines...) Expand all Loading... |
| 39 #include "chrome/browser/extensions/extension_pref_value_map_factory.h" | 39 #include "chrome/browser/extensions/extension_pref_value_map_factory.h" |
| 40 #include "chrome/browser/extensions/extension_service.h" | 40 #include "chrome/browser/extensions/extension_service.h" |
| 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/metrics/metrics_service.h" | 47 #include "chrome/browser/metrics/metrics_service.h" |
| 48 #include "chrome/browser/net/chrome_url_request_context.h" | 48 #include "chrome/browser/net/chrome_url_request_context.h" |
| 49 #include "chrome/browser/net/cookie_store_util.h" |
| 49 #include "chrome/browser/net/net_pref_observer.h" | 50 #include "chrome/browser/net/net_pref_observer.h" |
| 50 #include "chrome/browser/net/predictor.h" | 51 #include "chrome/browser/net/predictor.h" |
| 51 #include "chrome/browser/net/pref_proxy_config_tracker.h" | 52 #include "chrome/browser/net/pref_proxy_config_tracker.h" |
| 52 #include "chrome/browser/net/proxy_service_factory.h" | 53 #include "chrome/browser/net/proxy_service_factory.h" |
| 53 #include "chrome/browser/net/ssl_config_service_manager.h" | 54 #include "chrome/browser/net/ssl_config_service_manager.h" |
| 54 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 55 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
| 55 #include "chrome/browser/plugins/plugin_prefs.h" | 56 #include "chrome/browser/plugins/plugin_prefs.h" |
| 56 #include "chrome/browser/policy/profile_policy_connector.h" | 57 #include "chrome/browser/policy/profile_policy_connector.h" |
| 57 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 58 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 58 #include "chrome/browser/prefs/browser_prefs.h" | 59 #include "chrome/browser/prefs/browser_prefs.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 77 #include "chrome/common/chrome_switches.h" | 78 #include "chrome/common/chrome_switches.h" |
| 78 #include "chrome/common/chrome_version_info.h" | 79 #include "chrome/common/chrome_version_info.h" |
| 79 #include "chrome/common/net/url_fixer_upper.h" | 80 #include "chrome/common/net/url_fixer_upper.h" |
| 80 #include "chrome/common/pref_names.h" | 81 #include "chrome/common/pref_names.h" |
| 81 #include "chrome/common/startup_metric_utils.h" | 82 #include "chrome/common/startup_metric_utils.h" |
| 82 #include "chrome/common/url_constants.h" | 83 #include "chrome/common/url_constants.h" |
| 83 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 84 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
| 84 #include "components/user_prefs/pref_registry_syncable.h" | 85 #include "components/user_prefs/pref_registry_syncable.h" |
| 85 #include "components/user_prefs/user_prefs.h" | 86 #include "components/user_prefs/user_prefs.h" |
| 86 #include "content/public/browser/browser_thread.h" | 87 #include "content/public/browser/browser_thread.h" |
| 88 #include "content/public/browser/cookie_store_factory.h" |
| 87 #include "content/public/browser/dom_storage_context.h" | 89 #include "content/public/browser/dom_storage_context.h" |
| 88 #include "content/public/browser/host_zoom_map.h" | 90 #include "content/public/browser/host_zoom_map.h" |
| 89 #include "content/public/browser/notification_service.h" | 91 #include "content/public/browser/notification_service.h" |
| 90 #include "content/public/browser/render_process_host.h" | 92 #include "content/public/browser/render_process_host.h" |
| 91 #include "content/public/browser/storage_partition.h" | 93 #include "content/public/browser/storage_partition.h" |
| 92 #include "content/public/browser/user_metrics.h" | 94 #include "content/public/browser/user_metrics.h" |
| 93 #include "content/public/common/content_constants.h" | 95 #include "content/public/common/content_constants.h" |
| 94 #include "grit/chromium_strings.h" | 96 #include "grit/chromium_strings.h" |
| 95 #include "grit/generated_resources.h" | 97 #include "grit/generated_resources.h" |
| 96 #include "ui/base/l10n/l10n_util.h" | 98 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 bool init_background_mode_manager = true; | 487 bool init_background_mode_manager = true; |
| 486 #if defined(OS_CHROMEOS) | 488 #if defined(OS_CHROMEOS) |
| 487 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kKeepAliveForTest)) | 489 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kKeepAliveForTest)) |
| 488 init_background_mode_manager = false; | 490 init_background_mode_manager = false; |
| 489 #endif | 491 #endif |
| 490 if (init_background_mode_manager) { | 492 if (init_background_mode_manager) { |
| 491 if (g_browser_process->background_mode_manager()) | 493 if (g_browser_process->background_mode_manager()) |
| 492 g_browser_process->background_mode_manager()->RegisterProfile(this); | 494 g_browser_process->background_mode_manager()->RegisterProfile(this); |
| 493 } | 495 } |
| 494 | 496 |
| 495 base::FilePath cookie_path = GetPath(); | |
| 496 cookie_path = cookie_path.Append(chrome::kCookieFilename); | |
| 497 base::FilePath server_bound_cert_path = GetPath(); | 497 base::FilePath server_bound_cert_path = GetPath(); |
| 498 server_bound_cert_path = | 498 server_bound_cert_path = |
| 499 server_bound_cert_path.Append(chrome::kOBCertFilename); | 499 server_bound_cert_path.Append(chrome::kOBCertFilename); |
| 500 base::FilePath cache_path = base_cache_path_; | 500 base::FilePath cache_path = base_cache_path_; |
| 501 int cache_max_size; | 501 int cache_max_size; |
| 502 GetCacheParameters(false, &cache_path, &cache_max_size); | 502 GetCacheParameters(false, &cache_path, &cache_max_size); |
| 503 cache_path = GetCachePath(cache_path); | 503 cache_path = GetCachePath(cache_path); |
| 504 | 504 |
| 505 base::FilePath media_cache_path = base_cache_path_; | 505 base::FilePath media_cache_path = base_cache_path_; |
| 506 int media_cache_max_size; | 506 int media_cache_max_size; |
| 507 GetCacheParameters(true, &media_cache_path, &media_cache_max_size); | 507 GetCacheParameters(true, &media_cache_path, &media_cache_max_size); |
| 508 media_cache_path = GetMediaCachePath(media_cache_path); | 508 media_cache_path = GetMediaCachePath(media_cache_path); |
| 509 | 509 |
| 510 base::FilePath extensions_cookie_path = GetPath(); | 510 base::FilePath extensions_cookie_path = GetPath(); |
| 511 extensions_cookie_path = | 511 extensions_cookie_path = |
| 512 extensions_cookie_path.Append(chrome::kExtensionsCookieFilename); | 512 extensions_cookie_path.Append(chrome::kExtensionsCookieFilename); |
| 513 | 513 |
| 514 base::FilePath infinite_cache_path = GetPath(); | 514 base::FilePath infinite_cache_path = GetPath(); |
| 515 infinite_cache_path = | 515 infinite_cache_path = |
| 516 infinite_cache_path.Append(FILE_PATH_LITERAL("Infinite Cache")); | 516 infinite_cache_path.Append(FILE_PATH_LITERAL("Infinite Cache")); |
| 517 | 517 |
| 518 #if defined(OS_ANDROID) | |
| 519 SessionStartupPref::Type startup_pref_type = | |
| 520 SessionStartupPref::GetDefaultStartupType(); | |
| 521 #else | |
| 522 SessionStartupPref::Type startup_pref_type = | |
| 523 StartupBrowserCreator::GetSessionStartupPref( | |
| 524 *CommandLine::ForCurrentProcess(), this).type; | |
| 525 #endif | |
| 526 bool restore_old_session_cookies = | |
| 527 (GetLastSessionExitType() == Profile::EXIT_CRASHED || | |
| 528 startup_pref_type == SessionStartupPref::LAST); | |
| 529 | |
| 530 InitHostZoomMap(); | 518 InitHostZoomMap(); |
| 531 | 519 |
| 532 // Make sure we initialize the ProfileIOData after everything else has been | 520 // Make sure we initialize the ProfileIOData after everything else has been |
| 533 // initialized that we might be reading from the IO thread. | 521 // initialized that we might be reading from the IO thread. |
| 534 | 522 |
| 535 io_data_.Init(cookie_path, server_bound_cert_path, cache_path, | 523 io_data_.Init(server_bound_cert_path, cache_path, |
| 536 cache_max_size, media_cache_path, media_cache_max_size, | 524 cache_max_size, media_cache_path, media_cache_max_size, |
| 537 extensions_cookie_path, GetPath(), infinite_cache_path, | 525 GetPath(), infinite_cache_path, predictor_, |
| 538 predictor_, | |
| 539 restore_old_session_cookies, | |
| 540 GetSpecialStoragePolicy()); | 526 GetSpecialStoragePolicy()); |
| 541 | 527 |
| 542 #if defined(ENABLE_PLUGINS) | 528 #if defined(ENABLE_PLUGINS) |
| 543 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( | 529 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( |
| 544 PluginPrefs::GetForProfile(this).get(), | 530 PluginPrefs::GetForProfile(this).get(), |
| 545 io_data_.GetResourceContextNoInit()); | 531 io_data_.GetResourceContextNoInit()); |
| 546 #endif | 532 #endif |
| 547 | 533 |
| 548 // Delay README creation to not impact startup performance. | 534 // Delay README creation to not impact startup performance. |
| 549 BrowserThread::PostDelayedTask( | 535 BrowserThread::PostDelayedTask( |
| 550 BrowserThread::FILE, FROM_HERE, | 536 BrowserThread::FILE, FROM_HERE, |
| 551 base::Bind(&EnsureReadmeFile, GetPath()), | 537 base::Bind(&EnsureReadmeFile, GetPath()), |
| 552 base::TimeDelta::FromMilliseconds(create_readme_delay_ms)); | 538 base::TimeDelta::FromMilliseconds(create_readme_delay_ms)); |
| 553 | 539 |
| 554 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 540 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 555 switches::kDisableRestoreSessionState)) { | 541 switches::kDisableRestoreSessionState)) { |
| 556 TRACE_EVENT0("browser", "ProfileImpl::SetSaveSessionStorageOnDisk") | 542 TRACE_EVENT0("browser", "ProfileImpl::SetSaveSessionStorageOnDisk") |
| 557 content::BrowserContext::GetDefaultStoragePartition(this)-> | 543 GetDefaultStoragePartition(this)-> |
| 558 GetDOMStorageContext()->SetSaveSessionStorageOnDisk(); | 544 GetDOMStorageContext()->SetSaveSessionStorageOnDisk(); |
| 559 } | 545 } |
| 560 | 546 |
| 561 // Creation has been finished. | 547 // Creation has been finished. |
| 562 if (delegate_) { | 548 if (delegate_) { |
| 563 TRACE_EVENT0("browser", "ProfileImpl::DoFileInit:DelegateOnProfileCreated") | 549 TRACE_EVENT0("browser", "ProfileImpl::DoFileInit:DelegateOnProfileCreated") |
| 564 delegate_->OnProfileCreated(this, true, IsNewProfile()); | 550 delegate_->OnProfileCreated(this, true, IsNewProfile()); |
| 565 } | 551 } |
| 566 | 552 |
| 567 content::NotificationService::current()->Notify( | 553 content::NotificationService::current()->Notify( |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 | 651 |
| 666 scoped_refptr<base::SequencedTaskRunner> ProfileImpl::GetIOTaskRunner() { | 652 scoped_refptr<base::SequencedTaskRunner> ProfileImpl::GetIOTaskRunner() { |
| 667 return JsonPrefStore::GetTaskRunnerForFile( | 653 return JsonPrefStore::GetTaskRunnerForFile( |
| 668 GetPath(), BrowserThread::GetBlockingPool()); | 654 GetPath(), BrowserThread::GetBlockingPool()); |
| 669 } | 655 } |
| 670 | 656 |
| 671 bool ProfileImpl::IsOffTheRecord() const { | 657 bool ProfileImpl::IsOffTheRecord() const { |
| 672 return false; | 658 return false; |
| 673 } | 659 } |
| 674 | 660 |
| 661 content::CookieStoreConfig ProfileImpl::GetCookieStoreConfig() { |
| 662 // The delegate is stateless so it's silly to create more than one per |
| 663 // profile. |
| 664 if (!cookie_delegate_) { |
| 665 cookie_delegate_ = chrome_browser_net::CreateCookieDelegate(this); |
| 666 } |
| 667 |
| 668 #if defined(OS_ANDROID) |
| 669 SessionStartupPref::Type startup_pref_type = |
| 670 SessionStartupPref::GetDefaultStartupType(); |
| 671 #else |
| 672 SessionStartupPref::Type startup_pref_type = |
| 673 StartupBrowserCreator::GetSessionStartupPref( |
| 674 *CommandLine::ForCurrentProcess(), this).type; |
| 675 #endif |
| 676 bool restore_old_session_cookies = |
| 677 (GetLastSessionExitType() == Profile::EXIT_CRASHED || |
| 678 startup_pref_type == SessionStartupPref::LAST); |
| 679 |
| 680 if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) { |
| 681 return content::CookieStoreConfig::InMemoryWithOptions( |
| 682 GetSpecialStoragePolicy(), cookie_delegate_); |
| 683 } |
| 684 |
| 685 return content::CookieStoreConfig::PersistentWithOptions( |
| 686 GetPath().Append(content::kCookieFilename), |
| 687 restore_old_session_cookies, GetSpecialStoragePolicy(), |
| 688 cookie_delegate_); |
| 689 } |
| 690 |
| 675 Profile* ProfileImpl::GetOffTheRecordProfile() { | 691 Profile* ProfileImpl::GetOffTheRecordProfile() { |
| 676 if (!off_the_record_profile_) { | 692 if (!off_the_record_profile_) { |
| 677 scoped_ptr<Profile> p(CreateOffTheRecordProfile()); | 693 scoped_ptr<Profile> p(CreateOffTheRecordProfile()); |
| 678 off_the_record_profile_.swap(p); | 694 off_the_record_profile_.swap(p); |
| 679 | 695 |
| 680 content::NotificationService::current()->Notify( | 696 content::NotificationService::current()->Notify( |
| 681 chrome::NOTIFICATION_PROFILE_CREATED, | 697 chrome::NOTIFICATION_PROFILE_CREATED, |
| 682 content::Source<Profile>(off_the_record_profile_.get()), | 698 content::Source<Profile>(off_the_record_profile_.get()), |
| 683 content::NotificationService::NoDetails()); | 699 content::NotificationService::NoDetails()); |
| 684 } | 700 } |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 const GURL& requesting_frame, | 880 const GURL& requesting_frame, |
| 865 const MIDISysExPermissionCallback& callback) { | 881 const MIDISysExPermissionCallback& callback) { |
| 866 // TODO(toyoshim): Implement. http://crbug.com/257618 . | 882 // TODO(toyoshim): Implement. http://crbug.com/257618 . |
| 867 callback.Run(false); | 883 callback.Run(false); |
| 868 } | 884 } |
| 869 | 885 |
| 870 content::ResourceContext* ProfileImpl::GetResourceContext() { | 886 content::ResourceContext* ProfileImpl::GetResourceContext() { |
| 871 return io_data_.GetResourceContext(); | 887 return io_data_.GetResourceContext(); |
| 872 } | 888 } |
| 873 | 889 |
| 874 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() { | |
| 875 return io_data_.GetExtensionsRequestContextGetter().get(); | |
| 876 } | |
| 877 | |
| 878 net::URLRequestContextGetter* | 890 net::URLRequestContextGetter* |
| 879 ProfileImpl::CreateRequestContextForStoragePartition( | 891 ProfileImpl::CreateRequestContextForStoragePartition( |
| 880 const base::FilePath& partition_path, | 892 const base::FilePath& partition_path, |
| 881 bool in_memory, | 893 bool in_memory, |
| 882 content::ProtocolHandlerMap* protocol_handlers) { | 894 content::ProtocolHandlerMap* protocol_handlers) { |
| 883 return io_data_.CreateIsolatedAppRequestContextGetter( | 895 return io_data_.CreateIsolatedAppRequestContextGetter( |
| 884 partition_path, in_memory, protocol_handlers).get(); | 896 partition_path, in_memory, protocol_handlers).get(); |
| 885 } | 897 } |
| 886 | 898 |
| 887 net::SSLConfigService* ProfileImpl::GetSSLConfigService() { | 899 net::SSLConfigService* ProfileImpl::GetSSLConfigService() { |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() { | 1172 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() { |
| 1161 #if defined(OS_CHROMEOS) | 1173 #if defined(OS_CHROMEOS) |
| 1162 if (chromeos::ProfileHelper::IsSigninProfile(this)) { | 1174 if (chromeos::ProfileHelper::IsSigninProfile(this)) { |
| 1163 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( | 1175 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
| 1164 g_browser_process->local_state()); | 1176 g_browser_process->local_state()); |
| 1165 } | 1177 } |
| 1166 #endif // defined(OS_CHROMEOS) | 1178 #endif // defined(OS_CHROMEOS) |
| 1167 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( | 1179 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( |
| 1168 GetPrefs(), g_browser_process->local_state()); | 1180 GetPrefs(), g_browser_process->local_state()); |
| 1169 } | 1181 } |
| OLD | NEW |