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

Unified Diff: chrome/browser/chromeos/login/captive_portal_window_proxy.cc

Issue 15780006: Added bowser test for Captive Portal Window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added captive_portal_window_borwsertest.cc to git index. Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/captive_portal_window_proxy.cc
diff --git a/chrome/browser/chromeos/login/captive_portal_window_proxy.cc b/chrome/browser/chromeos/login/captive_portal_window_proxy.cc
index 28c376d2f9b85aa8acb46e069ec5fc88e778bfd7..3cbc8d1ba64fb79a93aeea88e2c3afb0d41a85d6 100644
--- a/chrome/browser/chromeos/login/captive_portal_window_proxy.cc
+++ b/chrome/browser/chromeos/login/captive_portal_window_proxy.cc
@@ -26,31 +26,21 @@ CaptivePortalWindowProxy::CaptivePortalWindowProxy(Delegate* delegate,
}
CaptivePortalWindowProxy::~CaptivePortalWindowProxy() {
- if (widget_) {
+ if (IsShown()) {
widget_->RemoveObserver(this);
widget_->Close();
}
}
void CaptivePortalWindowProxy::ShowIfRedirected() {
- if (widget_) {
+ if (IsShown()) {
// Invalid state as when widget is created (Show())
// CaptivePortalView ownership is transferred to it.
- if (captive_portal_view_.get()) {
- NOTREACHED();
- }
+ DCHECK(!captive_portal_view_.get());
// Dialog is already shown, no need to reload.
return;
}
-
- // Dialog is not initialized yet.
- if (!captive_portal_view_.get()) {
- captive_portal_view_.reset(
- new CaptivePortalView(ProfileHelper::GetSigninProfile(), this));
- }
-
- // If dialog has been created (but not shown) previously, force reload.
- captive_portal_view_->StartLoad();
+ InitCaptivePortalView();
}
void CaptivePortalWindowProxy::Show() {
@@ -60,10 +50,10 @@ void CaptivePortalWindowProxy::Show() {
return;
}
- if (!captive_portal_view_.get() || widget_) {
- // Dialog is already shown, do nothing.
+ if (IsShown()) // Dialog is already shown, do nothing.
return;
- }
+
+ InitCaptivePortalView();
CaptivePortalView* captive_portal_view = captive_portal_view_.release();
widget_ = views::Widget::CreateWindowWithParent(
@@ -80,11 +70,10 @@ void CaptivePortalWindowProxy::Show() {
}
void CaptivePortalWindowProxy::Close() {
- if (widget_) {
+ if (IsShown())
widget_->Close();
- } else {
+ else
captive_portal_view_.reset();
- }
}
void CaptivePortalWindowProxy::OnRedirected() {
@@ -96,11 +85,23 @@ void CaptivePortalWindowProxy::OnOriginalURLLoaded() {
Close();
}
-void CaptivePortalWindowProxy::OnWidgetDestroying(views::Widget* widget) {
+void CaptivePortalWindowProxy::OnWidgetClosing(views::Widget* widget) {
DCHECK(widget == widget_);
DCHECK(captive_portal_view_.get() == NULL);
widget->RemoveObserver(this);
widget_ = NULL;
}
+void CaptivePortalWindowProxy::InitCaptivePortalView() {
+ if (!captive_portal_view_.get()) {
+ captive_portal_view_.reset(
+ new CaptivePortalView(ProfileHelper::GetSigninProfile(), this));
+ }
+ captive_portal_view_->StartLoad();
+}
+
+bool CaptivePortalWindowProxy::IsShown() const {
+ return widget_ != NULL;
+}
+
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698