Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: chrome/browser/profiles/profile_impl.cc

Issue 9296041: Create Content API around HostZoomMap. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/profiles/profile_io_data.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/environment.h" 10 #include "base/environment.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 #include "chrome/common/chrome_notification_types.h" 88 #include "chrome/common/chrome_notification_types.h"
89 #include "chrome/common/chrome_paths_internal.h" 89 #include "chrome/common/chrome_paths_internal.h"
90 #include "chrome/common/chrome_switches.h" 90 #include "chrome/common/chrome_switches.h"
91 #include "chrome/common/extensions/extension_permission_set.h" 91 #include "chrome/common/extensions/extension_permission_set.h"
92 #include "chrome/common/json_pref_store.h" 92 #include "chrome/common/json_pref_store.h"
93 #include "chrome/common/pref_names.h" 93 #include "chrome/common/pref_names.h"
94 #include "chrome/common/url_constants.h" 94 #include "chrome/common/url_constants.h"
95 #include "content/browser/appcache/chrome_appcache_service.h" 95 #include "content/browser/appcache/chrome_appcache_service.h"
96 #include "content/browser/chrome_blob_storage_context.h" 96 #include "content/browser/chrome_blob_storage_context.h"
97 #include "content/browser/file_system/browser_file_system_helper.h" 97 #include "content/browser/file_system/browser_file_system_helper.h"
98 #include "content/browser/host_zoom_map.h"
99 #include "content/browser/in_process_webkit/webkit_context.h" 98 #include "content/browser/in_process_webkit/webkit_context.h"
100 #include "content/browser/speech/speech_input_manager.h" 99 #include "content/browser/speech/speech_input_manager.h"
101 #include "content/browser/ssl/ssl_host_state.h" 100 #include "content/browser/ssl/ssl_host_state.h"
102 #include "content/public/browser/browser_thread.h" 101 #include "content/public/browser/browser_thread.h"
102 #include "content/public/browser/host_zoom_map.h"
103 #include "content/public/browser/notification_service.h" 103 #include "content/public/browser/notification_service.h"
104 #include "content/public/browser/user_metrics.h" 104 #include "content/public/browser/user_metrics.h"
105 #include "grit/locale_settings.h" 105 #include "grit/locale_settings.h"
106 #include "net/base/transport_security_state.h" 106 #include "net/base/transport_security_state.h"
107 #include "net/http/http_server_properties.h" 107 #include "net/http/http_server_properties.h"
108 #include "webkit/database/database_tracker.h" 108 #include "webkit/database/database_tracker.h"
109 #include "webkit/quota/quota_manager.h" 109 #include "webkit/quota/quota_manager.h"
110 110
111 #if defined(OS_WIN) 111 #if defined(OS_WIN)
112 #include "chrome/browser/instant/promo_counter.h" 112 #include "chrome/browser/instant/promo_counter.h"
(...skipping 18 matching lines...) Expand all
131 #include "chrome/browser/chromeos/locale_change_guard.h" 131 #include "chrome/browser/chromeos/locale_change_guard.h"
132 #include "chrome/browser/chromeos/login/user_manager.h" 132 #include "chrome/browser/chromeos/login/user_manager.h"
133 #include "chrome/browser/chromeos/preferences.h" 133 #include "chrome/browser/chromeos/preferences.h"
134 #include "chrome/browser/chromeos/proxy_config_service_impl.h" 134 #include "chrome/browser/chromeos/proxy_config_service_impl.h"
135 #endif 135 #endif
136 136
137 using base::Time; 137 using base::Time;
138 using base::TimeDelta; 138 using base::TimeDelta;
139 using content::BrowserThread; 139 using content::BrowserThread;
140 using content::DownloadManager; 140 using content::DownloadManager;
141 using content::HostZoomMap;
141 using content::UserMetricsAction; 142 using content::UserMetricsAction;
142 143
143 namespace { 144 namespace {
144 145
145 // Constrict us to a very specific platform and architecture to make sure 146 // Constrict us to a very specific platform and architecture to make sure
146 // ifdefs don't cause problems with the check. 147 // ifdefs don't cause problems with the check.
147 #if defined(OS_LINUX) && defined(TOOLKIT_GTK) && defined(ARCH_CPU_X86_64) 148 #if defined(OS_LINUX) && defined(TOOLKIT_GTK) && defined(ARCH_CPU_X86_64)
148 // Make sure that the ProfileImpl doesn't grow. We're currently trying to drive 149 // Make sure that the ProfileImpl doesn't grow. We're currently trying to drive
149 // the number of services that are included in ProfileImpl (instead of using 150 // the number of services that are included in ProfileImpl (instead of using
150 // ProfileKeyedServiceFactory) to zero. 151 // ProfileKeyedServiceFactory) to zero.
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 HostContentSettingsMap* ProfileImpl::GetHostContentSettingsMap() { 889 HostContentSettingsMap* ProfileImpl::GetHostContentSettingsMap() {
889 if (!host_content_settings_map_.get()) { 890 if (!host_content_settings_map_.get()) {
890 host_content_settings_map_ = new HostContentSettingsMap( 891 host_content_settings_map_ = new HostContentSettingsMap(
891 GetPrefs(), GetExtensionService(), false); 892 GetPrefs(), GetExtensionService(), false);
892 } 893 }
893 return host_content_settings_map_.get(); 894 return host_content_settings_map_.get();
894 } 895 }
895 896
896 HostZoomMap* ProfileImpl::GetHostZoomMap() { 897 HostZoomMap* ProfileImpl::GetHostZoomMap() {
897 if (!host_zoom_map_) { 898 if (!host_zoom_map_) {
898 host_zoom_map_ = new HostZoomMap(); 899 host_zoom_map_ = HostZoomMap::Create();
899 host_zoom_map_->set_default_zoom_level( 900 host_zoom_map_->SetDefaultZoomLevel(
900 GetPrefs()->GetDouble(prefs::kDefaultZoomLevel)); 901 GetPrefs()->GetDouble(prefs::kDefaultZoomLevel));
901 902
902 const DictionaryValue* host_zoom_dictionary = 903 const DictionaryValue* host_zoom_dictionary =
903 prefs_->GetDictionary(prefs::kPerHostZoomLevels); 904 prefs_->GetDictionary(prefs::kPerHostZoomLevels);
904 // Careful: The returned value could be NULL if the pref has never been set. 905 // Careful: The returned value could be NULL if the pref has never been set.
905 if (host_zoom_dictionary != NULL) { 906 if (host_zoom_dictionary != NULL) {
906 for (DictionaryValue::key_iterator i(host_zoom_dictionary->begin_keys()); 907 for (DictionaryValue::key_iterator i(host_zoom_dictionary->begin_keys());
907 i != host_zoom_dictionary->end_keys(); ++i) { 908 i != host_zoom_dictionary->end_keys(); ++i) {
908 const std::string& host(*i); 909 const std::string& host(*i);
909 double zoom_level = 0; 910 double zoom_level = 0;
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 db_tracker_->SetClearLocalStateOnExit( 1295 db_tracker_->SetClearLocalStateOnExit(
1295 clear_local_state_on_exit_); 1296 clear_local_state_on_exit_);
1296 } 1297 }
1297 } else if (*pref_name_in == prefs::kGoogleServicesUsername) { 1298 } else if (*pref_name_in == prefs::kGoogleServicesUsername) {
1298 UpdateProfileUserNameCache(); 1299 UpdateProfileUserNameCache();
1299 } else if (*pref_name_in == prefs::kProfileAvatarIndex) { 1300 } else if (*pref_name_in == prefs::kProfileAvatarIndex) {
1300 UpdateProfileAvatarCache(); 1301 UpdateProfileAvatarCache();
1301 } else if (*pref_name_in == prefs::kProfileName) { 1302 } else if (*pref_name_in == prefs::kProfileName) {
1302 UpdateProfileNameCache(); 1303 UpdateProfileNameCache();
1303 } else if (*pref_name_in == prefs::kDefaultZoomLevel) { 1304 } else if (*pref_name_in == prefs::kDefaultZoomLevel) {
1304 GetHostZoomMap()->set_default_zoom_level( 1305 GetHostZoomMap()->SetDefaultZoomLevel(
1305 prefs->GetDouble(prefs::kDefaultZoomLevel)); 1306 prefs->GetDouble(prefs::kDefaultZoomLevel));
1306 } 1307 }
1307 break; 1308 break;
1308 } 1309 }
1309 case chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED: 1310 case chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED:
1310 GetProfileSyncService(); // Causes lazy-load if sync is enabled. 1311 GetProfileSyncService(); // Causes lazy-load if sync is enabled.
1311 registrar_.Remove(this, chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED, 1312 registrar_.Remove(this, chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED,
1312 content::Source<Profile>(this)); 1313 content::Source<Profile>(this));
1313 break; 1314 break;
1314 case content::NOTIFICATION_ZOOM_LEVEL_CHANGED: { 1315 case content::NOTIFICATION_ZOOM_LEVEL_CHANGED: {
1315 const std::string& host = 1316 const std::string& host =
1316 *(content::Details<const std::string>(details).ptr()); 1317 *(content::Details<const std::string>(details).ptr());
1317 if (!host.empty()) { 1318 if (!host.empty()) {
1318 double level = host_zoom_map_->GetZoomLevel(host); 1319 double level = host_zoom_map_->GetZoomLevel(host);
1319 DictionaryPrefUpdate update(prefs_.get(), prefs::kPerHostZoomLevels); 1320 DictionaryPrefUpdate update(prefs_.get(), prefs::kPerHostZoomLevels);
1320 DictionaryValue* host_zoom_dictionary = update.Get(); 1321 DictionaryValue* host_zoom_dictionary = update.Get();
1321 if (level == host_zoom_map_->default_zoom_level()) { 1322 if (level == host_zoom_map_->GetDefaultZoomLevel()) {
1322 host_zoom_dictionary->RemoveWithoutPathExpansion(host, NULL); 1323 host_zoom_dictionary->RemoveWithoutPathExpansion(host, NULL);
1323 } else { 1324 } else {
1324 host_zoom_dictionary->SetWithoutPathExpansion( 1325 host_zoom_dictionary->SetWithoutPathExpansion(
1325 host, Value::CreateDoubleValue(level)); 1326 host, Value::CreateDoubleValue(level));
1326 } 1327 }
1327 } 1328 }
1328 break; 1329 break;
1329 } 1330 }
1330 default: 1331 default:
1331 NOTREACHED(); 1332 NOTREACHED();
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 FilePath* cache_path, 1590 FilePath* cache_path,
1590 int* max_size) { 1591 int* max_size) {
1591 DCHECK(cache_path); 1592 DCHECK(cache_path);
1592 DCHECK(max_size); 1593 DCHECK(max_size);
1593 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); 1594 FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir));
1594 if (!path.empty()) 1595 if (!path.empty())
1595 *cache_path = path; 1596 *cache_path = path;
1596 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : 1597 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) :
1597 prefs_->GetInteger(prefs::kDiskCacheSize); 1598 prefs_->GetInteger(prefs::kDiskCacheSize);
1598 } 1599 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/profiles/profile_io_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698