Commit f1d8bce1 authored by Quan Nguyen's avatar Quan Nguyen Committed by Commit Bot

Reland "cros: Turn LoginBubble flags into a LoginBaseBubbleView member function"

This reverts commit 1f29016e.
The original CL was found not to be the culprit for the test failure.

TBR=jdufault@chromium.org

Bug: 905436
Change-Id: I750baa17c1d27a2940c3ed050c3f274fc4e8226c
Reviewed-on: https://chromium-review.googlesource.com/c/1342762Reviewed-by: default avatarQuan Nguyen <qnnguyen@chromium.org>
Commit-Queue: Quan Nguyen <qnnguyen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609369}
parent 1bd7fc0e
......@@ -697,7 +697,7 @@ void LockContentsView::OnFingerprintStateChanged(
auth_error_bubble_->ShowErrorBubble(
container, big_view->auth_user()->password_view() /*anchor_view*/,
LoginBubble::kFlagPersistent);
true /*show_persistently*/);
}
}
......@@ -816,7 +816,7 @@ void LockContentsView::OnShowWarningBanner(const base::string16& message) {
label->SetEnabledColor(SK_ColorWHITE);
warning_banner_bubble_->ShowErrorBubble(
label, CurrentBigUserView()->auth_user()->password_view() /*anchor_view*/,
LoginBubble::kFlagPersistent);
true /*show_persistently*/);
}
void LockContentsView::OnHideWarningBanner() {
......@@ -975,7 +975,7 @@ void LockContentsView::OnDetachableBasePairingStatusChanged(
detachable_base_error_bubble_->ShowErrorBubble(
label, CurrentBigUserView()->auth_user()->password_view() /*anchor_view*/,
LoginBubble::kFlagPersistent);
true /*show_persistently*/);
// Remove the focus from the password field, to make user less likely to enter
// the password without seeing the warning about detachable base change.
......@@ -1489,7 +1489,7 @@ void LockContentsView::OnBigUserChanged() {
supervised_user_deprecation_bubble_->ShowErrorBubble(
label,
CurrentBigUserView()->auth_user()->password_view() /*anchor_view*/,
LoginBubble::kFlagPersistent);
true /*show_persistently*/);
}
// The new auth user might have different last used detachable base - make
......@@ -1595,7 +1595,7 @@ void LockContentsView::ShowAuthErrorMessage() {
auth_error_bubble_->ShowErrorBubble(
container, big_view->auth_user()->password_view() /*anchor_view*/,
LoginBubble::kFlagsNone);
false /*show_persistently*/);
}
void LockContentsView::OnEasyUnlockIconHovered() {
......
......@@ -50,6 +50,10 @@ LoginButton* LoginBaseBubbleView::GetBubbleOpener() const {
return nullptr;
}
bool LoginBaseBubbleView::IsPersistent() const {
return false;
}
void LoginBaseBubbleView::OnBeforeBubbleWidgetInit(
views::Widget::InitParams* params,
views::Widget* widget) const {
......
......@@ -25,6 +25,9 @@ class ASH_EXPORT LoginBaseBubbleView : public views::BubbleDialogDelegateView {
// Returns the button responsible for opening this bubble.
virtual LoginButton* GetBubbleOpener() const;
// Returns whether or not this bubble should show persistently.
virtual bool IsPersistent() const;
// views::BubbleDialogDelegateView:
void OnBeforeBubbleWidgetInit(views::Widget::InitParams* params,
views::Widget* widget) const override;
......
......@@ -96,8 +96,10 @@ class LoginErrorBubbleView : public LoginBaseBubbleView {
public:
LoginErrorBubbleView(views::View* content,
views::View* anchor_view,
aura::Window* container)
: LoginBaseBubbleView(anchor_view, container) {
aura::Window* container,
bool show_persistently)
: LoginBaseBubbleView(anchor_view, container),
show_persistently_(show_persistently) {
set_anchor_view_insets(
gfx::Insets(kAnchorViewErrorBubbleVerticalSpacingDp, 0));
......@@ -125,6 +127,9 @@ class LoginErrorBubbleView : public LoginBaseBubbleView {
~LoginErrorBubbleView() override = default;
// LoginBaseBubbleView:
bool IsPersistent() const override { return show_persistently_; }
// views::View:
const char* GetClassName() const override { return "LoginErrorBubbleView"; }
void GetAccessibleNodeData(ui::AXNodeData* node_data) override {
......@@ -132,6 +137,8 @@ class LoginErrorBubbleView : public LoginBaseBubbleView {
}
private:
bool show_persistently_;
DISALLOW_COPY_AND_ASSIGN(LoginErrorBubbleView);
};
......@@ -453,14 +460,14 @@ LoginBubble::~LoginBubble() {
void LoginBubble::ShowErrorBubble(views::View* content,
views::View* anchor_view,
uint32_t flags) {
bool show_persistently) {
if (bubble_view_)
CloseImmediately();
flags_ = flags;
aura::Window* menu_container = Shell::GetContainer(
Shell::GetPrimaryRootWindow(), kShellWindowId_MenuContainer);
bubble_view_ = new LoginErrorBubbleView(content, anchor_view, menu_container);
bubble_view_ = new LoginErrorBubbleView(content, anchor_view, menu_container,
show_persistently);
Show();
}
......@@ -477,7 +484,6 @@ void LoginBubble::ShowUserMenu(const base::string16& username,
if (bubble_view_)
CloseImmediately();
flags_ = kFlagsNone;
bubble_view_ = new LoginUserMenuView(
this, username, email, type, is_owner, anchor_view, bubble_opener,
show_remove_user, std::move(on_remove_user_warning_shown),
......@@ -496,7 +502,6 @@ void LoginBubble::ShowTooltip(const base::string16& message,
if (bubble_view_)
CloseImmediately();
flags_ = kFlagsNone;
bubble_view_ = new LoginTooltipView(message, anchor_view);
Show();
}
......@@ -505,7 +510,6 @@ void LoginBubble::ShowSelectionMenu(LoginMenuView* menu) {
if (bubble_view_)
CloseImmediately();
flags_ = kFlagsNone;
const bool had_focus =
menu->GetBubbleOpener() && menu->GetBubbleOpener()->HasFocus();
......@@ -579,7 +583,7 @@ void LoginBubble::OnKeyEvent(ui::KeyEvent* event) {
if (bubble_view_->GetWidget()->IsActive())
return;
if (!(flags_ & kFlagPersistent)) {
if (!bubble_view_->IsPersistent()) {
Close();
}
}
......@@ -603,7 +607,7 @@ void LoginBubble::OnWindowFocused(aura::Window* gained_focus,
if (gained_focus && bubble_window->Contains(gained_focus))
return;
if (!(flags_ & kFlagPersistent))
if (!bubble_view_->IsPersistent())
Close();
}
......@@ -645,7 +649,7 @@ void LoginBubble::ProcessPressedEvent(const ui::LocatedEvent* event) {
return;
}
if (!(flags_ & kFlagPersistent))
if (!bubble_view_->IsPersistent())
Close();
}
......@@ -694,7 +698,6 @@ void LoginBubble::Reset(bool widget_already_closing) {
bubble_view_->GetWidget()->Close();
is_visible_ = false;
bubble_view_ = nullptr;
flags_ = kFlagsNone;
}
void LoginBubble::EnsureBubbleInScreen() {
......
......@@ -40,12 +40,6 @@ class ASH_EXPORT LoginBubble : public views::WidgetObserver,
static const int kUserMenuRemoveUserButtonIdForTest;
// Flags passed to ShowErrorBubble().
static constexpr uint32_t kFlagsNone = 0;
// If set, the shown error bubble will not be closed due to an unrelated user
// action - e.g. the bubble will not be closed if the user starts typing.
static constexpr uint32_t kFlagPersistent = 1 << 0;
LoginBubble();
~LoginBubble() override;
......@@ -53,7 +47,7 @@ class ASH_EXPORT LoginBubble : public views::WidgetObserver,
// |anchor_view| is the anchor for placing the bubble view.
void ShowErrorBubble(views::View* content,
views::View* anchor_view,
uint32_t flags);
bool show_persistently);
// Shows a user menu bubble.
// |anchor_view| is the anchor for placing the bubble view.
......@@ -128,9 +122,6 @@ class ASH_EXPORT LoginBubble : public views::WidgetObserver,
// Repositions the bubble view if it extends too far right or down.
void EnsureBubbleInScreen();
// Flags passed to ShowErrorBubble().
uint32_t flags_ = kFlagsNone;
LoginBaseBubbleView* bubble_view_ = nullptr;
// The status of bubble after animation ends.
......
......@@ -288,7 +288,7 @@ TEST_F(LoginBubbleTest, ErrorBubbleKeyEventHandling) {
EXPECT_FALSE(bubble_->IsVisible());
views::Label* error_text = new views::Label(base::ASCIIToUTF16("Error text"));
bubble_->ShowErrorBubble(error_text, container_, LoginBubble::kFlagsNone);
bubble_->ShowErrorBubble(error_text, container_, false /*show_persistently*/);
EXPECT_TRUE(bubble_->IsVisible());
// Verifies that key event on a view other than error closes the error bubble.
......@@ -302,7 +302,7 @@ TEST_F(LoginBubbleTest, ErrorBubbleMouseEventHandling) {
EXPECT_FALSE(bubble_->IsVisible());
views::Label* error_text = new views::Label(base::ASCIIToUTF16("Error text"));
bubble_->ShowErrorBubble(error_text, container_, LoginBubble::kFlagsNone);
bubble_->ShowErrorBubble(error_text, container_, false /*show_persistently*/);
EXPECT_TRUE(bubble_->IsVisible());
// Verifies that mouse event on the bubble itself won't close the bubble.
......@@ -322,7 +322,7 @@ TEST_F(LoginBubbleTest, ErrorBubbleGestureEventHandling) {
EXPECT_FALSE(bubble_->IsVisible());
views::Label* error_text = new views::Label(base::ASCIIToUTF16("Error text"));
bubble_->ShowErrorBubble(error_text, container_, LoginBubble::kFlagsNone);
bubble_->ShowErrorBubble(error_text, container_, false /*show_persistently*/);
EXPECT_TRUE(bubble_->IsVisible());
// Verifies that gesture event on the bubble itself won't close the bubble.
......@@ -340,8 +340,7 @@ TEST_F(LoginBubbleTest, PersistentErrorBubbleEventHandling) {
EXPECT_FALSE(bubble_->IsVisible());
views::Label* error_text = new views::Label(base::ASCIIToUTF16("Error text"));
bubble_->ShowErrorBubble(error_text, container_,
LoginBubble::kFlagPersistent);
bubble_->ShowErrorBubble(error_text, container_, true /*show_persistently*/);
EXPECT_TRUE(bubble_->IsVisible());
// Verifies that mouse event on the bubble itself won't close the bubble.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment