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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 #include "chrome/browser/profiles/profile_manager.h" | 64 #include "chrome/browser/profiles/profile_manager.h" |
65 #include "chrome/browser/profiles/profile_metrics.h" | 65 #include "chrome/browser/profiles/profile_metrics.h" |
66 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 66 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
67 #include "chrome/browser/services/gcm/gcm_profile_service.h" | 67 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
68 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 68 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
69 #include "chrome/browser/services/gcm/push_messaging_service_impl.h" | 69 #include "chrome/browser/services/gcm/push_messaging_service_impl.h" |
70 #include "chrome/browser/sessions/session_service_factory.h" | 70 #include "chrome/browser/sessions/session_service_factory.h" |
71 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" | 71 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" |
72 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h" | 72 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h" |
73 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 73 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 74 #include "chrome/browser/ui/zoom/zoom_level_prefs_delegate_impl.h" |
74 #include "chrome/common/chrome_constants.h" | 75 #include "chrome/common/chrome_constants.h" |
75 #include "chrome/common/chrome_paths_internal.h" | 76 #include "chrome/common/chrome_paths_internal.h" |
76 #include "chrome/common/chrome_switches.h" | 77 #include "chrome/common/chrome_switches.h" |
77 #include "chrome/common/chrome_version_info.h" | 78 #include "chrome/common/chrome_version_info.h" |
78 #include "chrome/common/pref_names.h" | 79 #include "chrome/common/pref_names.h" |
79 #include "chrome/common/url_constants.h" | 80 #include "chrome/common/url_constants.h" |
80 #include "components/bookmarks/browser/bookmark_model.h" | 81 #include "components/bookmarks/browser/bookmark_model.h" |
81 #include "components/dom_distiller/content/dom_distiller_viewer_source.h" | 82 #include "components/dom_distiller/content/dom_distiller_viewer_source.h" |
82 #include "components/dom_distiller/core/url_constants.h" | 83 #include "components/dom_distiller/core/url_constants.h" |
83 #include "components/domain_reliability/monitor.h" | 84 #include "components/domain_reliability/monitor.h" |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 StartupBrowserCreator::GetSessionStartupPref( | 621 StartupBrowserCreator::GetSessionStartupPref( |
621 *CommandLine::ForCurrentProcess(), this).type; | 622 *CommandLine::ForCurrentProcess(), this).type; |
622 #endif | 623 #endif |
623 content::CookieStoreConfig::SessionCookieMode session_cookie_mode = | 624 content::CookieStoreConfig::SessionCookieMode session_cookie_mode = |
624 content::CookieStoreConfig::PERSISTANT_SESSION_COOKIES; | 625 content::CookieStoreConfig::PERSISTANT_SESSION_COOKIES; |
625 if (GetLastSessionExitType() == Profile::EXIT_CRASHED || | 626 if (GetLastSessionExitType() == Profile::EXIT_CRASHED || |
626 startup_pref_type == SessionStartupPref::LAST) { | 627 startup_pref_type == SessionStartupPref::LAST) { |
627 session_cookie_mode = content::CookieStoreConfig::RESTORED_SESSION_COOKIES; | 628 session_cookie_mode = content::CookieStoreConfig::RESTORED_SESSION_COOKIES; |
628 } | 629 } |
629 | 630 |
630 InitHostZoomMap(); | |
631 | |
632 base::Callback<void(bool)> data_reduction_proxy_unavailable; | 631 base::Callback<void(bool)> data_reduction_proxy_unavailable; |
633 scoped_ptr<data_reduction_proxy::DataReductionProxyParams> | 632 scoped_ptr<data_reduction_proxy::DataReductionProxyParams> |
634 data_reduction_proxy_params; | 633 data_reduction_proxy_params; |
| 634 |
635 #if defined(SPDY_PROXY_AUTH_ORIGIN) | 635 #if defined(SPDY_PROXY_AUTH_ORIGIN) |
636 DataReductionProxyChromeSettings* data_reduction_proxy_chrome_settings = | 636 DataReductionProxyChromeSettings* data_reduction_proxy_chrome_settings = |
637 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(this); | 637 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(this); |
638 data_reduction_proxy_params = | 638 data_reduction_proxy_params = |
639 data_reduction_proxy_chrome_settings->params()->Clone(); | 639 data_reduction_proxy_chrome_settings->params()->Clone(); |
640 data_reduction_proxy_unavailable = | 640 data_reduction_proxy_unavailable = |
641 base::Bind( | 641 base::Bind( |
642 &data_reduction_proxy::DataReductionProxySettings::SetUnreachable, | 642 &data_reduction_proxy::DataReductionProxySettings::SetUnreachable, |
643 base::Unretained(data_reduction_proxy_chrome_settings)); | 643 base::Unretained(data_reduction_proxy_chrome_settings)); |
644 #endif | 644 #endif |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 #if !defined(OS_CHROMEOS) | 717 #if !defined(OS_CHROMEOS) |
718 // Listen for bookmark model load, to bootstrap the sync service. | 718 // Listen for bookmark model load, to bootstrap the sync service. |
719 // On CrOS sync service will be initialized after sign in. | 719 // On CrOS sync service will be initialized after sign in. |
720 BookmarkModel* model = BookmarkModelFactory::GetForProfile(this); | 720 BookmarkModel* model = BookmarkModelFactory::GetForProfile(this); |
721 model->AddObserver(new BookmarkModelLoadedObserver(this)); | 721 model->AddObserver(new BookmarkModelLoadedObserver(this)); |
722 #endif | 722 #endif |
723 | 723 |
724 gcm::PushMessagingServiceImpl::InitializeForProfile(this); | 724 gcm::PushMessagingServiceImpl::InitializeForProfile(this); |
725 } | 725 } |
726 | 726 |
727 void ProfileImpl::InitHostZoomMap() { | |
728 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); | |
729 host_zoom_map->SetDefaultZoomLevel( | |
730 prefs_->GetDouble(prefs::kDefaultZoomLevel)); | |
731 | |
732 const base::DictionaryValue* host_zoom_dictionary = | |
733 prefs_->GetDictionary(prefs::kPerHostZoomLevels); | |
734 // Careful: The returned value could be NULL if the pref has never been set. | |
735 if (host_zoom_dictionary != NULL) { | |
736 std::vector<std::string> keys_to_remove; | |
737 for (base::DictionaryValue::Iterator i(*host_zoom_dictionary); !i.IsAtEnd(); | |
738 i.Advance()) { | |
739 const std::string& host(i.key()); | |
740 double zoom_level = 0; | |
741 | |
742 bool success = i.value().GetAsDouble(&zoom_level); | |
743 DCHECK(success); | |
744 | |
745 // Filter out A) the empty host, B) zoom levels equal to the default; and | |
746 // remember them, so that we can later erase them from Prefs. | |
747 // Values of type A and B could have been stored due to crbug.com/364399. | |
748 // Values of type B could further have been stored before the default zoom | |
749 // level was set to its current value. In either case, SetZoomLevelForHost | |
750 // will ignore type B values, thus, to have consistency with HostZoomMap's | |
751 // internal state, these values must also be removed from Prefs. | |
752 if (host.empty() || | |
753 content::ZoomValuesEqual(zoom_level, | |
754 host_zoom_map->GetDefaultZoomLevel())) { | |
755 keys_to_remove.push_back(host); | |
756 continue; | |
757 } | |
758 | |
759 host_zoom_map->SetZoomLevelForHost(host, zoom_level); | |
760 } | |
761 | |
762 DictionaryPrefUpdate update(prefs_.get(), prefs::kPerHostZoomLevels); | |
763 base::DictionaryValue* host_zoom_dictionary = update.Get(); | |
764 for (std::vector<std::string>::const_iterator it = keys_to_remove.begin(); | |
765 it != keys_to_remove.end(); ++it) { | |
766 host_zoom_dictionary->RemoveWithoutPathExpansion(*it, NULL); | |
767 } | |
768 } | |
769 | |
770 zoom_subscription_ = host_zoom_map->AddZoomLevelChangedCallback( | |
771 base::Bind(&ProfileImpl::OnZoomLevelChanged, base::Unretained(this))); | |
772 } | |
773 | |
774 base::FilePath ProfileImpl::last_selected_directory() { | 727 base::FilePath ProfileImpl::last_selected_directory() { |
775 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); | 728 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); |
776 } | 729 } |
777 | 730 |
778 void ProfileImpl::set_last_selected_directory(const base::FilePath& path) { | 731 void ProfileImpl::set_last_selected_directory(const base::FilePath& path) { |
779 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); | 732 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); |
780 } | 733 } |
781 | 734 |
782 ProfileImpl::~ProfileImpl() { | 735 ProfileImpl::~ProfileImpl() { |
783 MaybeSendDestroyedNotification(); | 736 MaybeSendDestroyedNotification(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 } | 779 } |
827 | 780 |
828 std::string ProfileImpl::GetProfileName() { | 781 std::string ProfileImpl::GetProfileName() { |
829 return GetPrefs()->GetString(prefs::kGoogleServicesUsername); | 782 return GetPrefs()->GetString(prefs::kGoogleServicesUsername); |
830 } | 783 } |
831 | 784 |
832 Profile::ProfileType ProfileImpl::GetProfileType() const { | 785 Profile::ProfileType ProfileImpl::GetProfileType() const { |
833 return REGULAR_PROFILE; | 786 return REGULAR_PROFILE; |
834 } | 787 } |
835 | 788 |
| 789 double ProfileImpl::GetDefaultZoomLevel() const { |
| 790 return pref_change_registrar_.prefs()->GetDouble(prefs::kDefaultZoomLevel); |
| 791 } |
| 792 |
| 793 content::ZoomLevelPrefsDelegate* ProfileImpl::CreateZoomLevelPrefsDelegate() { |
| 794 return new browser::ZoomLevelPrefsDelegateImpl; |
| 795 } |
| 796 |
836 base::FilePath ProfileImpl::GetPath() const { | 797 base::FilePath ProfileImpl::GetPath() const { |
837 return path_; | 798 return path_; |
838 } | 799 } |
839 | 800 |
840 scoped_refptr<base::SequencedTaskRunner> ProfileImpl::GetIOTaskRunner() { | 801 scoped_refptr<base::SequencedTaskRunner> ProfileImpl::GetIOTaskRunner() { |
841 return JsonPrefStore::GetTaskRunnerForFile( | 802 return JsonPrefStore::GetTaskRunnerForFile( |
842 GetPath(), BrowserThread::GetBlockingPool()); | 803 GetPath(), BrowserThread::GetBlockingPool()); |
843 } | 804 } |
844 | 805 |
845 bool ProfileImpl::IsOffTheRecord() const { | 806 bool ProfileImpl::IsOffTheRecord() const { |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 this, GetPath().Append(chrome::kTopSitesFilename)); | 1095 this, GetPath().Append(chrome::kTopSitesFilename)); |
1135 } | 1096 } |
1136 return top_sites_.get(); | 1097 return top_sites_.get(); |
1137 } | 1098 } |
1138 | 1099 |
1139 history::TopSites* ProfileImpl::GetTopSitesWithoutCreating() { | 1100 history::TopSites* ProfileImpl::GetTopSitesWithoutCreating() { |
1140 return top_sites_.get(); | 1101 return top_sites_.get(); |
1141 } | 1102 } |
1142 | 1103 |
1143 void ProfileImpl::OnDefaultZoomLevelChanged() { | 1104 void ProfileImpl::OnDefaultZoomLevelChanged() { |
1144 HostZoomMap::GetForBrowserContext(this)->SetDefaultZoomLevel( | 1105 BrowserContext::SetDefaultZoomLevel(this, GetDefaultZoomLevel()); |
1145 pref_change_registrar_.prefs()->GetDouble(prefs::kDefaultZoomLevel)); | |
1146 } | 1106 } |
1147 | 1107 |
1148 void ProfileImpl::OnZoomLevelChanged( | 1108 void ProfileImpl::OnZoomLevelChanged( |
1149 const HostZoomMap::ZoomLevelChange& change) { | 1109 const HostZoomMap::ZoomLevelChange& change) { |
1150 | 1110 |
1151 if (change.mode != HostZoomMap::ZOOM_CHANGED_FOR_HOST) | 1111 if (change.mode != HostZoomMap::ZOOM_CHANGED_FOR_HOST) |
1152 return; | 1112 return; |
1153 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); | |
1154 double level = change.zoom_level; | 1113 double level = change.zoom_level; |
1155 DictionaryPrefUpdate update(prefs_.get(), prefs::kPerHostZoomLevels); | 1114 DictionaryPrefUpdate update(prefs_.get(), prefs::kPerHostZoomLevels); |
1156 base::DictionaryValue* host_zoom_dictionary = update.Get(); | 1115 base::DictionaryValue* host_zoom_dictionary = update.Get(); |
1157 if (content::ZoomValuesEqual(level, host_zoom_map->GetDefaultZoomLevel())) | 1116 if (content::ZoomValuesEqual(level, GetDefaultZoomLevel())) |
1158 host_zoom_dictionary->RemoveWithoutPathExpansion(change.host, NULL); | 1117 host_zoom_dictionary->RemoveWithoutPathExpansion(change.host, NULL); |
1159 else | 1118 else |
1160 host_zoom_dictionary->SetDoubleWithoutPathExpansion(change.host, level); | 1119 host_zoom_dictionary->SetDoubleWithoutPathExpansion(change.host, level); |
1161 } | 1120 } |
1162 | 1121 |
1163 #if defined(ENABLE_SESSION_SERVICE) | 1122 #if defined(ENABLE_SESSION_SERVICE) |
1164 void ProfileImpl::StopCreateSessionServiceTimer() { | 1123 void ProfileImpl::StopCreateSessionServiceTimer() { |
1165 create_session_service_timer_.Stop(); | 1124 create_session_service_timer_.Stop(); |
1166 } | 1125 } |
1167 | 1126 |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 ProfileImpl::CreateDomainReliabilityMonitor() { | 1360 ProfileImpl::CreateDomainReliabilityMonitor() { |
1402 domain_reliability::DomainReliabilityService* service = | 1361 domain_reliability::DomainReliabilityService* service = |
1403 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> | 1362 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> |
1404 GetForBrowserContext(this); | 1363 GetForBrowserContext(this); |
1405 if (!service) | 1364 if (!service) |
1406 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); | 1365 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); |
1407 | 1366 |
1408 return service->CreateMonitor( | 1367 return service->CreateMonitor( |
1409 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 1368 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
1410 } | 1369 } |
OLD | NEW |