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

cros: Call OnAfterCaptivePortalHidden only after widget is destroyed

This CL fixes the case where displaying the captive portal view and then
closing it would break the Gaia screen email input, preventing users from
typing into the box.

Bug: 881498
Change-Id: Id79795566fbb4355be7954edc34929ee4cccd524
Reviewed-on: https://chromium-review.googlesource.com/1222314Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Quan Nguyen <qnnguyen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#591386}
parent 82dff59b
...@@ -103,6 +103,8 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalWindowTest, ShowClose) { ...@@ -103,6 +103,8 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalWindowTest, ShowClose) {
CheckState(true, 0); CheckState(true, 0);
Close(); Close();
// Wait for widget to be destroyed
base::RunLoop().RunUntilIdle();
CheckState(false, 0); CheckState(false, 0);
} }
...@@ -116,6 +118,8 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalWindowTest, OnRedirected) { ...@@ -116,6 +118,8 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalWindowTest, OnRedirected) {
CheckState(true, 1); CheckState(true, 1);
Close(); Close();
// Wait for widget to be destroyed
base::RunLoop().RunUntilIdle();
CheckState(false, 1); CheckState(false, 1);
} }
...@@ -129,6 +133,8 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalWindowTest, OnOriginalURLLoaded) { ...@@ -129,6 +133,8 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalWindowTest, OnOriginalURLLoaded) {
CheckState(true, 1); CheckState(true, 1);
OnOriginalURLLoaded(); OnOriginalURLLoaded();
// Wait for widget to be destroyed
base::RunLoop().RunUntilIdle();
CheckState(false, 1); CheckState(false, 1);
} }
...@@ -142,12 +148,16 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalWindowTest, MultipleCalls) { ...@@ -142,12 +148,16 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalWindowTest, MultipleCalls) {
CheckState(true, 0); CheckState(true, 0);
Close(); Close();
// Wait for widget to be destroyed
base::RunLoop().RunUntilIdle();
CheckState(false, 0); CheckState(false, 0);
OnRedirected(); OnRedirected();
CheckState(false, 1); CheckState(false, 1);
OnOriginalURLLoaded(); OnOriginalURLLoaded();
// Wait for widget to be destroyed
base::RunLoop().RunUntilIdle();
CheckState(false, 1); CheckState(false, 1);
Show(); Show();
...@@ -157,6 +167,8 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalWindowTest, MultipleCalls) { ...@@ -157,6 +167,8 @@ IN_PROC_BROWSER_TEST_F(CaptivePortalWindowTest, MultipleCalls) {
CheckState(true, 2); CheckState(true, 2);
Close(); Close();
// Wait for widget to be destroyed
base::RunLoop().RunUntilIdle();
CheckState(false, 2); CheckState(false, 2);
OnOriginalURLLoaded(); OnOriginalURLLoaded();
......
...@@ -93,9 +93,6 @@ void CaptivePortalWindowProxy::Close() { ...@@ -93,9 +93,6 @@ void CaptivePortalWindowProxy::Close() {
widget_->Close(); widget_->Close();
captive_portal_view_.reset(); captive_portal_view_.reset();
captive_portal_view_for_testing_ = NULL; captive_portal_view_for_testing_ = NULL;
for (auto& observer : observers_)
observer.OnAfterCaptivePortalHidden();
} }
void CaptivePortalWindowProxy::OnRedirected() { void CaptivePortalWindowProxy::OnRedirected() {
...@@ -122,24 +119,16 @@ void CaptivePortalWindowProxy::RemoveObserver(Observer* observer) { ...@@ -122,24 +119,16 @@ void CaptivePortalWindowProxy::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer); observers_.RemoveObserver(observer);
} }
void CaptivePortalWindowProxy::OnWidgetClosing(views::Widget* widget) { void CaptivePortalWindowProxy::OnWidgetDestroyed(views::Widget* widget) {
DCHECK(GetState() == STATE_DISPLAYED); DCHECK(GetState() == STATE_DISPLAYED);
DCHECK(widget == widget_); DCHECK(widget == widget_);
DetachFromWidget(widget); DetachFromWidget(widget);
for (auto& observer : observers_)
observer.OnAfterCaptivePortalHidden();
DCHECK(GetState() == STATE_IDLE); DCHECK(GetState() == STATE_IDLE);
}
void CaptivePortalWindowProxy::OnWidgetDestroying(views::Widget* widget) { for (auto& observer : observers_)
DetachFromWidget(widget); observer.OnAfterCaptivePortalHidden();
}
void CaptivePortalWindowProxy::OnWidgetDestroyed(views::Widget* widget) {
DetachFromWidget(widget);
} }
void CaptivePortalWindowProxy::InitCaptivePortalView() { void CaptivePortalWindowProxy::InitCaptivePortalView() {
......
...@@ -83,8 +83,6 @@ class CaptivePortalWindowProxy : public views::WidgetObserver { ...@@ -83,8 +83,6 @@ class CaptivePortalWindowProxy : public views::WidgetObserver {
void RemoveObserver(Observer* observer); void RemoveObserver(Observer* observer);
// Overridden from views::WidgetObserver: // Overridden from views::WidgetObserver:
void OnWidgetClosing(views::Widget* widget) override;
void OnWidgetDestroying(views::Widget* widget) override;
void OnWidgetDestroyed(views::Widget* widget) override; void OnWidgetDestroyed(views::Widget* widget) override;
private: private:
......
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