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 16 matching lines...) Expand all Loading... |
27 #include "chrome/browser/content_settings/cookie_settings.h" | 27 #include "chrome/browser/content_settings/cookie_settings.h" |
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_protocols.h" | 33 #include "chrome/browser/extensions/extension_protocols.h" |
34 #include "chrome/browser/extensions/extension_resource_protocols.h" | 34 #include "chrome/browser/extensions/extension_resource_protocols.h" |
35 #include "chrome/browser/extensions/extension_system.h" | 35 #include "chrome/browser/extensions/extension_system.h" |
36 #include "chrome/browser/io_thread.h" | 36 #include "chrome/browser/io_thread.h" |
| 37 #include "chrome/browser/media/media_device_id_salt.h" |
37 #include "chrome/browser/net/about_protocol_handler.h" | 38 #include "chrome/browser/net/about_protocol_handler.h" |
38 #include "chrome/browser/net/chrome_cookie_notification_details.h" | 39 #include "chrome/browser/net/chrome_cookie_notification_details.h" |
39 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" | 40 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" |
40 #include "chrome/browser/net/chrome_http_user_agent_settings.h" | 41 #include "chrome/browser/net/chrome_http_user_agent_settings.h" |
41 #include "chrome/browser/net/chrome_net_log.h" | 42 #include "chrome/browser/net/chrome_net_log.h" |
42 #include "chrome/browser/net/chrome_network_delegate.h" | 43 #include "chrome/browser/net/chrome_network_delegate.h" |
43 #include "chrome/browser/net/evicted_domain_cookie_counter.h" | 44 #include "chrome/browser/net/evicted_domain_cookie_counter.h" |
44 #include "chrome/browser/net/load_time_stats.h" | 45 #include "chrome/browser/net/load_time_stats.h" |
45 #include "chrome/browser/net/proxy_service_factory.h" | 46 #include "chrome/browser/net/proxy_service_factory.h" |
46 #include "chrome/browser/net/resource_prefetch_predictor_observer.h" | 47 #include "chrome/browser/net/resource_prefetch_predictor_observer.h" |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 &enable_do_not_track_, | 287 &enable_do_not_track_, |
287 &force_safesearch_, | 288 &force_safesearch_, |
288 pref_service); | 289 pref_service); |
289 | 290 |
290 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy = | 291 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy = |
291 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 292 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
292 #if defined(ENABLE_PRINTING) | 293 #if defined(ENABLE_PRINTING) |
293 printing_enabled_.Init(prefs::kPrintingEnabled, pref_service); | 294 printing_enabled_.Init(prefs::kPrintingEnabled, pref_service); |
294 printing_enabled_.MoveToThread(io_message_loop_proxy); | 295 printing_enabled_.MoveToThread(io_message_loop_proxy); |
295 #endif | 296 #endif |
| 297 |
296 chrome_http_user_agent_settings_.reset( | 298 chrome_http_user_agent_settings_.reset( |
297 new ChromeHttpUserAgentSettings(pref_service)); | 299 new ChromeHttpUserAgentSettings(pref_service)); |
298 | 300 |
299 // These members are used only for one click sign in, which is not enabled | 301 // These members are used only for one click sign in, which is not enabled |
300 // in incognito mode. So no need to initialize them. | 302 // in incognito mode. So no need to initialize them. |
301 if (!is_incognito()) { | 303 if (!is_incognito()) { |
302 signin_names_.reset(new SigninNamesOnIOThread()); | 304 signin_names_.reset(new SigninNamesOnIOThread()); |
303 | 305 |
304 google_services_username_.Init( | 306 google_services_username_.Init( |
305 prefs::kGoogleServicesUsername, pref_service); | 307 prefs::kGoogleServicesUsername, pref_service); |
(...skipping 11 matching lines...) Expand all Loading... |
317 prefs::kReverseAutologinRejectedEmailList, pref_service); | 319 prefs::kReverseAutologinRejectedEmailList, pref_service); |
318 one_click_signin_rejected_email_list_.MoveToThread(io_message_loop_proxy); | 320 one_click_signin_rejected_email_list_.MoveToThread(io_message_loop_proxy); |
319 | 321 |
320 sync_disabled_.Init(prefs::kSyncManaged, pref_service); | 322 sync_disabled_.Init(prefs::kSyncManaged, pref_service); |
321 sync_disabled_.MoveToThread(io_message_loop_proxy); | 323 sync_disabled_.MoveToThread(io_message_loop_proxy); |
322 | 324 |
323 signin_allowed_.Init(prefs::kSigninAllowed, pref_service); | 325 signin_allowed_.Init(prefs::kSigninAllowed, pref_service); |
324 signin_allowed_.MoveToThread(io_message_loop_proxy); | 326 signin_allowed_.MoveToThread(io_message_loop_proxy); |
325 } | 327 } |
326 | 328 |
| 329 media_device_id_salt_.reset(new MediaDeviceIDSalt(pref_service, |
| 330 is_incognito())); |
| 331 |
327 #if defined(OS_CHROMEOS) | 332 #if defined(OS_CHROMEOS) |
328 cert_verifier_ = policy::PolicyCertServiceFactory::CreateForProfile(profile); | 333 cert_verifier_ = policy::PolicyCertServiceFactory::CreateForProfile(profile); |
329 #endif | 334 #endif |
330 // The URLBlacklistManager has to be created on the UI thread to register | 335 // The URLBlacklistManager has to be created on the UI thread to register |
331 // observers of |pref_service|, and it also has to clean up on | 336 // observers of |pref_service|, and it also has to clean up on |
332 // ShutdownOnUIThread to release these observers on the right thread. | 337 // ShutdownOnUIThread to release these observers on the right thread. |
333 // Don't pass it in |profile_params_| to make sure it is correctly cleaned up, | 338 // Don't pass it in |profile_params_| to make sure it is correctly cleaned up, |
334 // in particular when this ProfileIOData isn't |initialized_| during deletion. | 339 // in particular when this ProfileIOData isn't |initialized_| during deletion. |
335 #if defined(ENABLE_CONFIGURATION_POLICY) | 340 #if defined(ENABLE_CONFIGURATION_POLICY) |
336 url_blacklist_manager_.reset(new policy::URLBlacklistManager(pref_service)); | 341 url_blacklist_manager_.reset(new policy::URLBlacklistManager(pref_service)); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 // Allow either Init() or SetCookieSettingsForTesting() to initialize. | 611 // Allow either Init() or SetCookieSettingsForTesting() to initialize. |
607 DCHECK(initialized_ || cookie_settings_.get()); | 612 DCHECK(initialized_ || cookie_settings_.get()); |
608 return cookie_settings_.get(); | 613 return cookie_settings_.get(); |
609 } | 614 } |
610 | 615 |
611 HostContentSettingsMap* ProfileIOData::GetHostContentSettingsMap() const { | 616 HostContentSettingsMap* ProfileIOData::GetHostContentSettingsMap() const { |
612 DCHECK(initialized_); | 617 DCHECK(initialized_); |
613 return host_content_settings_map_.get(); | 618 return host_content_settings_map_.get(); |
614 } | 619 } |
615 | 620 |
| 621 std::string ProfileIOData::GetMediaDeviceIDSalt() const { |
| 622 return media_device_id_salt_->GetSalt(); |
| 623 } |
| 624 |
616 void ProfileIOData::InitializeMetricsEnabledStateOnUIThread() { | 625 void ProfileIOData::InitializeMetricsEnabledStateOnUIThread() { |
617 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 626 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
618 #if defined(OS_CHROMEOS) | 627 #if defined(OS_CHROMEOS) |
619 // Just fetch the value from ChromeOS' settings while we're on the UI thread. | 628 // Just fetch the value from ChromeOS' settings while we're on the UI thread. |
620 // TODO(stevet): For now, this value is only set on profile initialization. | 629 // TODO(stevet): For now, this value is only set on profile initialization. |
621 // We will want to do something similar to the PrefMember method below in the | 630 // We will want to do something similar to the PrefMember method below in the |
622 // future to more accurately capture this state. | 631 // future to more accurately capture this state. |
623 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, | 632 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, |
624 &enable_metrics_); | 633 &enable_metrics_); |
625 #elif defined(OS_ANDROID) | 634 #elif defined(OS_ANDROID) |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 | 717 |
709 bool ProfileIOData::ResourceContext::AllowContentAccess( | 718 bool ProfileIOData::ResourceContext::AllowContentAccess( |
710 const GURL& origin, ContentSettingsType type) { | 719 const GURL& origin, ContentSettingsType type) { |
711 HostContentSettingsMap* content_settings = | 720 HostContentSettingsMap* content_settings = |
712 io_data_->GetHostContentSettingsMap(); | 721 io_data_->GetHostContentSettingsMap(); |
713 ContentSetting setting = content_settings->GetContentSetting( | 722 ContentSetting setting = content_settings->GetContentSetting( |
714 origin, origin, type, NO_RESOURCE_IDENTIFIER); | 723 origin, origin, type, NO_RESOURCE_IDENTIFIER); |
715 return setting == CONTENT_SETTING_ALLOW; | 724 return setting == CONTENT_SETTING_ALLOW; |
716 } | 725 } |
717 | 726 |
| 727 std::string ProfileIOData::ResourceContext::GetMediaDeviceIDSalt() { |
| 728 return io_data_->GetMediaDeviceIDSalt(); |
| 729 } |
| 730 |
718 // static | 731 // static |
719 std::string ProfileIOData::GetSSLSessionCacheShard() { | 732 std::string ProfileIOData::GetSSLSessionCacheShard() { |
720 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 733 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
721 // The SSL session cache is partitioned by setting a string. This returns a | 734 // The SSL session cache is partitioned by setting a string. This returns a |
722 // unique string to partition the SSL session cache. Each time we create a | 735 // unique string to partition the SSL session cache. Each time we create a |
723 // new profile, we'll get a fresh SSL session cache which is separate from | 736 // new profile, we'll get a fresh SSL session cache which is separate from |
724 // the other profiles. | 737 // the other profiles. |
725 static unsigned ssl_session_cache_instance = 0; | 738 static unsigned ssl_session_cache_instance = 0; |
726 return base::StringPrintf("profile/%u", ssl_session_cache_instance++); | 739 return base::StringPrintf("profile/%u", ssl_session_cache_instance++); |
727 } | 740 } |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 enable_referrers_.Destroy(); | 929 enable_referrers_.Destroy(); |
917 enable_do_not_track_.Destroy(); | 930 enable_do_not_track_.Destroy(); |
918 force_safesearch_.Destroy(); | 931 force_safesearch_.Destroy(); |
919 #if !defined(OS_CHROMEOS) | 932 #if !defined(OS_CHROMEOS) |
920 enable_metrics_.Destroy(); | 933 enable_metrics_.Destroy(); |
921 #endif | 934 #endif |
922 safe_browsing_enabled_.Destroy(); | 935 safe_browsing_enabled_.Destroy(); |
923 printing_enabled_.Destroy(); | 936 printing_enabled_.Destroy(); |
924 sync_disabled_.Destroy(); | 937 sync_disabled_.Destroy(); |
925 signin_allowed_.Destroy(); | 938 signin_allowed_.Destroy(); |
| 939 if (media_device_id_salt_) |
| 940 media_device_id_salt_->ShutdownOnUIThread(); |
926 session_startup_pref_.Destroy(); | 941 session_startup_pref_.Destroy(); |
927 #if defined(ENABLE_CONFIGURATION_POLICY) | 942 #if defined(ENABLE_CONFIGURATION_POLICY) |
928 if (url_blacklist_manager_) | 943 if (url_blacklist_manager_) |
929 url_blacklist_manager_->ShutdownOnUIThread(); | 944 url_blacklist_manager_->ShutdownOnUIThread(); |
930 #endif | 945 #endif |
931 if (chrome_http_user_agent_settings_) | 946 if (chrome_http_user_agent_settings_) |
932 chrome_http_user_agent_settings_->CleanupOnUIThread(); | 947 chrome_http_user_agent_settings_->CleanupOnUIThread(); |
933 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); | 948 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); |
934 if (!posted) | 949 if (!posted) |
935 delete this; | 950 delete this; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 void ProfileIOData::SetCookieSettingsForTesting( | 986 void ProfileIOData::SetCookieSettingsForTesting( |
972 CookieSettings* cookie_settings) { | 987 CookieSettings* cookie_settings) { |
973 DCHECK(!cookie_settings_.get()); | 988 DCHECK(!cookie_settings_.get()); |
974 cookie_settings_ = cookie_settings; | 989 cookie_settings_ = cookie_settings; |
975 } | 990 } |
976 | 991 |
977 void ProfileIOData::set_signin_names_for_testing( | 992 void ProfileIOData::set_signin_names_for_testing( |
978 SigninNamesOnIOThread* signin_names) { | 993 SigninNamesOnIOThread* signin_names) { |
979 signin_names_.reset(signin_names); | 994 signin_names_.reset(signin_names); |
980 } | 995 } |
OLD | NEW |