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

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

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head for commit 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
« no previous file with comments | « chrome/browser/ui/zoom/zoom_controller.h ('k') | chrome/common/DEPS » ('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) 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 const content::LoadCommittedDetails& details, 58 const content::LoadCommittedDetails& details,
59 const content::FrameNavigateParams& params) { 59 const content::FrameNavigateParams& params) {
60 // If the main frame's content has changed, the new page may have a different 60 // If the main frame's content has changed, the new page may have a different
61 // zoom level from the old one. 61 // zoom level from the old one.
62 UpdateState(std::string()); 62 UpdateState(std::string());
63 } 63 }
64 64
65 void ZoomController::Observe(int type, 65 void ZoomController::Observe(int type,
66 const content::NotificationSource& source, 66 const content::NotificationSource& source,
67 const content::NotificationDetails& details) { 67 const content::NotificationDetails& details) {
68 switch (type) { 68 DCHECK_EQ(content::NOTIFICATION_ZOOM_LEVEL_CHANGED, type);
69 case chrome::NOTIFICATION_PREF_CHANGED: { 69 UpdateState(*content::Details<std::string>(details).ptr());
70 std::string* pref_name = content::Details<std::string>(details).ptr(); 70 }
71 DCHECK(pref_name && *pref_name == prefs::kDefaultZoomLevel); 71
72 UpdateState(std::string()); 72 void ZoomController::OnPreferenceChanged(PrefServiceBase* service,
73 break; 73 const std::string& pref_name) {
74 } 74 DCHECK(pref_name == prefs::kDefaultZoomLevel);
75 case content::NOTIFICATION_ZOOM_LEVEL_CHANGED: 75 UpdateState(std::string());
76 UpdateState(*content::Details<std::string>(details).ptr());
77 break;
78 default:
79 NOTREACHED();
80 }
81 } 76 }
82 77
83 void ZoomController::UpdateState(const std::string& host) { 78 void ZoomController::UpdateState(const std::string& host) {
84 if (host.empty()) 79 if (host.empty())
85 return; 80 return;
86 81
87 // 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
88 // virtual URLs work (e.g. chrome://settings). http://crbug.com/153950 83 // virtual URLs work (e.g. chrome://settings). http://crbug.com/153950
89 content::NavigationEntry* active_entry = 84 content::NavigationEntry* active_entry =
90 web_contents()->GetController().GetActiveEntry(); 85 web_contents()->GetController().GetActiveEntry();
91 if (!active_entry || 86 if (!active_entry ||
92 host != net::GetHostOrSpecFromURL(active_entry->GetURL())) { 87 host != net::GetHostOrSpecFromURL(active_entry->GetURL())) {
93 return; 88 return;
94 } 89 }
95 90
96 bool dummy; 91 bool dummy;
97 zoom_percent_ = web_contents()->GetZoomPercent(&dummy, &dummy); 92 zoom_percent_ = web_contents()->GetZoomPercent(&dummy, &dummy);
98 93
99 if (observer_) 94 if (observer_)
100 observer_->OnZoomChanged(web_contents(), !host.empty()); 95 observer_->OnZoomChanged(web_contents(), !host.empty());
101 } 96 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/zoom/zoom_controller.h ('k') | chrome/common/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698