| 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 enable_referrers_.Destroy(); | 947 enable_referrers_.Destroy(); |
| 939 enable_do_not_track_.Destroy(); | 948 enable_do_not_track_.Destroy(); |
| 940 force_safesearch_.Destroy(); | 949 force_safesearch_.Destroy(); |
| 941 #if !defined(OS_CHROMEOS) | 950 #if !defined(OS_CHROMEOS) |
| 942 enable_metrics_.Destroy(); | 951 enable_metrics_.Destroy(); |
| 943 #endif | 952 #endif |
| 944 safe_browsing_enabled_.Destroy(); | 953 safe_browsing_enabled_.Destroy(); |
| 945 printing_enabled_.Destroy(); | 954 printing_enabled_.Destroy(); |
| 946 sync_disabled_.Destroy(); | 955 sync_disabled_.Destroy(); |
| 947 signin_allowed_.Destroy(); | 956 signin_allowed_.Destroy(); |
| 957 media_device_id_salt_.reset(NULL); |
| 948 session_startup_pref_.Destroy(); | 958 session_startup_pref_.Destroy(); |
| 949 #if defined(ENABLE_CONFIGURATION_POLICY) | 959 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 950 if (url_blacklist_manager_) | 960 if (url_blacklist_manager_) |
| 951 url_blacklist_manager_->ShutdownOnUIThread(); | 961 url_blacklist_manager_->ShutdownOnUIThread(); |
| 952 #endif | 962 #endif |
| 953 if (chrome_http_user_agent_settings_) | 963 if (chrome_http_user_agent_settings_) |
| 954 chrome_http_user_agent_settings_->CleanupOnUIThread(); | 964 chrome_http_user_agent_settings_->CleanupOnUIThread(); |
| 955 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); | 965 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); |
| 956 if (!posted) | 966 if (!posted) |
| 957 delete this; | 967 delete this; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 void ProfileIOData::SetCookieSettingsForTesting( | 1002 void ProfileIOData::SetCookieSettingsForTesting( |
| 993 CookieSettings* cookie_settings) { | 1003 CookieSettings* cookie_settings) { |
| 994 DCHECK(!cookie_settings_.get()); | 1004 DCHECK(!cookie_settings_.get()); |
| 995 cookie_settings_ = cookie_settings; | 1005 cookie_settings_ = cookie_settings; |
| 996 } | 1006 } |
| 997 | 1007 |
| 998 void ProfileIOData::set_signin_names_for_testing( | 1008 void ProfileIOData::set_signin_names_for_testing( |
| 999 SigninNamesOnIOThread* signin_names) { | 1009 SigninNamesOnIOThread* signin_names) { |
| 1000 signin_names_.reset(signin_names); | 1010 signin_names_.reset(signin_names); |
| 1001 } | 1011 } |
| OLD | NEW |