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

Side by Side Diff: chrome/browser/ui/zoom/zoom_controller.cc

Issue 11299014: [zoom bubble] Fix my stupidity and restore the proper host handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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/ui/zoom/zoom_controller.h" 5 #include "chrome/browser/ui/zoom/zoom_controller.h"
6 6
7 #include "chrome/browser/prefs/pref_service.h" 7 #include "chrome/browser/prefs/pref_service.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser_finder.h" 9 #include "chrome/browser/ui/browser_finder.h"
10 #include "chrome/browser/ui/tab_contents/tab_contents.h" 10 #include "chrome/browser/ui/tab_contents/tab_contents.h"
(...skipping 17 matching lines...) Expand all
28 observer_(NULL) { 28 observer_(NULL) {
29 Profile* profile = 29 Profile* profile =
30 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 30 Profile::FromBrowserContext(web_contents->GetBrowserContext());
31 default_zoom_level_.Init(prefs::kDefaultZoomLevel, profile->GetPrefs(), this); 31 default_zoom_level_.Init(prefs::kDefaultZoomLevel, profile->GetPrefs(), this);
32 32
33 content::HostZoomMap* zoom_map = 33 content::HostZoomMap* zoom_map =
34 content::HostZoomMap::GetForBrowserContext(profile); 34 content::HostZoomMap::GetForBrowserContext(profile);
35 registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED, 35 registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED,
36 content::Source<content::HostZoomMap>(zoom_map)); 36 content::Source<content::HostZoomMap>(zoom_map));
37 37
38 UpdateState(std::string()); 38 UpdateState(std::string());
Dan Beam 2012/11/15 23:05:06 FYI: I don't see the point to this first UpdateSta
Dan Beam 2012/11/15 23:18:33 nevermind, it also sets |zoom_percent_|.
39 } 39 }
40 40
41 ZoomController::~ZoomController() { 41 ZoomController::~ZoomController() {
42 default_zoom_level_.Destroy(); 42 default_zoom_level_.Destroy();
43 registrar_.RemoveAll(); 43 registrar_.RemoveAll();
44 } 44 }
45 45
46 bool ZoomController::IsAtDefaultZoom() const { 46 bool ZoomController::IsAtDefaultZoom() const {
47 return content::ZoomValuesEqual(web_contents()->GetZoomLevel(), 47 return content::ZoomValuesEqual(web_contents()->GetZoomLevel(),
48 default_zoom_level_.GetValue()); 48 default_zoom_level_.GetValue());
(...skipping 20 matching lines...) Expand all
69 UpdateState(*content::Details<std::string>(details).ptr()); 69 UpdateState(*content::Details<std::string>(details).ptr());
70 } 70 }
71 71
72 void ZoomController::OnPreferenceChanged(PrefServiceBase* service, 72 void ZoomController::OnPreferenceChanged(PrefServiceBase* service,
73 const std::string& pref_name) { 73 const std::string& pref_name) {
74 DCHECK(pref_name == prefs::kDefaultZoomLevel); 74 DCHECK(pref_name == prefs::kDefaultZoomLevel);
75 UpdateState(std::string()); 75 UpdateState(std::string());
76 } 76 }
77 77
78 void ZoomController::UpdateState(const std::string& host) { 78 void ZoomController::UpdateState(const std::string& host) {
79 if (host.empty()) 79 // If |host| is empty, all observers should be updated.
80 return; 80 if (!host.empty()) {
81 81 // Use the active navigation entry's URL instead of the WebContents' so
82 // Use the active navigation entry's URL instead of the WebContents' so 82 // virtual URLs work (e.g. chrome://settings). http://crbug.com/153950
83 // virtual URLs work (e.g. chrome://settings). http://crbug.com/153950 83 content::NavigationEntry* active_entry =
84 content::NavigationEntry* active_entry = 84 web_contents()->GetController().GetActiveEntry();
85 web_contents()->GetController().GetActiveEntry(); 85 if (!active_entry ||
86 if (!active_entry || 86 host != net::GetHostOrSpecFromURL(active_entry->GetURL())) {
87 host != net::GetHostOrSpecFromURL(active_entry->GetURL())) { 87 return;
88 return; 88 }
89 } 89 }
90 90
91 bool dummy; 91 bool dummy;
92 zoom_percent_ = web_contents()->GetZoomPercent(&dummy, &dummy); 92 zoom_percent_ = web_contents()->GetZoomPercent(&dummy, &dummy);
93 93
94 if (observer_) 94 if (observer_)
95 observer_->OnZoomChanged(web_contents(), !host.empty()); 95 observer_->OnZoomChanged(web_contents(), !host.empty());
96 } 96 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/zoom/zoom_controller.h ('k') | chrome/browser/ui/zoom/zoom_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698