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" |
(...skipping 18 matching lines...) Expand all Loading... |
29 #endif | 29 #endif |
30 | 30 |
31 #if defined(OS_ANDROID) && defined(FULL_SAFE_BROWSING) | 31 #if defined(OS_ANDROID) && defined(FULL_SAFE_BROWSING) |
32 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 32 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
33 #endif | 33 #endif |
34 | 34 |
35 #if defined(ENABLE_EXTENSIONS) | 35 #if defined(ENABLE_EXTENSIONS) |
36 #include "extensions/browser/pref_names.h" | 36 #include "extensions/browser/pref_names.h" |
37 #endif | 37 #endif |
38 | 38 |
| 39 using content::HostZoomMap; |
| 40 |
39 Profile::Profile() | 41 Profile::Profile() |
40 : restored_last_session_(false), | 42 : restored_last_session_(false), |
41 sent_destroyed_notification_(false), | 43 sent_destroyed_notification_(false), |
42 accessibility_pause_level_(0) { | 44 accessibility_pause_level_(0) { |
43 } | 45 } |
44 | 46 |
45 Profile::~Profile() { | 47 Profile::~Profile() { |
46 } | 48 } |
47 | 49 |
48 // static | 50 // static |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 content::NotificationService::NoDetails()); | 257 content::NotificationService::NoDetails()); |
256 } | 258 } |
257 } | 259 } |
258 | 260 |
259 bool ProfileCompare::operator()(Profile* a, Profile* b) const { | 261 bool ProfileCompare::operator()(Profile* a, Profile* b) const { |
260 DCHECK(a && b); | 262 DCHECK(a && b); |
261 if (a->IsSameProfile(b)) | 263 if (a->IsSameProfile(b)) |
262 return false; | 264 return false; |
263 return a->GetOriginalProfile() < b->GetOriginalProfile(); | 265 return a->GetOriginalProfile() < b->GetOriginalProfile(); |
264 } | 266 } |
| 267 |
| 268 void Profile::TrackZoomLevelsFromParent(Profile* parent) { |
| 269 // This function only makes sense in a derived class that implements |
| 270 // HostZoomMaps. |
| 271 DCHECK(GetProfileType() == INCOGNITO_PROFILE && |
| 272 parent->GetProfileType() == REGULAR_PROFILE); |
| 273 |
| 274 // Here we only want to use zoom levels stored in the main-context's default |
| 275 // storage partition. We're not interested in zoom levels in special |
| 276 // partitions, e.g. those used by WebViewGuests. |
| 277 HostZoomMap* host_zoom_map = HostZoomMap::GetDefaultForBrowserContext(this); |
| 278 HostZoomMap* parent_host_zoom_map = |
| 279 HostZoomMap::GetDefaultForBrowserContext(parent); |
| 280 host_zoom_map->CopyFrom(parent_host_zoom_map); |
| 281 // Observe parenti profile's HostZoomMap changes so they can also be applied |
| 282 // to this profile's HostZoomMap. |
| 283 track_zoom_subscription_ = parent_host_zoom_map->AddZoomLevelChangedCallback( |
| 284 base::Bind(&Profile::TrackZoomLevelChanged, base::Unretained(this))); |
| 285 } |
| 286 |
| 287 void Profile::TrackZoomLevelChanged( |
| 288 const HostZoomMap::ZoomLevelChange& change) { |
| 289 HostZoomMap* host_zoom_map = HostZoomMap::GetDefaultForBrowserContext(this); |
| 290 switch (change.mode) { |
| 291 case HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM: |
| 292 return; |
| 293 case HostZoomMap::ZOOM_CHANGED_FOR_HOST: |
| 294 host_zoom_map->SetZoomLevelForHost(change.host, change.zoom_level); |
| 295 return; |
| 296 case HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: |
| 297 host_zoom_map->SetZoomLevelForHostAndScheme(change.scheme, |
| 298 change.host, |
| 299 change.zoom_level); |
| 300 return; |
| 301 } |
| 302 } |
OLD | NEW |