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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 // URLs work (e.g. chrome://settings). http://crbug.com/153950 | 311 // URLs work (e.g. chrome://settings). http://crbug.com/153950 |
312 content::NavigationEntry* entry = | 312 content::NavigationEntry* entry = |
313 web_contents()->GetController().GetLastCommittedEntry(); | 313 web_contents()->GetController().GetLastCommittedEntry(); |
314 if (!entry || | 314 if (!entry || |
315 host != net::GetHostOrSpecFromURL( | 315 host != net::GetHostOrSpecFromURL( |
316 content::HostZoomMap::GetURLFromEntry(entry))) { | 316 content::HostZoomMap::GetURLFromEntry(entry))) { |
317 return; | 317 return; |
318 } | 318 } |
319 } | 319 } |
320 | 320 |
321 // The zoom bubble should not be shown for zoom changes where the host is | |
322 // empty. | |
323 bool can_show_bubble = can_show_bubble_ && !host.empty(); | |
324 | |
325 if (event_data_) { | 321 if (event_data_) { |
326 // For state changes initiated within the ZoomController, information about | 322 // For state changes initiated within the ZoomController, information about |
327 // the change should be sent. | 323 // the change should be sent. |
328 ZoomChangedEventData zoom_change_data = *event_data_; | 324 ZoomChangedEventData zoom_change_data = *event_data_; |
329 event_data_.reset(); | 325 event_data_.reset(); |
330 zoom_change_data.can_show_bubble = can_show_bubble; | 326 // The zoom bubble should not be shown for zoom changes where the host |
| 327 // is empty. |
| 328 zoom_change_data.can_show_bubble = can_show_bubble_ && !host.empty(); |
331 FOR_EACH_OBSERVER(ZoomObserver, observers_, | 329 FOR_EACH_OBSERVER(ZoomObserver, observers_, |
332 OnZoomChanged(zoom_change_data)); | 330 OnZoomChanged(zoom_change_data)); |
333 } else { | 331 } else { |
334 // TODO(wjmaclean) Should we consider having HostZoomMap send both old and | 332 // TODO(wjmaclean) Should we consider having HostZoomMap send both old and |
335 // new zoom levels here? | 333 // new zoom levels here? |
336 double zoom_level = GetZoomLevel(); | 334 double zoom_level = GetZoomLevel(); |
337 ZoomChangedEventData zoom_change_data( | 335 // We never show a zoom bubble for an event we didn't generate. |
338 web_contents(), zoom_level, zoom_level, zoom_mode_, can_show_bubble); | 336 ZoomChangedEventData zoom_change_data(web_contents(), zoom_level, |
| 337 zoom_level, zoom_mode_, |
| 338 false /* can_show_bubble */); |
339 FOR_EACH_OBSERVER(ZoomObserver, observers_, | 339 FOR_EACH_OBSERVER(ZoomObserver, observers_, |
340 OnZoomChanged(zoom_change_data)); | 340 OnZoomChanged(zoom_change_data)); |
341 } | 341 } |
342 } | 342 } |
343 | 343 |
344 } // namespace ui_zoom | 344 } // namespace ui_zoom |
OLD | NEW |