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/views/location_bar/zoom_bubble_view.h" | 5 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "ui/views/layout/layout_constants.h" | 32 #include "ui/views/layout/layout_constants.h" |
33 #include "ui/views/widget/widget.h" | 33 #include "ui/views/widget/widget.h" |
34 | 34 |
35 // static | 35 // static |
36 ZoomBubbleView* ZoomBubbleView::zoom_bubble_ = NULL; | 36 ZoomBubbleView* ZoomBubbleView::zoom_bubble_ = NULL; |
37 | 37 |
38 // static | 38 // static |
39 void ZoomBubbleView::ShowBubble(content::WebContents* web_contents, | 39 void ZoomBubbleView::ShowBubble(content::WebContents* web_contents, |
40 bool auto_close) { | 40 bool auto_close) { |
41 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 41 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
42 DCHECK(browser && browser->window() && browser->fullscreen_controller()); | 42 DCHECK(browser && browser->window() && |
| 43 browser->exclusive_access_manager()->fullscreen_controller()); |
43 | 44 |
44 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); | 45 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); |
45 bool is_fullscreen = browser_view->IsFullscreen(); | 46 bool is_fullscreen = browser_view->IsFullscreen(); |
46 bool anchor_to_view = !is_fullscreen || | 47 bool anchor_to_view = !is_fullscreen || |
47 browser_view->immersive_mode_controller()->IsRevealed(); | 48 browser_view->immersive_mode_controller()->IsRevealed(); |
48 views::View* anchor_view = anchor_to_view ? | 49 views::View* anchor_view = anchor_to_view ? |
49 browser_view->GetLocationBarView()->zoom_view() : NULL; | 50 browser_view->GetLocationBarView()->zoom_view() : NULL; |
50 | 51 |
51 // Find the extension that initiated the zoom change, if any. | 52 // Find the extension that initiated the zoom change, if any. |
52 ui_zoom::ZoomController* zoom_controller = | 53 ui_zoom::ZoomController* zoom_controller = |
53 ui_zoom::ZoomController::FromWebContents(web_contents); | 54 ui_zoom::ZoomController::FromWebContents(web_contents); |
54 const ui_zoom::ZoomRequestClient* client = zoom_controller->last_client(); | 55 const ui_zoom::ZoomRequestClient* client = zoom_controller->last_client(); |
55 | 56 |
56 // If the bubble is already showing in this window and the zoom change was not | 57 // If the bubble is already showing in this window and the zoom change was not |
57 // initiated by an extension, then the bubble can be reused and only the label | 58 // initiated by an extension, then the bubble can be reused and only the label |
58 // text needs to be updated. | 59 // text needs to be updated. |
59 if (zoom_bubble_ && zoom_bubble_->GetAnchorView() == anchor_view && !client) { | 60 if (zoom_bubble_ && zoom_bubble_->GetAnchorView() == anchor_view && !client) { |
60 DCHECK_EQ(web_contents, zoom_bubble_->web_contents_); | 61 DCHECK_EQ(web_contents, zoom_bubble_->web_contents_); |
61 zoom_bubble_->Refresh(); | 62 zoom_bubble_->Refresh(); |
62 return; | 63 return; |
63 } | 64 } |
64 | 65 |
65 // If the bubble is already showing but in a different tab, the current | 66 // If the bubble is already showing but in a different tab, the current |
66 // bubble must be closed and a new one created. | 67 // bubble must be closed and a new one created. |
67 CloseBubble(); | 68 CloseBubble(); |
68 | 69 |
69 zoom_bubble_ = new ZoomBubbleView(anchor_view, | 70 zoom_bubble_ = new ZoomBubbleView(anchor_view, web_contents, auto_close, |
70 web_contents, | 71 browser_view->immersive_mode_controller()); |
71 auto_close, | |
72 browser_view->immersive_mode_controller(), | |
73 browser->fullscreen_controller()); | |
74 | 72 |
75 // If the zoom change was initiated by an extension, capture the relevent | 73 // If the zoom change was initiated by an extension, capture the relevent |
76 // information from it. | 74 // information from it. |
77 if (client) { | 75 if (client) { |
78 zoom_bubble_->SetExtensionInfo( | 76 zoom_bubble_->SetExtensionInfo( |
79 static_cast<const extensions::ExtensionZoomRequestClient*>(client) | 77 static_cast<const extensions::ExtensionZoomRequestClient*>(client) |
80 ->extension()); | 78 ->extension()); |
81 } | 79 } |
82 | 80 |
83 // If we do not have an anchor view, parent the bubble to the content area. | 81 // If we do not have an anchor view, parent the bubble to the content area. |
(...skipping 27 matching lines...) Expand all Loading... |
111 | 109 |
112 // static | 110 // static |
113 const ZoomBubbleView* ZoomBubbleView::GetZoomBubbleForTest() { | 111 const ZoomBubbleView* ZoomBubbleView::GetZoomBubbleForTest() { |
114 return zoom_bubble_; | 112 return zoom_bubble_; |
115 } | 113 } |
116 | 114 |
117 ZoomBubbleView::ZoomBubbleView( | 115 ZoomBubbleView::ZoomBubbleView( |
118 views::View* anchor_view, | 116 views::View* anchor_view, |
119 content::WebContents* web_contents, | 117 content::WebContents* web_contents, |
120 bool auto_close, | 118 bool auto_close, |
121 ImmersiveModeController* immersive_mode_controller, | 119 ImmersiveModeController* immersive_mode_controller) |
122 FullscreenController* fullscreen_controller) | |
123 : ManagedFullScreenBubbleDelegateView(anchor_view, web_contents), | 120 : ManagedFullScreenBubbleDelegateView(anchor_view, web_contents), |
124 image_button_(NULL), | 121 image_button_(NULL), |
125 label_(NULL), | 122 label_(NULL), |
126 web_contents_(web_contents), | 123 web_contents_(web_contents), |
127 auto_close_(auto_close), | 124 auto_close_(auto_close), |
128 immersive_mode_controller_(immersive_mode_controller) { | 125 immersive_mode_controller_(immersive_mode_controller) { |
129 // Compensate for built-in vertical padding in the anchor view's image. | 126 // Compensate for built-in vertical padding in the anchor view's image. |
130 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); | 127 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); |
131 set_notify_enter_exit_on_child(true); | 128 set_notify_enter_exit_on_child(true); |
132 immersive_mode_controller_->AddObserver(this); | 129 immersive_mode_controller_->AddObserver(this); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 } | 321 } |
325 } | 322 } |
326 | 323 |
327 void ZoomBubbleView::StopTimer() { | 324 void ZoomBubbleView::StopTimer() { |
328 timer_.Stop(); | 325 timer_.Stop(); |
329 } | 326 } |
330 | 327 |
331 ZoomBubbleView::ZoomBubbleExtensionInfo::ZoomBubbleExtensionInfo() {} | 328 ZoomBubbleView::ZoomBubbleExtensionInfo::ZoomBubbleExtensionInfo() {} |
332 | 329 |
333 ZoomBubbleView::ZoomBubbleExtensionInfo::~ZoomBubbleExtensionInfo() {} | 330 ZoomBubbleView::ZoomBubbleExtensionInfo::~ZoomBubbleExtensionInfo() {} |
OLD | NEW |