Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: chrome/browser/host_zoom_map.cc

Issue 1744003: Send content settings based on the URL to the renderer instead of just the host. (Closed)
Patch Set: nits Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/host_zoom_map.h ('k') | chrome/browser/host_zoom_map_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_source.h" 13 #include "chrome/common/notification_source.h"
14 #include "chrome/common/notification_type.h" 14 #include "chrome/common/notification_type.h"
15 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
16 #include "googleurl/src/gurl.h"
17 #include "net/base/net_util.h"
16 18
17 HostZoomMap::HostZoomMap(Profile* profile) 19 HostZoomMap::HostZoomMap(Profile* profile)
18 : profile_(profile), 20 : profile_(profile),
19 updating_preferences_(false) { 21 updating_preferences_(false) {
20 Load(); 22 Load();
21 registrar_.Add(this, NotificationType::PROFILE_DESTROYED, 23 registrar_.Add(this, NotificationType::PROFILE_DESTROYED,
22 Source<Profile>(profile)); 24 Source<Profile>(profile));
23 profile_->GetPrefs()->AddPrefObserver(prefs::kPerHostZoomLevels, this); 25 profile_->GetPrefs()->AddPrefObserver(prefs::kPerHostZoomLevels, this);
24 } 26 }
25 27
(...skipping 17 matching lines...) Expand all
43 host_zoom_levels_[WideToUTF8(wide_host)] = zoom_level; 45 host_zoom_levels_[WideToUTF8(wide_host)] = zoom_level;
44 } 46 }
45 } 47 }
46 } 48 }
47 49
48 // static 50 // static
49 void HostZoomMap::RegisterUserPrefs(PrefService* prefs) { 51 void HostZoomMap::RegisterUserPrefs(PrefService* prefs) {
50 prefs->RegisterDictionaryPref(prefs::kPerHostZoomLevels); 52 prefs->RegisterDictionaryPref(prefs::kPerHostZoomLevels);
51 } 53 }
52 54
53 int HostZoomMap::GetZoomLevel(const std::string& host) const { 55 int HostZoomMap::GetZoomLevel(const GURL& url) const {
56 std::string host(net::GetHostOrSpecFromURL(url));
54 AutoLock auto_lock(lock_); 57 AutoLock auto_lock(lock_);
55 HostZoomLevels::const_iterator i(host_zoom_levels_.find(host)); 58 HostZoomLevels::const_iterator i(host_zoom_levels_.find(host));
56 return (i == host_zoom_levels_.end()) ? 0 : i->second; 59 return (i == host_zoom_levels_.end()) ? 0 : i->second;
57 } 60 }
58 61
59 void HostZoomMap::SetZoomLevel(const std::string& host, int level) { 62 void HostZoomMap::SetZoomLevel(const GURL& url, int level) {
60 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); 63 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
61 if (!profile_) 64 if (!profile_)
62 return; 65 return;
63 66
64 if (host.empty()) 67 std::string host(net::GetHostOrSpecFromURL(url));
65 return;
66 68
67 { 69 {
68 AutoLock auto_lock(lock_); 70 AutoLock auto_lock(lock_);
69 if (level == 0) 71 if (level == 0)
70 host_zoom_levels_.erase(host); 72 host_zoom_levels_.erase(host);
71 else 73 else
72 host_zoom_levels_[host] = level; 74 host_zoom_levels_[host] = level;
73 } 75 }
74 76
75 updating_preferences_ = true; 77 updating_preferences_ = true;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 return; 140 return;
139 } 141 }
140 } 142 }
141 143
142 NOTREACHED() << "Unexpected preference observed."; 144 NOTREACHED() << "Unexpected preference observed.";
143 } 145 }
144 146
145 HostZoomMap::~HostZoomMap() { 147 HostZoomMap::~HostZoomMap() {
146 Shutdown(); 148 Shutdown();
147 } 149 }
OLDNEW
« no previous file with comments | « chrome/browser/host_zoom_map.h ('k') | chrome/browser/host_zoom_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698