Chromium Code Reviews| 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.h" | 5 #include "chrome/browser/profiles/profile.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/browser/first_run/first_run.h" | 12 #include "chrome/browser/first_run/first_run.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/browser/sync/profile_sync_service.h" | 14 #include "chrome/browser/sync/profile_sync_service.h" |
| 15 #include "chrome/browser/sync/profile_sync_service_factory.h" | 15 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "components/data_reduction_proxy/browser/data_reduction_proxy_prefs.h" | 17 #include "components/data_reduction_proxy/browser/data_reduction_proxy_prefs.h" |
| 18 #include "components/pref_registry/pref_registry_syncable.h" | 18 #include "components/pref_registry/pref_registry_syncable.h" |
| 19 #include "components/sync_driver/sync_prefs.h" | 19 #include "components/sync_driver/sync_prefs.h" |
| 20 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
| 21 #include "content/public/browser/notification_source.h" | 21 #include "content/public/browser/notification_source.h" |
| 22 #include "content/public/browser/storage_partition.h" | |
| 22 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 23 #include "content/public/browser/web_ui.h" | 24 #include "content/public/browser/web_ui.h" |
| 24 | 25 |
| 25 #if defined(OS_CHROMEOS) | 26 #if defined(OS_CHROMEOS) |
| 26 #include "base/command_line.h" | 27 #include "base/command_line.h" |
| 27 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 28 #include "chromeos/chromeos_switches.h" | 29 #include "chromeos/chromeos_switches.h" |
| 29 #endif | 30 #endif |
| 30 | 31 |
| 31 #if defined(OS_ANDROID) && defined(FULL_SAFE_BROWSING) | 32 #if defined(OS_ANDROID) && defined(FULL_SAFE_BROWSING) |
| 32 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 33 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 33 #endif | 34 #endif |
| 34 | 35 |
| 35 #if defined(ENABLE_EXTENSIONS) | 36 #if defined(ENABLE_EXTENSIONS) |
| 36 #include "extensions/browser/pref_names.h" | 37 #include "extensions/browser/pref_names.h" |
| 37 #endif | 38 #endif |
| 38 | 39 |
| 40 using content::HostZoomMap; | |
| 41 | |
| 39 Profile::Profile() | 42 Profile::Profile() |
| 40 : restored_last_session_(false), | 43 : restored_last_session_(false), |
| 41 sent_destroyed_notification_(false), | 44 sent_destroyed_notification_(false), |
| 42 accessibility_pause_level_(0) { | 45 accessibility_pause_level_(0) { |
| 43 } | 46 } |
| 44 | 47 |
| 45 Profile::~Profile() { | 48 Profile::~Profile() { |
| 46 } | 49 } |
| 47 | 50 |
| 48 // static | 51 // static |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 #if defined(ENABLE_EXTENSIONS) | 140 #if defined(ENABLE_EXTENSIONS) |
| 138 registry->RegisterBooleanPref( | 141 registry->RegisterBooleanPref( |
| 139 extensions::pref_names::kAlertsInitialized, | 142 extensions::pref_names::kAlertsInitialized, |
| 140 false, | 143 false, |
| 141 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 144 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 142 #endif | 145 #endif |
| 143 registry->RegisterStringPref( | 146 registry->RegisterStringPref( |
| 144 prefs::kSelectFileLastDirectory, | 147 prefs::kSelectFileLastDirectory, |
| 145 std::string(), | 148 std::string(), |
| 146 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 149 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 147 registry->RegisterDoublePref( | |
| 148 prefs::kDefaultZoomLevel, | |
| 149 0.0, | |
| 150 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
| 151 registry->RegisterDictionaryPref( | 150 registry->RegisterDictionaryPref( |
| 152 prefs::kPerHostZoomLevels, | 151 prefs::kPerHostZoomLevels, |
| 153 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 152 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 154 registry->RegisterStringPref( | 153 registry->RegisterStringPref( |
| 155 prefs::kDefaultApps, | 154 prefs::kDefaultApps, |
| 156 "install", | 155 "install", |
| 157 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 156 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 158 registry->RegisterBooleanPref( | 157 registry->RegisterBooleanPref( |
| 159 prefs::kSpeechRecognitionFilterProfanities, | 158 prefs::kSpeechRecognitionFilterProfanities, |
| 160 true, | 159 true, |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 content::NotificationService::NoDetails()); | 250 content::NotificationService::NoDetails()); |
| 252 } | 251 } |
| 253 } | 252 } |
| 254 | 253 |
| 255 bool ProfileCompare::operator()(Profile* a, Profile* b) const { | 254 bool ProfileCompare::operator()(Profile* a, Profile* b) const { |
| 256 DCHECK(a && b); | 255 DCHECK(a && b); |
| 257 if (a->IsSameProfile(b)) | 256 if (a->IsSameProfile(b)) |
| 258 return false; | 257 return false; |
| 259 return a->GetOriginalProfile() < b->GetOriginalProfile(); | 258 return a->GetOriginalProfile() < b->GetOriginalProfile(); |
| 260 } | 259 } |
| 260 | |
| 261 double Profile::GetDefaultZoomLevel() { | |
| 262 return GetDefaultStoragePartition(this) | |
| 263 ->GetHostZoomMap() | |
| 264 ->GetDefaultZoomLevel(); | |
| 265 } | |
| 266 | |
| 267 PrefService* Profile::GetZoomLevelPrefs() { | |
| 268 return GetDefaultStoragePartition(this)->GetZoomLevelPrefs(); | |
| 269 } | |
| 270 | |
| 271 void Profile::TrackZoomLevelsFromParent(Profile* parent) { | |
| 272 // This function only makes sense in a derived class that implements | |
| 273 // HostZoomMaps. | |
| 274 DCHECK(GetProfileType() == INCOGNITO_PROFILE && | |
| 275 parent->GetProfileType() == REGULAR_PROFILE); | |
| 276 | |
| 277 // Here we only want to use zoom levels stored in the main-context's default | |
| 278 // storage partition. We're not interested in zoom levels in special | |
| 279 // partitions, e.g. those used by WebViewGuests. | |
| 280 HostZoomMap* host_zoom_map = HostZoomMap::GetDefaultForBrowserContext(this); | |
| 281 HostZoomMap* parent_host_zoom_map = | |
| 282 HostZoomMap::GetDefaultForBrowserContext(parent); | |
| 283 host_zoom_map->CopyFrom(parent_host_zoom_map); | |
| 284 // Observe parenti profile's HostZoomMap changes so they can also be applied | |
|
awong
2014/08/20 19:56:58
parenti -> parent
wjmaclean
2014/08/20 20:15:45
Done.
| |
| 285 // to this profile's HostZoomMap. | |
| 286 track_zoom_subscription_ = parent_host_zoom_map->AddZoomLevelChangedCallback( | |
| 287 base::Bind(&Profile::TrackZoomLevelChanged, base::Unretained(this))); | |
|
awong
2014/08/20 19:56:58
Should add a note in TrackZoomLevelChanged() that
wjmaclean
2014/08/20 20:15:45
I will add this in the next CL.
| |
| 288 } | |
| 289 | |
| 290 void Profile::TrackZoomLevelChanged( | |
| 291 const HostZoomMap::ZoomLevelChange& change) { | |
| 292 HostZoomMap* host_zoom_map = HostZoomMap::GetDefaultForBrowserContext(this); | |
| 293 switch (change.mode) { | |
| 294 case HostZoomMap::ZOOM_CHANGED_DEFAULT_ZOOM_LEVEL: | |
| 295 case HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM: | |
| 296 return; | |
| 297 case HostZoomMap::ZOOM_CHANGED_FOR_HOST: | |
| 298 host_zoom_map->SetZoomLevelForHost(change.host, change.zoom_level); | |
| 299 return; | |
| 300 case HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: | |
| 301 host_zoom_map->SetZoomLevelForHostAndScheme(change.scheme, | |
| 302 change.host, | |
| 303 change.zoom_level); | |
| 304 return; | |
| 305 } | |
| 306 } | |
| OLD | NEW |