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_io_data.h" | 5 #include "chrome/browser/profiles/profile_io_data.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 17 matching lines...) Expand all Loading... | |
28 #include "chrome/browser/content_settings/host_content_settings_map.h" | 28 #include "chrome/browser/content_settings/host_content_settings_map.h" |
29 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 29 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
30 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | 30 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
31 #include "chrome/browser/download/download_service.h" | 31 #include "chrome/browser/download/download_service.h" |
32 #include "chrome/browser/download/download_service_factory.h" | 32 #include "chrome/browser/download/download_service_factory.h" |
33 #include "chrome/browser/extensions/extension_info_map.h" | 33 #include "chrome/browser/extensions/extension_info_map.h" |
34 #include "chrome/browser/extensions/extension_protocols.h" | 34 #include "chrome/browser/extensions/extension_protocols.h" |
35 #include "chrome/browser/extensions/extension_resource_protocols.h" | 35 #include "chrome/browser/extensions/extension_resource_protocols.h" |
36 #include "chrome/browser/extensions/extension_system.h" | 36 #include "chrome/browser/extensions/extension_system.h" |
37 #include "chrome/browser/io_thread.h" | 37 #include "chrome/browser/io_thread.h" |
38 #include "chrome/browser/media/media_device_id_salt.h" | |
38 #include "chrome/browser/net/about_protocol_handler.h" | 39 #include "chrome/browser/net/about_protocol_handler.h" |
39 #include "chrome/browser/net/chrome_cookie_notification_details.h" | 40 #include "chrome/browser/net/chrome_cookie_notification_details.h" |
40 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" | 41 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" |
41 #include "chrome/browser/net/chrome_http_user_agent_settings.h" | 42 #include "chrome/browser/net/chrome_http_user_agent_settings.h" |
42 #include "chrome/browser/net/chrome_net_log.h" | 43 #include "chrome/browser/net/chrome_net_log.h" |
43 #include "chrome/browser/net/chrome_network_delegate.h" | 44 #include "chrome/browser/net/chrome_network_delegate.h" |
44 #include "chrome/browser/net/evicted_domain_cookie_counter.h" | 45 #include "chrome/browser/net/evicted_domain_cookie_counter.h" |
45 #include "chrome/browser/net/load_time_stats.h" | 46 #include "chrome/browser/net/load_time_stats.h" |
46 #include "chrome/browser/net/proxy_service_factory.h" | 47 #include "chrome/browser/net/proxy_service_factory.h" |
47 #include "chrome/browser/net/resource_prefetch_predictor_observer.h" | 48 #include "chrome/browser/net/resource_prefetch_predictor_observer.h" |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 &enable_do_not_track_, | 309 &enable_do_not_track_, |
309 &force_safesearch_, | 310 &force_safesearch_, |
310 pref_service); | 311 pref_service); |
311 | 312 |
312 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy = | 313 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy = |
313 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 314 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
314 #if defined(ENABLE_PRINTING) | 315 #if defined(ENABLE_PRINTING) |
315 printing_enabled_.Init(prefs::kPrintingEnabled, pref_service); | 316 printing_enabled_.Init(prefs::kPrintingEnabled, pref_service); |
316 printing_enabled_.MoveToThread(io_message_loop_proxy); | 317 printing_enabled_.MoveToThread(io_message_loop_proxy); |
317 #endif | 318 #endif |
319 | |
318 chrome_http_user_agent_settings_.reset( | 320 chrome_http_user_agent_settings_.reset( |
319 new ChromeHttpUserAgentSettings(pref_service)); | 321 new ChromeHttpUserAgentSettings(pref_service)); |
320 | 322 |
321 // These members are used only for one click sign in, which is not enabled | 323 // These members are used only for one click sign in, which is not enabled |
322 // in incognito mode. So no need to initialize them. | 324 // in incognito mode. So no need to initialize them. |
323 if (!is_incognito()) { | 325 if (!is_incognito()) { |
324 signin_names_.reset(new SigninNamesOnIOThread()); | 326 signin_names_.reset(new SigninNamesOnIOThread()); |
325 | 327 |
326 google_services_username_.Init( | 328 google_services_username_.Init( |
327 prefs::kGoogleServicesUsername, pref_service); | 329 prefs::kGoogleServicesUsername, pref_service); |
(...skipping 11 matching lines...) Expand all Loading... | |
339 prefs::kReverseAutologinRejectedEmailList, pref_service); | 341 prefs::kReverseAutologinRejectedEmailList, pref_service); |
340 one_click_signin_rejected_email_list_.MoveToThread(io_message_loop_proxy); | 342 one_click_signin_rejected_email_list_.MoveToThread(io_message_loop_proxy); |
341 | 343 |
342 sync_disabled_.Init(prefs::kSyncManaged, pref_service); | 344 sync_disabled_.Init(prefs::kSyncManaged, pref_service); |
343 sync_disabled_.MoveToThread(io_message_loop_proxy); | 345 sync_disabled_.MoveToThread(io_message_loop_proxy); |
344 | 346 |
345 signin_allowed_.Init(prefs::kSigninAllowed, pref_service); | 347 signin_allowed_.Init(prefs::kSigninAllowed, pref_service); |
346 signin_allowed_.MoveToThread(io_message_loop_proxy); | 348 signin_allowed_.MoveToThread(io_message_loop_proxy); |
347 } | 349 } |
348 | 350 |
351 media_device_id_salt_.reset(new MediaDeviceIDSalt(pref_service, | |
352 is_incognito())); | |
353 | |
349 // The URLBlacklistManager has to be created on the UI thread to register | 354 // The URLBlacklistManager has to be created on the UI thread to register |
350 // observers of |pref_service|, and it also has to clean up on | 355 // observers of |pref_service|, and it also has to clean up on |
351 // ShutdownOnUIThread to release these observers on the right thread. | 356 // ShutdownOnUIThread to release these observers on the right thread. |
352 // Don't pass it in |profile_params_| to make sure it is correctly cleaned up, | 357 // Don't pass it in |profile_params_| to make sure it is correctly cleaned up, |
353 // in particular when this ProfileIOData isn't |initialized_| during deletion. | 358 // in particular when this ProfileIOData isn't |initialized_| during deletion. |
354 #if defined(ENABLE_CONFIGURATION_POLICY) | 359 #if defined(ENABLE_CONFIGURATION_POLICY) |
355 url_blacklist_manager_.reset(new policy::URLBlacklistManager(pref_service)); | 360 url_blacklist_manager_.reset(new policy::URLBlacklistManager(pref_service)); |
356 #endif | 361 #endif |
357 | 362 |
358 initialized_on_UI_thread_ = true; | 363 initialized_on_UI_thread_ = true; |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
638 return host_content_settings_map_.get(); | 643 return host_content_settings_map_.get(); |
639 } | 644 } |
640 | 645 |
641 #if defined(ENABLE_NOTIFICATIONS) | 646 #if defined(ENABLE_NOTIFICATIONS) |
642 DesktopNotificationService* ProfileIOData::GetNotificationService() const { | 647 DesktopNotificationService* ProfileIOData::GetNotificationService() const { |
643 DCHECK(initialized_); | 648 DCHECK(initialized_); |
644 return notification_service_; | 649 return notification_service_; |
645 } | 650 } |
646 #endif | 651 #endif |
647 | 652 |
653 std::string ProfileIOData::GetMediaDeviceIDSalt() const { | |
654 return media_device_id_salt_->GetSalt(); | |
655 } | |
656 | |
648 void ProfileIOData::InitializeMetricsEnabledStateOnUIThread() { | 657 void ProfileIOData::InitializeMetricsEnabledStateOnUIThread() { |
649 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 658 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
650 #if defined(OS_CHROMEOS) | 659 #if defined(OS_CHROMEOS) |
651 // Just fetch the value from ChromeOS' settings while we're on the UI thread. | 660 // Just fetch the value from ChromeOS' settings while we're on the UI thread. |
652 // TODO(stevet): For now, this value is only set on profile initialization. | 661 // TODO(stevet): For now, this value is only set on profile initialization. |
653 // We will want to do something similar to the PrefMember method below in the | 662 // We will want to do something similar to the PrefMember method below in the |
654 // future to more accurately capture this state. | 663 // future to more accurately capture this state. |
655 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, | 664 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, |
656 &enable_metrics_); | 665 &enable_metrics_); |
657 #elif defined(OS_ANDROID) | 666 #elif defined(OS_ANDROID) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
734 | 743 |
735 bool ProfileIOData::ResourceContext::AllowContentAccess( | 744 bool ProfileIOData::ResourceContext::AllowContentAccess( |
736 const GURL& origin, ContentSettingsType type) { | 745 const GURL& origin, ContentSettingsType type) { |
737 HostContentSettingsMap* content_settings = | 746 HostContentSettingsMap* content_settings = |
738 io_data_->GetHostContentSettingsMap(); | 747 io_data_->GetHostContentSettingsMap(); |
739 ContentSetting setting = content_settings->GetContentSetting( | 748 ContentSetting setting = content_settings->GetContentSetting( |
740 origin, origin, type, NO_RESOURCE_IDENTIFIER); | 749 origin, origin, type, NO_RESOURCE_IDENTIFIER); |
741 return setting == CONTENT_SETTING_ALLOW; | 750 return setting == CONTENT_SETTING_ALLOW; |
742 } | 751 } |
743 | 752 |
753 std::string ProfileIOData::ResourceContext::GetMediaDeviceIDSalt() { | |
754 return io_data_->GetMediaDeviceIDSalt(); | |
755 } | |
756 | |
744 // static | 757 // static |
745 std::string ProfileIOData::GetSSLSessionCacheShard() { | 758 std::string ProfileIOData::GetSSLSessionCacheShard() { |
746 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 759 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
747 // The SSL session cache is partitioned by setting a string. This returns a | 760 // The SSL session cache is partitioned by setting a string. This returns a |
748 // unique string to partition the SSL session cache. Each time we create a | 761 // unique string to partition the SSL session cache. Each time we create a |
749 // new profile, we'll get a fresh SSL session cache which is separate from | 762 // new profile, we'll get a fresh SSL session cache which is separate from |
750 // the other profiles. | 763 // the other profiles. |
751 static unsigned ssl_session_cache_instance = 0; | 764 static unsigned ssl_session_cache_instance = 0; |
752 return base::StringPrintf("profile/%u", ssl_session_cache_instance++); | 765 return base::StringPrintf("profile/%u", ssl_session_cache_instance++); |
753 } | 766 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
938 enable_referrers_.Destroy(); | 951 enable_referrers_.Destroy(); |
939 enable_do_not_track_.Destroy(); | 952 enable_do_not_track_.Destroy(); |
940 force_safesearch_.Destroy(); | 953 force_safesearch_.Destroy(); |
941 #if !defined(OS_CHROMEOS) | 954 #if !defined(OS_CHROMEOS) |
942 enable_metrics_.Destroy(); | 955 enable_metrics_.Destroy(); |
943 #endif | 956 #endif |
944 safe_browsing_enabled_.Destroy(); | 957 safe_browsing_enabled_.Destroy(); |
945 printing_enabled_.Destroy(); | 958 printing_enabled_.Destroy(); |
946 sync_disabled_.Destroy(); | 959 sync_disabled_.Destroy(); |
947 signin_allowed_.Destroy(); | 960 signin_allowed_.Destroy(); |
961 media_device_id_salt_.reset(NULL); | |
Jói
2013/11/04 16:53:29
I'm not sure this is correct (destroying it on the
perkj_chrome
2013/11/04 19:05:38
This is as the same as the other objects and ensur
Jói
2013/11/04 19:24:15
I see now from the ProfileIOData documentation tha
willchan no longer on Chromium
2013/11/04 19:33:00
Sorry, I missed this. Just to doublecheck, what th
| |
948 session_startup_pref_.Destroy(); | 962 session_startup_pref_.Destroy(); |
949 #if defined(ENABLE_CONFIGURATION_POLICY) | 963 #if defined(ENABLE_CONFIGURATION_POLICY) |
950 if (url_blacklist_manager_) | 964 if (url_blacklist_manager_) |
951 url_blacklist_manager_->ShutdownOnUIThread(); | 965 url_blacklist_manager_->ShutdownOnUIThread(); |
952 #endif | 966 #endif |
953 if (chrome_http_user_agent_settings_) | 967 if (chrome_http_user_agent_settings_) |
954 chrome_http_user_agent_settings_->CleanupOnUIThread(); | 968 chrome_http_user_agent_settings_->CleanupOnUIThread(); |
955 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); | 969 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); |
956 if (!posted) | 970 if (!posted) |
957 delete this; | 971 delete this; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
992 void ProfileIOData::SetCookieSettingsForTesting( | 1006 void ProfileIOData::SetCookieSettingsForTesting( |
993 CookieSettings* cookie_settings) { | 1007 CookieSettings* cookie_settings) { |
994 DCHECK(!cookie_settings_.get()); | 1008 DCHECK(!cookie_settings_.get()); |
995 cookie_settings_ = cookie_settings; | 1009 cookie_settings_ = cookie_settings; |
996 } | 1010 } |
997 | 1011 |
998 void ProfileIOData::set_signin_names_for_testing( | 1012 void ProfileIOData::set_signin_names_for_testing( |
999 SigninNamesOnIOThread* signin_names) { | 1013 SigninNamesOnIOThread* signin_names) { |
1000 signin_names_.reset(signin_names); | 1014 signin_names_.reset(signin_names); |
1001 } | 1015 } |
OLD | NEW |