summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvasilii@chromium.org <vasilii@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-25 21:21:48 +0000
committervasilii@chromium.org <vasilii@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-25 21:21:48 +0000
commit2fe3a1258097951bc015142effb37c38cdc65567 (patch)
treea2676bd36cb8fd5c5cc1db39947262762f52d09e
parent401c9dc414cd708d53ced5d884f8eb3a8b4bcbe5 (diff)
downloadchromium_src-2fe3a1258097951bc015142effb37c38cdc65567.zip
chromium_src-2fe3a1258097951bc015142effb37c38cdc65567.tar.gz
chromium_src-2fe3a1258097951bc015142effb37c38cdc65567.tar.bz2
Refactor BubbleDelegateView::use_focuseless().
It's confusing because it prevents the bubble activation. As a side effect on Windows the bubble doesn't get LBUTTON_DOWN messages. The reason for that is in HWNDMessageHandler::OnMouseActivate(). It asks the bubble if it can be activated. It answers "no" due to implementation in BubbleDelegateView::CanActivate(). Windows gets MA_NOACTIVATEANDEAT and MouseDown event isn't dispatched. This is definitely unexpected. The bubbles which indeed always inactive should use set_can_activate(false) at construction time. The bubbles which can be active but created without focus by default should use ShowInactive() instead. BUG=392734 Review URL: https://codereview.chromium.org/413433002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285682 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/ime/candidate_window_view.cc2
-rw-r--r--ash/ime/infolist_window.cc2
-rw-r--r--ash/ime/mode_indicator_view.cc2
-rw-r--r--ash/popup_message.cc2
-rw-r--r--ash/shelf/overflow_bubble_view.cc2
-rw-r--r--ash/shelf/shelf_tooltip_manager.cc2
-rw-r--r--ash/system/chromeos/network/network_state_list_detailed_view.cc4
-rw-r--r--ash/wm/immersive_fullscreen_controller_unittest.cc4
-rw-r--r--chrome/browser/ui/views/autofill/info_bubble.cc2
-rw-r--r--chrome/browser/ui/views/autofill/tooltip_icon.cc2
-rw-r--r--chrome/browser/ui/views/location_bar/zoom_bubble_view.cc23
-rw-r--r--chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc10
-rw-r--r--chrome/browser/ui/views/validation_message_bubble_delegate.cc2
-rw-r--r--ui/views/bubble/bubble_delegate.cc6
-rw-r--r--ui/views/bubble/bubble_delegate.h8
-rw-r--r--ui/views/touchui/touch_editing_menu.cc2
16 files changed, 29 insertions, 46 deletions
diff --git a/ash/ime/candidate_window_view.cc b/ash/ime/candidate_window_view.cc
index c759390..7cd7107 100644
--- a/ash/ime/candidate_window_view.cc
+++ b/ash/ime/candidate_window_view.cc
@@ -148,7 +148,7 @@ CandidateWindowView::CandidateWindowView(gfx::NativeView parent)
should_show_at_composition_head_(false),
should_show_upper_side_(false),
was_candidate_window_open_(false) {
- set_use_focusless(true);
+ set_can_activate(false);
set_parent_window(parent);
set_margins(gfx::Insets());
diff --git a/ash/ime/infolist_window.cc b/ash/ime/infolist_window.cc
index d29ed2a..f529948 100644
--- a/ash/ime/infolist_window.cc
+++ b/ash/ime/infolist_window.cc
@@ -172,7 +172,7 @@ InfolistWindow::InfolistWindow(views::View* candidate_window,
title_font_list_(gfx::Font(kJapaneseFontName, kFontSizeDelta + 15)),
description_font_list_(gfx::Font(kJapaneseFontName,
kFontSizeDelta + 11)) {
- set_use_focusless(true);
+ set_can_activate(false);
set_accept_events(false);
set_margins(gfx::Insets());
diff --git a/ash/ime/mode_indicator_view.cc b/ash/ime/mode_indicator_view.cc
index 117d6c4..e0c6f2f 100644
--- a/ash/ime/mode_indicator_view.cc
+++ b/ash/ime/mode_indicator_view.cc
@@ -48,7 +48,7 @@ ModeIndicatorView::ModeIndicatorView(gfx::NativeView parent,
const base::string16& label)
: cursor_bounds_(cursor_bounds),
label_view_(new views::Label(label)) {
- set_use_focusless(true);
+ set_can_activate(false);
set_accept_events(false);
set_parent_window(parent);
set_shadow(views::BubbleBorder::NO_SHADOW);
diff --git a/ash/popup_message.cc b/ash/popup_message.cc
index b83ba91..4696e81 100644
--- a/ash/popup_message.cc
+++ b/ash/popup_message.cc
@@ -84,7 +84,7 @@ PopupMessage::MessageBubble::MessageBubble(const base::string16& caption,
set_anchor_view_insets(insets);
set_close_on_esc(false);
set_close_on_deactivate(false);
- set_use_focusless(true);
+ set_can_activate(false);
set_accept_events(false);
set_margins(gfx::Insets(kMessageTopBottomMargin, kMessageLeftRightMargin,
diff --git a/ash/shelf/overflow_bubble_view.cc b/ash/shelf/overflow_bubble_view.cc
index 73b6477..2f3595f 100644
--- a/ash/shelf/overflow_bubble_view.cc
+++ b/ash/shelf/overflow_bubble_view.cc
@@ -50,7 +50,7 @@ void OverflowBubbleView::InitOverflowBubble(views::View* anchor,
set_margins(gfx::Insets(kPadding, kPadding, kPadding, kPadding));
// Overflow bubble should not get focus. If it get focus when it is shown,
// active state item is changed to running state.
- set_use_focusless(true);
+ set_can_activate(false);
// Makes bubble view has a layer and clip its children layers.
SetPaintToLayer(true);
diff --git a/ash/shelf/shelf_tooltip_manager.cc b/ash/shelf/shelf_tooltip_manager.cc
index b4e1d34..4ba6165 100644
--- a/ash/shelf/shelf_tooltip_manager.cc
+++ b/ash/shelf/shelf_tooltip_manager.cc
@@ -85,7 +85,7 @@ ShelfTooltipManager::ShelfTooltipBubble::ShelfTooltipBubble(
set_anchor_view_insets(insets);
set_close_on_esc(false);
set_close_on_deactivate(false);
- set_use_focusless(true);
+ set_can_activate(false);
set_accept_events(false);
set_margins(gfx::Insets(kTooltipTopBottomMargin, kTooltipLeftRightMargin,
kTooltipTopBottomMargin, kTooltipLeftRightMargin));
diff --git a/ash/system/chromeos/network/network_state_list_detailed_view.cc b/ash/system/chromeos/network/network_state_list_detailed_view.cc
index 3cdbe7c..ed8a6e2 100644
--- a/ash/system/chromeos/network/network_state_list_detailed_view.cc
+++ b/ash/system/chromeos/network/network_state_list_detailed_view.cc
@@ -94,7 +94,7 @@ class NetworkStateListDetailedView::InfoBubble
NetworkStateListDetailedView* detailed_view)
: views::BubbleDelegateView(anchor, views::BubbleBorder::TOP_RIGHT),
detailed_view_(detailed_view) {
- set_use_focusless(true);
+ set_can_activate(false);
set_parent_window(ash::Shell::GetContainer(
anchor->GetWidget()->GetNativeWindow()->GetRootWindow(),
ash::kShellWindowId_SettingBubbleContainer));
@@ -106,8 +106,6 @@ class NetworkStateListDetailedView::InfoBubble
detailed_view_->OnInfoBubbleDestroyed();
}
- virtual bool CanActivate() const OVERRIDE { return false; }
-
private:
// Not owned.
NetworkStateListDetailedView* detailed_view_;
diff --git a/ash/wm/immersive_fullscreen_controller_unittest.cc b/ash/wm/immersive_fullscreen_controller_unittest.cc
index 8868689..0ba623f 100644
--- a/ash/wm/immersive_fullscreen_controller_unittest.cc
+++ b/ash/wm/immersive_fullscreen_controller_unittest.cc
@@ -967,14 +967,14 @@ TEST_F(ImmersiveFullscreenControllerTest, Bubbles) {
views::BubbleDelegateView* bubble_delegate4(new views::BubbleDelegateView(
child_view, views::BubbleBorder::NONE));
- bubble_delegate4->set_use_focusless(true);
+ bubble_delegate4->set_can_activate(false);
views::Widget* bubble_widget4(views::BubbleDelegateView::CreateBubble(
bubble_delegate4));
bubble_widget4->Show();
views::BubbleDelegateView* bubble_delegate5(new views::BubbleDelegateView(
child_view, views::BubbleBorder::NONE));
- bubble_delegate5->set_use_focusless(true);
+ bubble_delegate5->set_can_activate(false);
views::Widget* bubble_widget5(views::BubbleDelegateView::CreateBubble(
bubble_delegate5));
bubble_widget5->Show();
diff --git a/chrome/browser/ui/views/autofill/info_bubble.cc b/chrome/browser/ui/views/autofill/info_bubble.cc
index 5337093..c4f07dd 100644
--- a/chrome/browser/ui/views/autofill/info_bubble.cc
+++ b/chrome/browser/ui/views/autofill/info_bubble.cc
@@ -65,7 +65,7 @@ InfoBubble::InfoBubble(views::View* anchor,
kInfoBubbleHorizontalMargin,
kInfoBubbleVerticalMargin,
kInfoBubbleHorizontalMargin));
- set_use_focusless(true);
+ set_can_activate(false);
SetLayoutManager(new views::FillLayout);
views::Label* label = new views::Label(message);
diff --git a/chrome/browser/ui/views/autofill/tooltip_icon.cc b/chrome/browser/ui/views/autofill/tooltip_icon.cc
index 92f8e43..c066ea0 100644
--- a/chrome/browser/ui/views/autofill/tooltip_icon.cc
+++ b/chrome/browser/ui/views/autofill/tooltip_icon.cc
@@ -114,7 +114,7 @@ void TooltipIcon::ShowBubble() {
bubble_ = new TooltipBubble(this, tooltip_);
// When shown due to a gesture event, close on deactivate (i.e. don't use
// "focusless").
- bubble_->set_use_focusless(mouse_inside_);
+ bubble_->set_can_activate(!mouse_inside_);
bubble_->Show();
observer_.Add(bubble_->GetWidget());
diff --git a/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc b/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc
index 3ab1d2f..e1298bb 100644
--- a/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc
+++ b/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc
@@ -63,21 +63,18 @@ void ZoomBubbleView::ShowBubble(content::WebContents* web_contents,
ZoomController::FromWebContents(web_contents);
const extensions::Extension* extension = zoom_controller->last_extension();
- // If the bubble is already showing in this window, its |auto_close_| value
- // is equal to |auto_close|, and the zoom change was not initiated by an
- // extension, then the bubble can be reused and only the label text needs to
- // be updated.
+ // If the bubble is already showing in this window and the zoom change was not
+ // initiated by an extension, then the bubble can be reused and only the label
+ // text needs to be updated.
if (zoom_bubble_ &&
zoom_bubble_->GetAnchorView() == anchor_view &&
- zoom_bubble_->auto_close_ == auto_close &&
!extension) {
zoom_bubble_->Refresh();
return;
}
- // If the bubble is already showing but its |auto_close_| value is not equal
- // to |auto_close|, the bubble's focus properties must change, so the
- // current bubble must be closed and a new one created.
+ // If the bubble is already showing but in a different tab, the current
+ // bubble must be closed and a new one created.
CloseBubble();
zoom_bubble_ = new ZoomBubbleView(anchor_view,
@@ -101,7 +98,7 @@ void ZoomBubbleView::ShowBubble(content::WebContents* web_contents,
if (is_fullscreen)
zoom_bubble_->AdjustForFullscreen(browser_view->GetBoundsInScreen());
- if (zoom_bubble_->use_focusless())
+ if (auto_close)
zoom_bubble_->GetWidget()->ShowInactive();
else
zoom_bubble_->GetWidget()->Show();
@@ -139,7 +136,6 @@ ZoomBubbleView::ZoomBubbleView(
immersive_mode_controller_(immersive_mode_controller) {
// Compensate for built-in vertical padding in the anchor view's image.
set_anchor_view_insets(gfx::Insets(5, 0, 5, 0));
- set_use_focusless(auto_close);
set_notify_enter_exit_on_child(true);
// Add observers to close the bubble if the fullscreen state or immersive
@@ -250,12 +246,10 @@ void ZoomBubbleView::OnExtensionIconImageChanged(
}
void ZoomBubbleView::OnMouseEntered(const ui::MouseEvent& event) {
- set_use_focusless(false);
StopTimer();
}
void ZoomBubbleView::OnMouseExited(const ui::MouseEvent& event) {
- set_use_focusless(auto_close_);
StartTimerIfNecessary();
}
@@ -265,9 +259,8 @@ void ZoomBubbleView::OnGestureEvent(ui::GestureEvent* event) {
return;
}
- // If an auto-closing bubble was tapped, show a non-auto-closing bubble in
- // its place.
- ShowBubble(zoom_bubble_->web_contents_, false);
+ auto_close_ = false;
+ StopTimer();
event->SetHandled();
}
diff --git a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc
index 7a5dac3..27974f3 100644
--- a/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc
+++ b/chrome/browser/ui/views/passwords/manage_passwords_bubble_view.cc
@@ -538,13 +538,7 @@ void ManagePasswordsBubbleView::ShowBubble(content::WebContents* web_contents,
manage_passwords_bubble_->AdjustForFullscreen(
browser_view->GetBoundsInScreen());
}
- manage_passwords_bubble_->GetWidget()->Show();
- // set_use_focusless(true) has adverse effect on Windows.
- // 1) The bubble can't be the active window (which is not desired behavior).
- // 2) The bubble doesn't get WM_LBUTTONDOWN event. Therefore, all the buttons
- // get stuck.
- // TODO(vasilii): remove this line once the bug in infrastructure is resolved.
- manage_passwords_bubble_->set_use_focusless(false);
+ manage_passwords_bubble_->GetWidget()->ShowInactive();
}
// static
@@ -572,8 +566,6 @@ ManagePasswordsBubbleView::ManagePasswordsBubbleView(
never_save_passwords_(false) {
// Compensate for built-in vertical padding in the anchor view's image.
set_anchor_view_insets(gfx::Insets(5, 0, 5, 0));
- // Don't focus by default.
- set_use_focusless(true);
if (anchor_view)
anchor_view->SetActive(true);
}
diff --git a/chrome/browser/ui/views/validation_message_bubble_delegate.cc b/chrome/browser/ui/views/validation_message_bubble_delegate.cc
index 0e857fa..ea79333 100644
--- a/chrome/browser/ui/views/validation_message_bubble_delegate.cc
+++ b/chrome/browser/ui/views/validation_message_bubble_delegate.cc
@@ -24,7 +24,7 @@ ValidationMessageBubbleDelegate::ValidationMessageBubbleDelegate(
const base::string16& sub_text,
Observer* observer)
: observer_(observer), width_(0), height_(0) {
- set_use_focusless(true);
+ set_can_activate(false);
set_arrow(views::BubbleBorder::TOP_LEFT);
SetAnchorRect(anchor_in_screen);
diff --git a/ui/views/bubble/bubble_delegate.cc b/ui/views/bubble/bubble_delegate.cc
index 0eab071..b52f95b 100644
--- a/ui/views/bubble/bubble_delegate.cc
+++ b/ui/views/bubble/bubble_delegate.cc
@@ -54,7 +54,7 @@ BubbleDelegateView::BubbleDelegateView()
shadow_(BubbleBorder::SMALL_SHADOW),
color_explicitly_set_(false),
margins_(kDefaultMargin, kDefaultMargin, kDefaultMargin, kDefaultMargin),
- use_focusless_(false),
+ can_activate_(true),
accept_events_(true),
border_accepts_events_(true),
adjust_if_offscreen_(true),
@@ -74,7 +74,7 @@ BubbleDelegateView::BubbleDelegateView(
shadow_(BubbleBorder::SMALL_SHADOW),
color_explicitly_set_(false),
margins_(kDefaultMargin, kDefaultMargin, kDefaultMargin, kDefaultMargin),
- use_focusless_(false),
+ can_activate_(true),
accept_events_(true),
border_accepts_events_(true),
adjust_if_offscreen_(true),
@@ -118,7 +118,7 @@ BubbleDelegateView* BubbleDelegateView::AsBubbleDelegate() {
}
bool BubbleDelegateView::CanActivate() const {
- return !use_focusless();
+ return can_activate();
}
bool BubbleDelegateView::ShouldShowCloseButton() const {
diff --git a/ui/views/bubble/bubble_delegate.h b/ui/views/bubble/bubble_delegate.h
index e61111b..98b4ea2 100644
--- a/ui/views/bubble/bubble_delegate.h
+++ b/ui/views/bubble/bubble_delegate.h
@@ -83,8 +83,8 @@ class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView,
gfx::NativeView parent_window() const { return parent_window_; }
void set_parent_window(gfx::NativeView window) { parent_window_ = window; }
- bool use_focusless() const { return use_focusless_; }
- void set_use_focusless(bool focusless) { use_focusless_ = focusless; }
+ bool can_activate() const { return can_activate_; }
+ void set_can_activate(bool focusless) { can_activate_ = focusless; }
bool accept_events() const { return accept_events_; }
void set_accept_events(bool accept_events) { accept_events_ = accept_events; }
@@ -183,8 +183,8 @@ class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView,
// Insets applied to the |anchor_view_| bounds.
gfx::Insets anchor_view_insets_;
- // If true, the bubble does not take focus on display; default is false.
- bool use_focusless_;
+ // If false, the bubble can't be activated; default is true.
+ bool can_activate_;
// Specifies whether the bubble (or its border) handles mouse events, etc.
bool accept_events_;
diff --git a/ui/views/touchui/touch_editing_menu.cc b/ui/views/touchui/touch_editing_menu.cc
index b17039c..850bdb1 100644
--- a/ui/views/touchui/touch_editing_menu.cc
+++ b/ui/views/touchui/touch_editing_menu.cc
@@ -47,7 +47,7 @@ TouchEditingMenuView::TouchEditingMenuView(
set_shadow(views::BubbleBorder::SMALL_SHADOW);
set_parent_window(context);
set_margins(gfx::Insets(kMenuMargin, kMenuMargin, kMenuMargin, kMenuMargin));
- set_use_focusless(true);
+ set_can_activate(false);
set_adjust_if_offscreen(true);
SetLayoutManager(new BoxLayout(BoxLayout::kHorizontal, 0, 0,