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/core/browser/data_reduction_proxy_pref
s.h" | 17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 content::NotificationService::NoDetails()); | 263 content::NotificationService::NoDetails()); |
261 } | 264 } |
262 } | 265 } |
263 | 266 |
264 bool ProfileCompare::operator()(Profile* a, Profile* b) const { | 267 bool ProfileCompare::operator()(Profile* a, Profile* b) const { |
265 DCHECK(a && b); | 268 DCHECK(a && b); |
266 if (a->IsSameProfile(b)) | 269 if (a->IsSameProfile(b)) |
267 return false; | 270 return false; |
268 return a->GetOriginalProfile() < b->GetOriginalProfile(); | 271 return a->GetOriginalProfile() < b->GetOriginalProfile(); |
269 } | 272 } |
| 273 |
| 274 double Profile::GetDefaultZoomLevel() { |
| 275 return GetDefaultStoragePartition(this) |
| 276 ->GetHostZoomMap() |
| 277 ->GetDefaultZoomLevel(); |
| 278 } |
| 279 |
| 280 void Profile::TrackZoomLevelsFromParent(Profile* parent) { |
| 281 // This function only makes sense in a derived class that implements |
| 282 // HostZoomMaps. |
| 283 DCHECK(parent->GetProfileType() != INCOGNITO_PROFILE); |
| 284 |
| 285 // Here we only want to use zoom levels stored in the main-context's default |
| 286 // storage partition. We're not interested in zoom levels in special |
| 287 // partitions, e.g. those used by WebViewGuests. |
| 288 HostZoomMap* host_zoom_map = HostZoomMap::GetDefaultForBrowserContext(this); |
| 289 HostZoomMap* parent_host_zoom_map = |
| 290 HostZoomMap::GetDefaultForBrowserContext(parent); |
| 291 host_zoom_map->CopyFrom(parent_host_zoom_map); |
| 292 // Observe parent profile's HostZoomMap changes so they can also be applied |
| 293 // to this profile's HostZoomMap. |
| 294 // Important: this function should never be made virtual without moving the |
| 295 // subscription down to the leaf nodes(s). |
| 296 track_zoom_subscription_ = parent_host_zoom_map->AddZoomLevelChangedCallback( |
| 297 base::Bind(&Profile::TrackZoomLevelChanged, base::Unretained(this))); |
| 298 } |
| 299 |
| 300 void Profile::TrackZoomLevelChanged( |
| 301 const HostZoomMap::ZoomLevelChange& change) { |
| 302 HostZoomMap* host_zoom_map = HostZoomMap::GetDefaultForBrowserContext(this); |
| 303 switch (change.mode) { |
| 304 case HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM: |
| 305 return; |
| 306 case HostZoomMap::ZOOM_CHANGED_FOR_HOST: |
| 307 host_zoom_map->SetZoomLevelForHost(change.host, change.zoom_level); |
| 308 return; |
| 309 case HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: |
| 310 host_zoom_map->SetZoomLevelForHostAndScheme(change.scheme, |
| 311 change.host, |
| 312 change.zoom_level); |
| 313 return; |
| 314 } |
| 315 } |
OLD | NEW |