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 "chrome/browser/ui/sad_tab.h" |
7 #include "chrome/browser/ui/zoom/zoom_event_manager.h" | 8 #include "chrome/browser/ui/zoom/zoom_event_manager.h" |
8 #include "chrome/browser/ui/zoom/zoom_observer.h" | 9 #include "chrome/browser/ui/zoom/zoom_observer.h" |
9 #include "content/public/browser/host_zoom_map.h" | 10 #include "content/public/browser/host_zoom_map.h" |
10 #include "content/public/browser/navigation_entry.h" | 11 #include "content/public/browser/navigation_entry.h" |
11 #include "content/public/browser/render_process_host.h" | 12 #include "content/public/browser/render_process_host.h" |
12 #include "content/public/browser/render_view_host.h" | 13 #include "content/public/browser/render_view_host.h" |
13 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
14 #include "content/public/common/page_zoom.h" | 15 #include "content/public/common/page_zoom.h" |
15 #include "extensions/common/extension.h" | 16 #include "extensions/common/extension.h" |
16 #include "grit/theme_resources.h" | 17 #include "grit/theme_resources.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // An extension did not initiate this zoom change. | 74 // An extension did not initiate this zoom change. |
74 return SetZoomLevelByExtension(zoom_level, NULL); | 75 return SetZoomLevelByExtension(zoom_level, NULL); |
75 } | 76 } |
76 | 77 |
77 bool ZoomController::SetZoomLevelByExtension( | 78 bool ZoomController::SetZoomLevelByExtension( |
78 double zoom_level, | 79 double zoom_level, |
79 const scoped_refptr<const extensions::Extension>& extension) { | 80 const scoped_refptr<const extensions::Extension>& extension) { |
80 // Cannot zoom in disabled mode. Also, don't allow changing zoom level on | 81 // Cannot zoom in disabled mode. Also, don't allow changing zoom level on |
81 // a crashed tab. | 82 // a crashed tab. |
82 if (zoom_mode_ == ZOOM_MODE_DISABLED || | 83 if (zoom_mode_ == ZOOM_MODE_DISABLED || |
83 !web_contents()->GetRenderProcessHost()->HasConnection()) | 84 !web_contents()->GetRenderViewHost()->IsRenderViewLive()) |
84 return false; | 85 return false; |
85 | 86 |
86 // Store extension data so that |extension| can be attributed when the zoom | 87 // Store extension data so that |extension| can be attributed when the zoom |
87 // change completes. We expect that by the time this function returns that | 88 // change completes. We expect that by the time this function returns that |
88 // any observers that require this information will have requested it. | 89 // any observers that require this information will have requested it. |
89 last_extension_ = extension; | 90 last_extension_ = extension; |
90 | 91 |
91 // Do not actually rescale the page in manual mode. | 92 // Do not actually rescale the page in manual mode. |
92 if (zoom_mode_ == ZOOM_MODE_MANUAL) { | 93 if (zoom_mode_ == ZOOM_MODE_MANUAL) { |
93 double old_zoom_level = zoom_level_; | 94 double old_zoom_level = zoom_level_; |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 } else { | 286 } else { |
286 // TODO(wjmaclean) Should we consider having HostZoomMap send both old and | 287 // TODO(wjmaclean) Should we consider having HostZoomMap send both old and |
287 // new zoom levels here? | 288 // new zoom levels here? |
288 double zoom_level = GetZoomLevel(); | 289 double zoom_level = GetZoomLevel(); |
289 ZoomChangedEventData zoom_change_data( | 290 ZoomChangedEventData zoom_change_data( |
290 web_contents(), zoom_level, zoom_level, zoom_mode_, can_show_bubble); | 291 web_contents(), zoom_level, zoom_level, zoom_mode_, can_show_bubble); |
291 FOR_EACH_OBSERVER( | 292 FOR_EACH_OBSERVER( |
292 ZoomObserver, observers_, OnZoomChanged(zoom_change_data)); | 293 ZoomObserver, observers_, OnZoomChanged(zoom_change_data)); |
293 } | 294 } |
294 } | 295 } |
OLD | NEW |