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 "base/prefs/pref_service.h" | 7 #include "base/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/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 61 } |
62 | 62 |
63 void ZoomController::DidNavigateMainFrame( | 63 void ZoomController::DidNavigateMainFrame( |
64 const content::LoadCommittedDetails& details, | 64 const content::LoadCommittedDetails& details, |
65 const content::FrameNavigateParams& params) { | 65 const content::FrameNavigateParams& params) { |
66 // If the main frame's content has changed, the new page may have a different | 66 // If the main frame's content has changed, the new page may have a different |
67 // zoom level from the old one. | 67 // zoom level from the old one. |
68 UpdateState(std::string()); | 68 UpdateState(std::string()); |
69 } | 69 } |
70 | 70 |
71 void ZoomController::OnZoomLevelChanged(const std::string& host) { | 71 void ZoomController::OnZoomLevelChanged( |
72 UpdateState(host); | 72 const content::HostZoomMap::ZoomLevelChange& change) { |
| 73 if (change.mode != content::HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM) |
| 74 UpdateState(change.host); |
73 } | 75 } |
74 | 76 |
75 void ZoomController::UpdateState(const std::string& host) { | 77 void ZoomController::UpdateState(const std::string& host) { |
76 // If |host| is empty, all observers should be updated. | 78 // If |host| is empty, all observers should be updated. |
77 if (!host.empty()) { | 79 if (!host.empty()) { |
78 // Use the active navigation entry's URL instead of the WebContents' so | 80 // Use the active navigation entry's URL instead of the WebContents' so |
79 // virtual URLs work (e.g. chrome://settings). http://crbug.com/153950 | 81 // virtual URLs work (e.g. chrome://settings). http://crbug.com/153950 |
80 content::NavigationEntry* active_entry = | 82 content::NavigationEntry* active_entry = |
81 web_contents()->GetController().GetActiveEntry(); | 83 web_contents()->GetController().GetActiveEntry(); |
82 if (!active_entry || | 84 if (!active_entry || |
83 host != net::GetHostOrSpecFromURL(active_entry->GetURL())) { | 85 host != net::GetHostOrSpecFromURL(active_entry->GetURL())) { |
84 return; | 86 return; |
85 } | 87 } |
86 } | 88 } |
87 | 89 |
88 bool dummy; | 90 bool dummy; |
89 zoom_percent_ = web_contents()->GetZoomPercent(&dummy, &dummy); | 91 zoom_percent_ = web_contents()->GetZoomPercent(&dummy, &dummy); |
90 | 92 |
91 if (observer_) | 93 if (observer_) |
92 observer_->OnZoomChanged(web_contents(), !host.empty()); | 94 observer_->OnZoomChanged(web_contents(), !host.empty()); |
93 } | 95 } |
OLD | NEW |