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

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

Issue 11414018: [zoom bubble] Add tests for ZoomController::UpdateState() handling empty hosts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: --set-upstream and rebase so I can try the code 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
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())
80 return;
81
82 CHECK(web_contents()); // http://crbug.com/144879 79 CHECK(web_contents()); // http://crbug.com/144879
83 80
84 // Use the active navigation entry's URL instead of the WebContents' so 81 // If |host| is empty, all observers should be updated.
85 // virtual URLs work (e.g. chrome://settings). http://crbug.com/153950 82 if (!host.empty()) {
Dan Beam 2012/11/16 04:17:48 I included this diff (from: https://codereview.chr
86 content::NavigationEntry* active_entry = 83 // Use the active navigation entry's URL instead of the WebContents' so
87 web_contents()->GetController().GetActiveEntry(); 84 // virtual URLs work (e.g. chrome://settings). http://crbug.com/153950
88 if (!active_entry || 85 content::NavigationEntry* active_entry =
89 host != net::GetHostOrSpecFromURL(active_entry->GetURL())) { 86 web_contents()->GetController().GetActiveEntry();
90 return; 87 if (!active_entry ||
88 host != net::GetHostOrSpecFromURL(active_entry->GetURL())) {
89 return;
90 }
91 } 91 }
92 92
93 bool dummy; 93 bool dummy;
94 zoom_percent_ = web_contents()->GetZoomPercent(&dummy, &dummy); 94 zoom_percent_ = web_contents()->GetZoomPercent(&dummy, &dummy);
95 95
96 if (observer_) 96 if (observer_)
97 observer_->OnZoomChanged(web_contents(), !host.empty()); 97 observer_->OnZoomChanged(web_contents(), !host.empty());
98 } 98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698