Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: chrome/browser/ui/views/location_bar/zoom_bubble_view.cc

Issue 413433002: Refactor BubbleDelegateView::use_focuseless() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cros compilation Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
77 77
78 // If the bubble is already showing but its |auto_close_| value is not equal 78 // If the bubble is already showing but its |auto_close_| value is not equal
msw 2014/07/23 18:57:00 I wonder if this is still true/necessary?
Dan Beam 2014/07/23 23:03:34 this only happens on ctrl+ and a click on the zoom
vasilii 2014/07/24 16:32:13 I reproduced this case.
msw 2014/07/24 16:52:27 Why do we need to recreate the bubble on click aft
79 // to |auto_close|, the bubble's focus properties must change, so the 79 // to |auto_close|, the bubble's focus properties must change, so the
80 // current bubble must be closed and a new one created. 80 // current bubble must be closed and a new one created.
81 CloseBubble(); 81 CloseBubble();
82 82
83 zoom_bubble_ = new ZoomBubbleView(anchor_view, 83 zoom_bubble_ = new ZoomBubbleView(anchor_view,
84 web_contents, 84 web_contents,
85 auto_close, 85 auto_close,
86 browser_view->immersive_mode_controller(), 86 browser_view->immersive_mode_controller(),
87 browser->fullscreen_controller()); 87 browser->fullscreen_controller());
88 88
89 // If the zoom change was initiated by an extension, capture the relevent 89 // If the zoom change was initiated by an extension, capture the relevent
90 // information from it. 90 // information from it.
91 if (extension) 91 if (extension)
92 zoom_bubble_->SetExtensionInfo(extension); 92 zoom_bubble_->SetExtensionInfo(extension);
93 93
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 (zoom_bubble_->can_activate())
msw 2014/07/23 18:57:00 nit: I think this can just call Show and it'll res
Dan Beam 2014/07/23 23:03:34 the last time i checked, can_active() { return fal
vasilii 2014/07/24 16:32:14 This line is my typo for sure. Dan, I touched this
105 zoom_bubble_->GetWidget()->Show();
106 else
105 zoom_bubble_->GetWidget()->ShowInactive(); 107 zoom_bubble_->GetWidget()->ShowInactive();
106 else
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 }
115 115
116 // static 116 // static
117 bool ZoomBubbleView::IsShowing() { 117 bool ZoomBubbleView::IsShowing() {
(...skipping 14 matching lines...) Expand all
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);
msw 2014/07/23 18:57:00 You've removed all the calls to set_use_focusless
Dan Beam 2014/07/23 23:03:34 correct, ctrl+/- should not move focus away from t
vasilii 2014/07/24 16:32:13 ctrl+ doesn't remove focus, I checked manually.
Dan Beam 2014/07/24 23:24:51 did you check on linux chromeos, linux aura, and w
vasilii 2014/07/25 15:27:43 Yeah.
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
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
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
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() {}
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/autofill/tooltip_icon.cc ('k') | chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698