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/chrome_page_zoom.h" | 10 #include "chrome/browser/chrome_page_zoom.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 bool anchor_to_view = !is_fullscreen || | 56 bool anchor_to_view = !is_fullscreen || |
57 browser_view->immersive_mode_controller()->IsRevealed(); | 57 browser_view->immersive_mode_controller()->IsRevealed(); |
58 views::View* anchor_view = anchor_to_view ? | 58 views::View* anchor_view = anchor_to_view ? |
59 browser_view->GetLocationBarView()->zoom_view() : NULL; | 59 browser_view->GetLocationBarView()->zoom_view() : NULL; |
60 | 60 |
61 // Find the extension that initiated the zoom change, if any. | 61 // Find the extension that initiated the zoom change, if any. |
62 ZoomController* zoom_controller = | 62 ZoomController* zoom_controller = |
63 ZoomController::FromWebContents(web_contents); | 63 ZoomController::FromWebContents(web_contents); |
64 const extensions::Extension* extension = zoom_controller->last_extension(); | 64 const extensions::Extension* extension = zoom_controller->last_extension(); |
65 | 65 |
66 // If the bubble is already showing in this window, its |auto_close_| value | 66 // If the bubble is already showing in this window, its |auto_close_| value |
msw
2014/07/24 22:16:33
If you update ZoomBubbleView::OnGestureEvent as I'
vasilii
2014/07/25 15:27:43
Done.
| |
67 // is equal to |auto_close|, and the zoom change was not initiated by an | 67 // is equal to |auto_close|, and the zoom change was not initiated by an |
68 // extension, then the bubble can be reused and only the label text needs to | 68 // extension, then the bubble can be reused and only the label text needs to |
69 // be updated. | 69 // be updated. |
70 if (zoom_bubble_ && | 70 if (zoom_bubble_ && |
71 zoom_bubble_->GetAnchorView() == anchor_view && | 71 zoom_bubble_->GetAnchorView() == anchor_view && |
72 zoom_bubble_->auto_close_ == auto_close && | 72 zoom_bubble_->auto_close_ == auto_close && |
73 !extension) { | 73 !extension) { |
74 zoom_bubble_->Refresh(); | 74 zoom_bubble_->Refresh(); |
75 return; | 75 return; |
76 } | 76 } |
(...skipping 17 matching lines...) Expand all Loading... | |
94 // If we do not have an anchor view, parent the bubble to the content area. | 94 // If we do not have an anchor view, parent the bubble to the content area. |
95 if (!anchor_to_view) | 95 if (!anchor_to_view) |
96 zoom_bubble_->set_parent_window(web_contents->GetTopLevelNativeWindow()); | 96 zoom_bubble_->set_parent_window(web_contents->GetTopLevelNativeWindow()); |
97 | 97 |
98 views::BubbleDelegateView::CreateBubble(zoom_bubble_); | 98 views::BubbleDelegateView::CreateBubble(zoom_bubble_); |
99 | 99 |
100 // Adjust for fullscreen after creation as it relies on the content size. | 100 // Adjust for fullscreen after creation as it relies on the content size. |
101 if (is_fullscreen) | 101 if (is_fullscreen) |
102 zoom_bubble_->AdjustForFullscreen(browser_view->GetBoundsInScreen()); | 102 zoom_bubble_->AdjustForFullscreen(browser_view->GetBoundsInScreen()); |
103 | 103 |
104 if (zoom_bubble_->use_focusless()) | 104 if (auto_close) |
105 zoom_bubble_->GetWidget()->ShowInactive(); | 105 zoom_bubble_->GetWidget()->ShowInactive(); |
106 else | 106 else |
107 zoom_bubble_->GetWidget()->Show(); | 107 zoom_bubble_->GetWidget()->Show(); |
108 } | 108 } |
109 | 109 |
110 // static | 110 // static |
111 void ZoomBubbleView::CloseBubble() { | 111 void ZoomBubbleView::CloseBubble() { |
112 if (zoom_bubble_) | 112 if (zoom_bubble_) |
113 zoom_bubble_->Close(); | 113 zoom_bubble_->Close(); |
114 } | 114 } |
(...skipping 17 matching lines...) Expand all Loading... | |
132 FullscreenController* fullscreen_controller) | 132 FullscreenController* fullscreen_controller) |
133 : BubbleDelegateView(anchor_view, anchor_view ? | 133 : BubbleDelegateView(anchor_view, anchor_view ? |
134 views::BubbleBorder::TOP_RIGHT : views::BubbleBorder::NONE), | 134 views::BubbleBorder::TOP_RIGHT : views::BubbleBorder::NONE), |
135 image_button_(NULL), | 135 image_button_(NULL), |
136 label_(NULL), | 136 label_(NULL), |
137 web_contents_(web_contents), | 137 web_contents_(web_contents), |
138 auto_close_(auto_close), | 138 auto_close_(auto_close), |
139 immersive_mode_controller_(immersive_mode_controller) { | 139 immersive_mode_controller_(immersive_mode_controller) { |
140 // Compensate for built-in vertical padding in the anchor view's image. | 140 // Compensate for built-in vertical padding in the anchor view's image. |
141 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); | 141 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); |
142 set_use_focusless(auto_close); | |
143 set_notify_enter_exit_on_child(true); | 142 set_notify_enter_exit_on_child(true); |
144 | 143 |
145 // Add observers to close the bubble if the fullscreen state or immersive | 144 // Add observers to close the bubble if the fullscreen state or immersive |
146 // fullscreen revealed state changes. | 145 // fullscreen revealed state changes. |
147 registrar_.Add(this, | 146 registrar_.Add(this, |
148 chrome::NOTIFICATION_FULLSCREEN_CHANGED, | 147 chrome::NOTIFICATION_FULLSCREEN_CHANGED, |
149 content::Source<FullscreenController>(fullscreen_controller)); | 148 content::Source<FullscreenController>(fullscreen_controller)); |
150 immersive_mode_controller_->AddObserver(this); | 149 immersive_mode_controller_->AddObserver(this); |
151 } | 150 } |
152 | 151 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 } | 242 } |
244 | 243 |
245 void ZoomBubbleView::OnExtensionIconImageChanged( | 244 void ZoomBubbleView::OnExtensionIconImageChanged( |
246 extensions::IconImage* /* image */) { | 245 extensions::IconImage* /* image */) { |
247 image_button_->SetImage(views::Button::STATE_NORMAL, | 246 image_button_->SetImage(views::Button::STATE_NORMAL, |
248 &extension_info_.icon_image->image_skia()); | 247 &extension_info_.icon_image->image_skia()); |
249 image_button_->SchedulePaint(); | 248 image_button_->SchedulePaint(); |
250 } | 249 } |
251 | 250 |
252 void ZoomBubbleView::OnMouseEntered(const ui::MouseEvent& event) { | 251 void ZoomBubbleView::OnMouseEntered(const ui::MouseEvent& event) { |
253 set_use_focusless(false); | |
254 StopTimer(); | 252 StopTimer(); |
255 } | 253 } |
256 | 254 |
257 void ZoomBubbleView::OnMouseExited(const ui::MouseEvent& event) { | 255 void ZoomBubbleView::OnMouseExited(const ui::MouseEvent& event) { |
258 set_use_focusless(auto_close_); | |
259 StartTimerIfNecessary(); | 256 StartTimerIfNecessary(); |
260 } | 257 } |
261 | 258 |
262 void ZoomBubbleView::OnGestureEvent(ui::GestureEvent* event) { | 259 void ZoomBubbleView::OnGestureEvent(ui::GestureEvent* event) { |
263 if (!zoom_bubble_ || !zoom_bubble_->auto_close_ || | 260 if (!zoom_bubble_ || !zoom_bubble_->auto_close_ || |
264 event->type() != ui::ET_GESTURE_TAP) { | 261 event->type() != ui::ET_GESTURE_TAP) { |
265 return; | 262 return; |
266 } | 263 } |
267 | 264 |
268 // If an auto-closing bubble was tapped, show a non-auto-closing bubble in | 265 // If an auto-closing bubble was tapped, show a non-auto-closing bubble in |
msw
2014/07/24 16:52:28
This is the culprit, can this just call StopTimer
msw
2014/07/24 22:16:33
Sounds like Dan tentatively agrees with my suggest
Dan Beam
2014/07/24 23:24:51
yes
vasilii
2014/07/25 15:27:43
Done.
| |
269 // its place. | 266 // its place. |
270 ShowBubble(zoom_bubble_->web_contents_, false); | 267 ShowBubble(zoom_bubble_->web_contents_, false); |
271 event->SetHandled(); | 268 event->SetHandled(); |
272 } | 269 } |
273 | 270 |
274 void ZoomBubbleView::ButtonPressed(views::Button* sender, | 271 void ZoomBubbleView::ButtonPressed(views::Button* sender, |
275 const ui::Event& event) { | 272 const ui::Event& event) { |
276 if (sender == image_button_) { | 273 if (sender == image_button_) { |
277 DCHECK(extension_info_.icon_image) << "Invalid button press."; | 274 DCHECK(extension_info_.icon_image) << "Invalid button press."; |
278 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); | 275 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 void ZoomBubbleView::WindowClosing() { | 356 void ZoomBubbleView::WindowClosing() { |
360 // |zoom_bubble_| can be a new bubble by this point (as Close(); doesn't | 357 // |zoom_bubble_| can be a new bubble by this point (as Close(); doesn't |
361 // call this right away). Only set to NULL when it's this bubble. | 358 // call this right away). Only set to NULL when it's this bubble. |
362 if (zoom_bubble_ == this) | 359 if (zoom_bubble_ == this) |
363 zoom_bubble_ = NULL; | 360 zoom_bubble_ = NULL; |
364 } | 361 } |
365 | 362 |
366 ZoomBubbleView::ZoomBubbleExtensionInfo::ZoomBubbleExtensionInfo() {} | 363 ZoomBubbleView::ZoomBubbleExtensionInfo::ZoomBubbleExtensionInfo() {} |
367 | 364 |
368 ZoomBubbleView::ZoomBubbleExtensionInfo::~ZoomBubbleExtensionInfo() {} | 365 ZoomBubbleView::ZoomBubbleExtensionInfo::~ZoomBubbleExtensionInfo() {} |
OLD | NEW |