| 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/zoom/zoom_controller.h" | 5 #include "components/zoom/zoom_controller.h" |
| 6 | 6 |
| 7 #include "components/zoom/zoom_event_manager.h" | 7 #include "components/zoom/zoom_event_manager.h" |
| 8 #include "components/zoom/zoom_observer.h" | 8 #include "components/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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 return; | 340 return; |
| 341 } | 341 } |
| 342 } | 342 } |
| 343 | 343 |
| 344 if (event_data_) { | 344 if (event_data_) { |
| 345 // For state changes initiated within the ZoomController, information about | 345 // For state changes initiated within the ZoomController, information about |
| 346 // the change should be sent. | 346 // the change should be sent. |
| 347 ZoomChangedEventData zoom_change_data = *event_data_; | 347 ZoomChangedEventData zoom_change_data = *event_data_; |
| 348 event_data_.reset(); | 348 event_data_.reset(); |
| 349 // The zoom bubble should not be shown for zoom changes where the host | 349 // The zoom bubble should not be shown for zoom changes where the host |
| 350 // is empty. | 350 // is empty or when zoom level is not changed from default. |
| 351 zoom_change_data.can_show_bubble = can_show_bubble_ && !host.empty(); | 351 const bool changed_from_default = |
| 352 zoom_change_data.new_zoom_level != zoom_change_data.old_zoom_level || |
| 353 zoom_change_data.new_zoom_level != GetDefaultZoomLevel(); |
| 354 zoom_change_data.can_show_bubble = |
| 355 can_show_bubble_ && !host.empty() && changed_from_default; |
| 352 for (auto& observer : observers_) | 356 for (auto& observer : observers_) |
| 353 observer.OnZoomChanged(zoom_change_data); | 357 observer.OnZoomChanged(zoom_change_data); |
| 354 } else { | 358 } else { |
| 355 // TODO(wjmaclean) Should we consider having HostZoomMap send both old and | 359 // TODO(wjmaclean) Should we consider having HostZoomMap send both old and |
| 356 // new zoom levels here? | 360 // new zoom levels here? |
| 357 double zoom_level = GetZoomLevel(); | 361 double zoom_level = GetZoomLevel(); |
| 358 // We never show a zoom bubble for an event we didn't generate. | 362 // We never show a zoom bubble for an event we didn't generate. |
| 359 ZoomChangedEventData zoom_change_data(web_contents(), zoom_level, | 363 ZoomChangedEventData zoom_change_data(web_contents(), zoom_level, |
| 360 zoom_level, zoom_mode_, | 364 zoom_level, zoom_mode_, |
| 361 false /* can_show_bubble */); | 365 false /* can_show_bubble */); |
| 362 for (auto& observer : observers_) | 366 for (auto& observer : observers_) |
| 363 observer.OnZoomChanged(zoom_change_data); | 367 observer.OnZoomChanged(zoom_change_data); |
| 364 } | 368 } |
| 365 } | 369 } |
| 366 | 370 |
| 367 void ZoomController::SetPageScaleFactorIsOneForTesting(bool is_one) { | 371 void ZoomController::SetPageScaleFactorIsOneForTesting(bool is_one) { |
| 368 int render_process_id = web_contents()->GetRenderProcessHost()->GetID(); | 372 int render_process_id = web_contents()->GetRenderProcessHost()->GetID(); |
| 369 int render_view_id = web_contents()->GetRenderViewHost()->GetRoutingID(); | 373 int render_view_id = web_contents()->GetRenderViewHost()->GetRoutingID(); |
| 370 host_zoom_map_->SetPageScaleFactorIsOneForView(render_process_id, | 374 host_zoom_map_->SetPageScaleFactorIsOneForView(render_process_id, |
| 371 render_view_id, is_one); | 375 render_view_id, is_one); |
| 372 } | 376 } |
| 373 | 377 |
| 374 bool ZoomController::PageScaleFactorIsOne() const { | 378 bool ZoomController::PageScaleFactorIsOne() const { |
| 375 return content::HostZoomMap::PageScaleFactorIsOne(web_contents()); | 379 return content::HostZoomMap::PageScaleFactorIsOne(web_contents()); |
| 376 } | 380 } |
| 377 | 381 |
| 378 } // namespace zoom | 382 } // namespace zoom |
| OLD | NEW |