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 "components/ui/zoom/zoom_controller.h" | 5 #include "components/ui/zoom/zoom_controller.h" |
6 | 6 |
7 #include "components/ui/zoom/zoom_event_manager.h" | 7 #include "components/ui/zoom/zoom_event_manager.h" |
8 #include "components/ui/zoom/zoom_observer.h" | 8 #include "components/ui/zoom/zoom_observer.h" |
9 #include "content/public/browser/host_zoom_map.h" | 9 #include "content/public/browser/host_zoom_map.h" |
10 #include "content/public/browser/navigation_details.h" | 10 #include "content/public/browser/navigation_details.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 !web_contents()->GetRenderViewHost()->IsRenderViewLive()) | 88 !web_contents()->GetRenderViewHost()->IsRenderViewLive()) |
89 return false; | 89 return false; |
90 | 90 |
91 // Store client data so the |client| can be attributed when the zoom | 91 // Store client data so the |client| can be attributed when the zoom |
92 // change completes. We expect that by the time this function returns that | 92 // change completes. We expect that by the time this function returns that |
93 // any observers that require this information will have requested it. | 93 // any observers that require this information will have requested it. |
94 last_client_ = client; | 94 last_client_ = client; |
95 | 95 |
96 // Do not actually rescale the page in manual mode. | 96 // Do not actually rescale the page in manual mode. |
97 if (zoom_mode_ == ZOOM_MODE_MANUAL) { | 97 if (zoom_mode_ == ZOOM_MODE_MANUAL) { |
| 98 // If the zoom level hasn't changed, early out to avoid sending an event. |
| 99 if (zoom_level_ == zoom_level) |
| 100 return true; |
| 101 |
98 double old_zoom_level = zoom_level_; | 102 double old_zoom_level = zoom_level_; |
99 zoom_level_ = zoom_level; | 103 zoom_level_ = zoom_level; |
100 | 104 |
101 // TODO(wjmaclean) Do we care about filling in host/scheme here? | 105 // TODO(wjmaclean) Do we care about filling in host/scheme here? |
102 content::HostZoomMap::ZoomLevelChange change; | 106 content::HostZoomMap::ZoomLevelChange change; |
103 change.mode = content::HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM; | 107 change.mode = content::HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM; |
104 change.zoom_level = zoom_level; | 108 change.zoom_level = zoom_level; |
105 ZoomEventManager::GetForBrowserContext(browser_context_) | 109 ZoomEventManager::GetForBrowserContext(browser_context_) |
106 ->OnZoomLevelChanged(change); | 110 ->OnZoomLevelChanged(change); |
107 | 111 |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 // new zoom levels here? | 335 // new zoom levels here? |
332 double zoom_level = GetZoomLevel(); | 336 double zoom_level = GetZoomLevel(); |
333 ZoomChangedEventData zoom_change_data( | 337 ZoomChangedEventData zoom_change_data( |
334 web_contents(), zoom_level, zoom_level, zoom_mode_, can_show_bubble); | 338 web_contents(), zoom_level, zoom_level, zoom_mode_, can_show_bubble); |
335 FOR_EACH_OBSERVER(ZoomObserver, observers_, | 339 FOR_EACH_OBSERVER(ZoomObserver, observers_, |
336 OnZoomChanged(zoom_change_data)); | 340 OnZoomChanged(zoom_change_data)); |
337 } | 341 } |
338 } | 342 } |
339 | 343 |
340 } // namespace ui_zoom | 344 } // namespace ui_zoom |
OLD | NEW |