Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/host_zoom_map.h" | 5 #include "chrome/browser/host_zoom_map.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/chrome_thread.h" | 8 #include "chrome/browser/chrome_thread.h" |
| 9 #include "chrome/browser/pref_service.h" | 9 #include "chrome/browser/pref_service.h" |
| 10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
| 11 #include "chrome/browser/scoped_pref_update.h" | 11 #include "chrome/browser/scoped_pref_update.h" |
| 12 #include "chrome/common/notification_details.h" | 12 #include "chrome/common/notification_details.h" |
| 13 #include "chrome/common/notification_service.h" | |
| 13 #include "chrome/common/notification_source.h" | 14 #include "chrome/common/notification_source.h" |
| 14 #include "chrome/common/notification_type.h" | 15 #include "chrome/common/notification_type.h" |
| 15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 16 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
| 17 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
| 18 | 19 |
| 19 HostZoomMap::HostZoomMap(Profile* profile) | 20 HostZoomMap::HostZoomMap(Profile* profile) |
| 20 : profile_(profile), | 21 : profile_(profile), |
| 21 updating_preferences_(false) { | 22 updating_preferences_(false) { |
| 22 Load(); | 23 Load(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 std::string host(net::GetHostOrSpecFromURL(url)); | 72 std::string host(net::GetHostOrSpecFromURL(url)); |
| 72 | 73 |
| 73 { | 74 { |
| 74 AutoLock auto_lock(lock_); | 75 AutoLock auto_lock(lock_); |
| 75 if (level == 0) | 76 if (level == 0) |
| 76 host_zoom_levels_.erase(host); | 77 host_zoom_levels_.erase(host); |
| 77 else | 78 else |
| 78 host_zoom_levels_[host] = level; | 79 host_zoom_levels_[host] = level; |
| 79 } | 80 } |
| 80 | 81 |
| 82 Details<std::string> details(&host); | |
| 83 NotificationService::current()->Notify(NotificationType::ZOOM_LEVEL_CHANGED, | |
| 84 Source<Profile>(profile_), | |
| 85 details); | |
|
Peter Kasting
2010/06/08 17:54:00
Nit: You can fit this on two lines
| |
| 86 | |
| 81 // If we're in incognito mode, don't persist changes to the prefs. We'll keep | 87 // If we're in incognito mode, don't persist changes to the prefs. We'll keep |
| 82 // them in memory only so they will be forgotten on exiting incognito. | 88 // them in memory only so they will be forgotten on exiting incognito. |
| 83 if (profile_->IsOffTheRecord()) | 89 if (profile_->IsOffTheRecord()) |
| 84 return; | 90 return; |
| 85 | 91 |
| 86 updating_preferences_ = true; | 92 updating_preferences_ = true; |
| 87 { | 93 { |
| 88 ScopedPrefUpdate update(profile_->GetPrefs(), prefs::kPerHostZoomLevels); | 94 ScopedPrefUpdate update(profile_->GetPrefs(), prefs::kPerHostZoomLevels); |
| 89 DictionaryValue* host_zoom_dictionary = | 95 DictionaryValue* host_zoom_dictionary = |
| 90 profile_->GetPrefs()->GetMutableDictionary(prefs::kPerHostZoomLevels); | 96 profile_->GetPrefs()->GetMutableDictionary(prefs::kPerHostZoomLevels); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 return; | 156 return; |
| 151 } | 157 } |
| 152 } | 158 } |
| 153 | 159 |
| 154 NOTREACHED() << "Unexpected preference observed."; | 160 NOTREACHED() << "Unexpected preference observed."; |
| 155 } | 161 } |
| 156 | 162 |
| 157 HostZoomMap::~HostZoomMap() { | 163 HostZoomMap::~HostZoomMap() { |
| 158 Shutdown(); | 164 Shutdown(); |
| 159 } | 165 } |
| OLD | NEW |