| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/login/captive_portal_window_proxy.h" | 5 #include "chrome/browser/chromeos/login/captive_portal_window_proxy.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/login/captive_portal_view.h" | 7 #include "chrome/browser/chromeos/login/captive_portal_view.h" |
| 8 #include "chrome/browser/chromeos/login/proxy_settings_dialog.h" | 8 #include "chrome/browser/chromeos/login/proxy_settings_dialog.h" |
| 9 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 9 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 10 #include "components/web_modal/web_contents_modal_dialog_host.h" | 10 #include "components/web_modal/web_contents_modal_dialog_host.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 83 } |
| 84 | 84 |
| 85 void CaptivePortalWindowProxy::OnOriginalURLLoaded() { | 85 void CaptivePortalWindowProxy::OnOriginalURLLoaded() { |
| 86 Close(); | 86 Close(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void CaptivePortalWindowProxy::OnWidgetClosing(views::Widget* widget) { | 89 void CaptivePortalWindowProxy::OnWidgetClosing(views::Widget* widget) { |
| 90 DCHECK(GetState() == STATE_DISPLAYED); | 90 DCHECK(GetState() == STATE_DISPLAYED); |
| 91 DCHECK(widget == widget_); | 91 DCHECK(widget == widget_); |
| 92 | 92 |
| 93 widget->RemoveObserver(this); | 93 DetachFromWidget(widget); |
| 94 widget_ = NULL; | |
| 95 | 94 |
| 96 DCHECK(GetState() == STATE_IDLE); | 95 DCHECK(GetState() == STATE_IDLE); |
| 97 } | 96 } |
| 98 | 97 |
| 98 void CaptivePortalWindowProxy::OnWidgetDestroying(views::Widget* widget) { |
| 99 DetachFromWidget(widget); |
| 100 } |
| 101 |
| 102 void CaptivePortalWindowProxy::OnWidgetDestroyed(views::Widget* widget) { |
| 103 DetachFromWidget(widget); |
| 104 } |
| 105 |
| 99 void CaptivePortalWindowProxy::InitCaptivePortalView() { | 106 void CaptivePortalWindowProxy::InitCaptivePortalView() { |
| 100 DCHECK(GetState() == STATE_IDLE || | 107 DCHECK(GetState() == STATE_IDLE || |
| 101 GetState() == STATE_WAITING_FOR_REDIRECTION); | 108 GetState() == STATE_WAITING_FOR_REDIRECTION); |
| 102 if (!captive_portal_view_.get()) { | 109 if (!captive_portal_view_.get()) { |
| 103 captive_portal_view_.reset( | 110 captive_portal_view_.reset( |
| 104 new CaptivePortalView(ProfileHelper::GetSigninProfile(), this)); | 111 new CaptivePortalView(ProfileHelper::GetSigninProfile(), this)); |
| 105 } | 112 } |
| 106 captive_portal_view_->StartLoad(); | 113 captive_portal_view_->StartLoad(); |
| 107 } | 114 } |
| 108 | 115 |
| 109 CaptivePortalWindowProxy::State CaptivePortalWindowProxy::GetState() const { | 116 CaptivePortalWindowProxy::State CaptivePortalWindowProxy::GetState() const { |
| 110 if (widget_ == NULL) { | 117 if (widget_ == NULL) { |
| 111 if (captive_portal_view_.get() == NULL) | 118 if (captive_portal_view_.get() == NULL) |
| 112 return STATE_IDLE; | 119 return STATE_IDLE; |
| 113 else | 120 else |
| 114 return STATE_WAITING_FOR_REDIRECTION; | 121 return STATE_WAITING_FOR_REDIRECTION; |
| 115 } else { | 122 } else { |
| 116 if (captive_portal_view_.get() == NULL) | 123 if (captive_portal_view_.get() == NULL) |
| 117 return STATE_DISPLAYED; | 124 return STATE_DISPLAYED; |
| 118 else | 125 else |
| 119 NOTREACHED(); | 126 NOTREACHED(); |
| 120 } | 127 } |
| 121 return STATE_UNKNOWN; | 128 return STATE_UNKNOWN; |
| 122 } | 129 } |
| 123 | 130 |
| 131 void CaptivePortalWindowProxy::DetachFromWidget(views::Widget* widget) { |
| 132 if (!widget_ || widget_ != widget) |
| 133 return; |
| 134 widget_->RemoveObserver(this); |
| 135 widget_ = NULL; |
| 136 } |
| 137 |
| 124 } // namespace chromeos | 138 } // namespace chromeos |
| OLD | NEW |