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 or when zoom level is not changed from default. | 350 // is empty. |
351 const bool changed_from_default = | 351 zoom_change_data.can_show_bubble = can_show_bubble_ && !host.empty(); |
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; | |
356 for (auto& observer : observers_) | 352 for (auto& observer : observers_) |
357 observer.OnZoomChanged(zoom_change_data); | 353 observer.OnZoomChanged(zoom_change_data); |
358 } else { | 354 } else { |
359 // TODO(wjmaclean) Should we consider having HostZoomMap send both old and | 355 // TODO(wjmaclean) Should we consider having HostZoomMap send both old and |
360 // new zoom levels here? | 356 // new zoom levels here? |
361 double zoom_level = GetZoomLevel(); | 357 double zoom_level = GetZoomLevel(); |
362 // We never show a zoom bubble for an event we didn't generate. | 358 // We never show a zoom bubble for an event we didn't generate. |
363 ZoomChangedEventData zoom_change_data(web_contents(), zoom_level, | 359 ZoomChangedEventData zoom_change_data(web_contents(), zoom_level, |
364 zoom_level, zoom_mode_, | 360 zoom_level, zoom_mode_, |
365 false /* can_show_bubble */); | 361 false /* can_show_bubble */); |
366 for (auto& observer : observers_) | 362 for (auto& observer : observers_) |
367 observer.OnZoomChanged(zoom_change_data); | 363 observer.OnZoomChanged(zoom_change_data); |
368 } | 364 } |
369 } | 365 } |
370 | 366 |
371 void ZoomController::SetPageScaleFactorIsOneForTesting(bool is_one) { | 367 void ZoomController::SetPageScaleFactorIsOneForTesting(bool is_one) { |
372 int render_process_id = web_contents()->GetRenderProcessHost()->GetID(); | 368 int render_process_id = web_contents()->GetRenderProcessHost()->GetID(); |
373 int render_view_id = web_contents()->GetRenderViewHost()->GetRoutingID(); | 369 int render_view_id = web_contents()->GetRenderViewHost()->GetRoutingID(); |
374 host_zoom_map_->SetPageScaleFactorIsOneForView(render_process_id, | 370 host_zoom_map_->SetPageScaleFactorIsOneForView(render_process_id, |
375 render_view_id, is_one); | 371 render_view_id, is_one); |
376 } | 372 } |
377 | 373 |
378 bool ZoomController::PageScaleFactorIsOne() const { | 374 bool ZoomController::PageScaleFactorIsOne() const { |
379 return content::HostZoomMap::PageScaleFactorIsOne(web_contents()); | 375 return content::HostZoomMap::PageScaleFactorIsOne(web_contents()); |
380 } | 376 } |
381 | 377 |
382 } // namespace zoom | 378 } // namespace zoom |
OLD | NEW |