OLD | NEW |
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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.empty()) |
80 return; | 80 return; |
81 | 81 |
| 82 CHECK(web_contents()); // http://crbug.com/144879 |
| 83 |
82 // Use the active navigation entry's URL instead of the WebContents' so | 84 // Use the active navigation entry's URL instead of the WebContents' so |
83 // virtual URLs work (e.g. chrome://settings). http://crbug.com/153950 | 85 // virtual URLs work (e.g. chrome://settings). http://crbug.com/153950 |
84 content::NavigationEntry* active_entry = | 86 content::NavigationEntry* active_entry = |
85 web_contents()->GetController().GetActiveEntry(); | 87 web_contents()->GetController().GetActiveEntry(); |
86 if (!active_entry || | 88 if (!active_entry || |
87 host != net::GetHostOrSpecFromURL(active_entry->GetURL())) { | 89 host != net::GetHostOrSpecFromURL(active_entry->GetURL())) { |
88 return; | 90 return; |
89 } | 91 } |
90 | 92 |
91 bool dummy; | 93 bool dummy; |
92 zoom_percent_ = web_contents()->GetZoomPercent(&dummy, &dummy); | 94 zoom_percent_ = web_contents()->GetZoomPercent(&dummy, &dummy); |
93 | 95 |
94 if (observer_) | 96 if (observer_) |
95 observer_->OnZoomChanged(web_contents(), !host.empty()); | 97 observer_->OnZoomChanged(web_contents(), !host.empty()); |
96 } | 98 } |
OLD | NEW |