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 if (GetProfileType() != INCOGNITO_PROFILE || | |
Fady Samuel
2014/08/13 19:45:42
This seems like an assumption that may be violated
wjmaclean
2014/08/14 18:18:21
Done.
| |
270 parent->GetProfileType() != REGULAR_PROFILE) | |
271 return; | |
272 | |
273 // Here we only want to use zoom levels stored in the main-context's default | |
274 // storage partition. We're not interested in zoom levels in special | |
275 // partitions, e.g. those used by WebViewGuests. | |
276 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); | |
277 HostZoomMap* parent_host_zoom_map = HostZoomMap::GetForBrowserContext(parent); | |
278 host_zoom_map->CopyFrom(parent_host_zoom_map); | |
279 // Observe parenti profile's HostZoomMap changes so they can also be applied | |
280 // to this profile's HostZoomMap. | |
281 track_zoom_subscription_ = parent_host_zoom_map->AddZoomLevelChangedCallback( | |
282 base::Bind(&Profile::TrackZoomLevelChanged, base::Unretained(this))); | |
Fady Samuel
2014/08/13 19:45:42
I worry about the lifetime implications here. What
wjmaclean
2014/08/14 18:18:21
The HostZoomMap lives in a StoragePartitionImpl in
Fady Samuel
2014/08/14 18:56:26
That doesn't seem to be the case looking at this c
wjmaclean
2014/08/14 19:12:20
My mistake, but we're still OK. Wrt to parent's Ho
| |
283 } | |
284 | |
285 void Profile::TrackZoomLevelChanged( | |
286 const HostZoomMap::ZoomLevelChange& change) { | |
287 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); | |
288 switch (change.mode) { | |
289 case HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM: | |
290 return; | |
291 case HostZoomMap::ZOOM_CHANGED_FOR_HOST: | |
292 host_zoom_map->SetZoomLevelForHost(change.host, change.zoom_level); | |
293 return; | |
294 case HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: | |
295 host_zoom_map->SetZoomLevelForHostAndScheme(change.scheme, | |
296 change.host, | |
297 change.zoom_level); | |
298 return; | |
299 } | |
300 } | |
OLD | NEW |