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

Side by Side Diff: chrome/browser/chromeos/login/captive_portal_window_proxy.cc

Issue 163413002: Added browser test for Captive Portal window ctor and dtor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix to CaptivePortalWindowProxy. Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/login/captive_portal_window_proxy.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/captive_portal_window_proxy.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698