| 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
|
|
|