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

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

Issue 1018523007: ChromeOS: Do not show the error dialog when captive portal is detected in OOBE. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed browser tests. Created 5 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ui/captive_portal_window_proxy.h" 5 #include "chrome/browser/chromeos/login/ui/captive_portal_window_proxy.h"
6 6
7 #include "base/metrics/histogram_macros.h"
7 #include "chrome/browser/chromeos/login/ui/captive_portal_view.h" 8 #include "chrome/browser/chromeos/login/ui/captive_portal_view.h"
8 #include "chrome/browser/chromeos/login/ui/proxy_settings_dialog.h" 9 #include "chrome/browser/chromeos/login/ui/proxy_settings_dialog.h"
9 #include "chrome/browser/chromeos/profiles/profile_helper.h" 10 #include "chrome/browser/chromeos/profiles/profile_helper.h"
10 #include "components/web_modal/popup_manager.h" 11 #include "components/web_modal/popup_manager.h"
11 #include "ui/views/widget/widget.h" 12 #include "ui/views/widget/widget.h"
12 13
13 namespace { 14 namespace {
14 15
15 // The captive portal dialog is system-modal, but uses the web-content-modal 16 // The captive portal dialog is system-modal, but uses the web-content-modal
16 // dialog manager (odd) and requires this atypical dialog widget initialization. 17 // dialog manager (odd) and requires this atypical dialog widget initialization.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 84 }
84 85
85 void CaptivePortalWindowProxy::Close() { 86 void CaptivePortalWindowProxy::Close() {
86 if (GetState() == STATE_DISPLAYED) 87 if (GetState() == STATE_DISPLAYED)
87 widget_->Close(); 88 widget_->Close();
88 captive_portal_view_.reset(); 89 captive_portal_view_.reset();
89 captive_portal_view_for_testing_ = NULL; 90 captive_portal_view_for_testing_ = NULL;
90 } 91 }
91 92
92 void CaptivePortalWindowProxy::OnRedirected() { 93 void CaptivePortalWindowProxy::OnRedirected() {
93 if (GetState() == STATE_WAITING_FOR_REDIRECTION) 94 if (GetState() == STATE_WAITING_FOR_REDIRECTION) {
95 if (!started_loading_at_.is_null()) {
96 UMA_HISTOGRAM_TIMES("CaptivePortal.RedirectTime",
97 base::Time::Now() - started_loading_at_);
98 started_loading_at_ = base::Time();
99 }
94 Show(); 100 Show();
101 }
95 delegate_->OnPortalDetected(); 102 delegate_->OnPortalDetected();
96 } 103 }
97 104
98 void CaptivePortalWindowProxy::OnOriginalURLLoaded() { 105 void CaptivePortalWindowProxy::OnOriginalURLLoaded() {
99 Close(); 106 Close();
100 } 107 }
101 108
102 void CaptivePortalWindowProxy::OnWidgetClosing(views::Widget* widget) { 109 void CaptivePortalWindowProxy::OnWidgetClosing(views::Widget* widget) {
103 DCHECK(GetState() == STATE_DISPLAYED); 110 DCHECK(GetState() == STATE_DISPLAYED);
104 DCHECK(widget == widget_); 111 DCHECK(widget == widget_);
(...skipping 12 matching lines...) Expand all
117 } 124 }
118 125
119 void CaptivePortalWindowProxy::InitCaptivePortalView() { 126 void CaptivePortalWindowProxy::InitCaptivePortalView() {
120 DCHECK(GetState() == STATE_IDLE || 127 DCHECK(GetState() == STATE_IDLE ||
121 GetState() == STATE_WAITING_FOR_REDIRECTION); 128 GetState() == STATE_WAITING_FOR_REDIRECTION);
122 if (!captive_portal_view_.get()) { 129 if (!captive_portal_view_.get()) {
123 captive_portal_view_.reset( 130 captive_portal_view_.reset(
124 new CaptivePortalView(ProfileHelper::GetSigninProfile(), this)); 131 new CaptivePortalView(ProfileHelper::GetSigninProfile(), this));
125 captive_portal_view_for_testing_ = captive_portal_view_.get(); 132 captive_portal_view_for_testing_ = captive_portal_view_.get();
126 } 133 }
134
135 started_loading_at_ = base::Time::Now();
127 captive_portal_view_->StartLoad(); 136 captive_portal_view_->StartLoad();
128 } 137 }
129 138
130 CaptivePortalWindowProxy::State CaptivePortalWindowProxy::GetState() const { 139 CaptivePortalWindowProxy::State CaptivePortalWindowProxy::GetState() const {
131 if (widget_ == NULL) { 140 if (widget_ == NULL) {
132 if (captive_portal_view_.get() == NULL) 141 if (captive_portal_view_.get() == NULL)
133 return STATE_IDLE; 142 return STATE_IDLE;
134 else 143 else
135 return STATE_WAITING_FOR_REDIRECTION; 144 return STATE_WAITING_FOR_REDIRECTION;
136 } else { 145 } else {
137 if (captive_portal_view_.get() == NULL) 146 if (captive_portal_view_.get() == NULL)
138 return STATE_DISPLAYED; 147 return STATE_DISPLAYED;
139 else 148 else
140 NOTREACHED(); 149 NOTREACHED();
141 } 150 }
142 return STATE_UNKNOWN; 151 return STATE_UNKNOWN;
143 } 152 }
144 153
145 void CaptivePortalWindowProxy::DetachFromWidget(views::Widget* widget) { 154 void CaptivePortalWindowProxy::DetachFromWidget(views::Widget* widget) {
146 if (!widget_ || widget_ != widget) 155 if (!widget_ || widget_ != widget)
147 return; 156 return;
148 widget_->RemoveObserver(this); 157 widget_->RemoveObserver(this);
149 widget_ = NULL; 158 widget_ = NULL;
150 } 159 }
151 160
152 } // namespace chromeos 161 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/ui/captive_portal_window_proxy.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698