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

Side by Side Diff: chrome/browser/chromeos/login/enrollment/auto_enrollment_check_step.cc

Issue 242483003: Move CaptivePortalDetector to src/components/captive_portal (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move CaptivePortalDetector to a component Created 6 years, 8 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
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/enrollment/auto_enrollment_check_step.h" 5 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_check_step.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "chrome/browser/chromeos/login/screens/screen_observer.h" 11 #include "chrome/browser/chromeos/login/screens/screen_observer.h"
12 #include "chromeos/chromeos_switches.h" 12 #include "chromeos/chromeos_switches.h"
13 #include "chromeos/network/network_state.h" 13 #include "chromeos/network/network_state.h"
14 #include "chromeos/network/network_state_handler.h" 14 #include "chromeos/network/network_state_handler.h"
15 15
16 namespace chromeos { 16 namespace chromeos {
17 17
18 AutoEnrollmentCheckStep::AutoEnrollmentCheckStep( 18 AutoEnrollmentCheckStep::AutoEnrollmentCheckStep(
19 ScreenObserver* screen_observer, 19 ScreenObserver* screen_observer,
20 AutoEnrollmentController* auto_enrollment_controller) 20 AutoEnrollmentController* auto_enrollment_controller)
21 : screen_observer_(screen_observer), 21 : screen_observer_(screen_observer),
22 auto_enrollment_controller_(auto_enrollment_controller), 22 auto_enrollment_controller_(auto_enrollment_controller),
23 captive_portal_status_( 23 captive_portal_status_(
24 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN), 24 captive_portal::CAPTIVE_PORTAL_STATUS_UNKNOWN),
25 auto_enrollment_state_(policy::AUTO_ENROLLMENT_STATE_IDLE) {} 25 auto_enrollment_state_(policy::AUTO_ENROLLMENT_STATE_IDLE) {}
26 26
27 AutoEnrollmentCheckStep::~AutoEnrollmentCheckStep() { 27 AutoEnrollmentCheckStep::~AutoEnrollmentCheckStep() {
28 NetworkPortalDetector::Get()->RemoveObserver(this); 28 NetworkPortalDetector::Get()->RemoveObserver(this);
29 } 29 }
30 30
31 void AutoEnrollmentCheckStep::Start() { 31 void AutoEnrollmentCheckStep::Start() {
32 if (AutoEnrollmentController::GetMode() != 32 if (AutoEnrollmentController::GetMode() !=
33 AutoEnrollmentController::MODE_FORCED_RE_ENROLLMENT) { 33 AutoEnrollmentController::MODE_FORCED_RE_ENROLLMENT) {
34 SignalCompletion(); 34 SignalCompletion();
(...skipping 21 matching lines...) Expand all
56 const NetworkPortalDetector::CaptivePortalState& state) { 56 const NetworkPortalDetector::CaptivePortalState& state) {
57 UpdateState(state.status, auto_enrollment_state_); 57 UpdateState(state.status, auto_enrollment_state_);
58 } 58 }
59 59
60 void AutoEnrollmentCheckStep::OnAutoEnrollmentCheckProgressed( 60 void AutoEnrollmentCheckStep::OnAutoEnrollmentCheckProgressed(
61 policy::AutoEnrollmentState state) { 61 policy::AutoEnrollmentState state) {
62 UpdateState(captive_portal_status_, state); 62 UpdateState(captive_portal_status_, state);
63 } 63 }
64 64
65 void AutoEnrollmentCheckStep::UpdateState( 65 void AutoEnrollmentCheckStep::UpdateState(
66 NetworkPortalDetector::CaptivePortalStatus new_captive_portal_status, 66 captive_portal::CaptivePortalStatus new_captive_portal_status,
67 policy::AutoEnrollmentState new_auto_enrollment_state) { 67 policy::AutoEnrollmentState new_auto_enrollment_state) {
68 // Configure the error screen to show the approriate error message. 68 // Configure the error screen to show the approriate error message.
69 if (!UpdateCaptivePortalStatus(new_captive_portal_status)) 69 if (!UpdateCaptivePortalStatus(new_captive_portal_status))
70 UpdateAutoEnrollmentState(new_auto_enrollment_state); 70 UpdateAutoEnrollmentState(new_auto_enrollment_state);
71 71
72 // Update the connecting indicator. 72 // Update the connecting indicator.
73 ErrorScreen* error_screen = screen_observer_->GetErrorScreen(); 73 ErrorScreen* error_screen = screen_observer_->GetErrorScreen();
74 error_screen->ShowConnectingIndicator( 74 error_screen->ShowConnectingIndicator(
75 new_auto_enrollment_state == policy::AUTO_ENROLLMENT_STATE_PENDING); 75 new_auto_enrollment_state == policy::AUTO_ENROLLMENT_STATE_PENDING);
76 76
77 // Determine whether a retry is in order. 77 // Determine whether a retry is in order.
78 bool retry = (new_captive_portal_status == 78 bool retry = (new_captive_portal_status ==
79 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE) && 79 captive_portal::CAPTIVE_PORTAL_STATUS_ONLINE) &&
80 (captive_portal_status_ != 80 (captive_portal_status_ !=
81 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE); 81 captive_portal::CAPTIVE_PORTAL_STATUS_ONLINE);
82 82
83 // Save the new state. 83 // Save the new state.
84 captive_portal_status_ = new_captive_portal_status; 84 captive_portal_status_ = new_captive_portal_status;
85 auto_enrollment_state_ = new_auto_enrollment_state; 85 auto_enrollment_state_ = new_auto_enrollment_state;
86 86
87 // Check whether a decision got made. 87 // Check whether a decision got made.
88 switch (new_auto_enrollment_state) { 88 switch (new_auto_enrollment_state) {
89 case policy::AUTO_ENROLLMENT_STATE_IDLE: 89 case policy::AUTO_ENROLLMENT_STATE_IDLE:
90 NOTREACHED(); 90 NOTREACHED();
91 // fall through. 91 // fall through.
92 case policy::AUTO_ENROLLMENT_STATE_PENDING: 92 case policy::AUTO_ENROLLMENT_STATE_PENDING:
93 case policy::AUTO_ENROLLMENT_STATE_CONNECTION_ERROR: 93 case policy::AUTO_ENROLLMENT_STATE_CONNECTION_ERROR:
94 break; 94 break;
95 case policy::AUTO_ENROLLMENT_STATE_SERVER_ERROR: 95 case policy::AUTO_ENROLLMENT_STATE_SERVER_ERROR:
96 // Server errors don't block OOBE. 96 // Server errors don't block OOBE.
97 case policy::AUTO_ENROLLMENT_STATE_TRIGGER_ENROLLMENT: 97 case policy::AUTO_ENROLLMENT_STATE_TRIGGER_ENROLLMENT:
98 case policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT: 98 case policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT:
99 // Decision made, ready to proceed. 99 // Decision made, ready to proceed.
100 SignalCompletion(); 100 SignalCompletion();
101 return; 101 return;
102 } 102 }
103 103
104 // Retry if applicable. This is last so eventual callbacks find consistent 104 // Retry if applicable. This is last so eventual callbacks find consistent
105 // state. 105 // state.
106 if (retry) 106 if (retry)
107 auto_enrollment_controller_->Retry(); 107 auto_enrollment_controller_->Retry();
108 } 108 }
109 109
110 bool AutoEnrollmentCheckStep::UpdateCaptivePortalStatus( 110 bool AutoEnrollmentCheckStep::UpdateCaptivePortalStatus(
111 NetworkPortalDetector::CaptivePortalStatus new_captive_portal_status) { 111 captive_portal::CaptivePortalStatus new_captive_portal_status) {
112 switch (new_captive_portal_status) { 112 switch (new_captive_portal_status) {
113 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN: 113 case captive_portal::CAPTIVE_PORTAL_STATUS_UNKNOWN:
114 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE: 114 case captive_portal::CAPTIVE_PORTAL_STATUS_ONLINE:
115 return false; 115 return false;
116 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE: 116 case captive_portal::CAPTIVE_PORTAL_STATUS_OFFLINE:
117 ShowErrorScreen(ErrorScreen::ERROR_STATE_OFFLINE); 117 ShowErrorScreen(ErrorScreen::ERROR_STATE_OFFLINE);
118 return true; 118 return true;
119 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL: 119 case captive_portal::CAPTIVE_PORTAL_STATUS_PORTAL:
120 ShowErrorScreen(ErrorScreen::ERROR_STATE_PORTAL); 120 ShowErrorScreen(ErrorScreen::ERROR_STATE_PORTAL);
121 if (captive_portal_status_ != new_captive_portal_status) 121 if (captive_portal_status_ != new_captive_portal_status)
122 screen_observer_->GetErrorScreen()->FixCaptivePortal(); 122 screen_observer_->GetErrorScreen()->FixCaptivePortal();
123 return true; 123 return true;
124 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: 124 case captive_portal::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED:
125 ShowErrorScreen(ErrorScreen::ERROR_STATE_PROXY); 125 ShowErrorScreen(ErrorScreen::ERROR_STATE_PROXY);
126 return true; 126 return true;
127 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT: 127 case captive_portal::CAPTIVE_PORTAL_STATUS_COUNT:
128 // Trigger NOTREACHED() below. 128 // Trigger NOTREACHED() below.
129 break; 129 break;
130 } 130 }
131 131
132 NOTREACHED() << "Bad status " << new_captive_portal_status; 132 NOTREACHED() << "Bad status " << new_captive_portal_status;
133 return false; 133 return false;
134 } 134 }
135 135
136 bool AutoEnrollmentCheckStep::UpdateAutoEnrollmentState( 136 bool AutoEnrollmentCheckStep::UpdateAutoEnrollmentState(
137 policy::AutoEnrollmentState new_auto_enrollment_state) { 137 policy::AutoEnrollmentState new_auto_enrollment_state) {
(...skipping 29 matching lines...) Expand all
167 } 167 }
168 168
169 void AutoEnrollmentCheckStep::SignalCompletion() { 169 void AutoEnrollmentCheckStep::SignalCompletion() {
170 NetworkPortalDetector::Get()->RemoveObserver(this); 170 NetworkPortalDetector::Get()->RemoveObserver(this);
171 auto_enrollment_progress_subscription_.reset(); 171 auto_enrollment_progress_subscription_.reset();
172 screen_observer_->OnExit( 172 screen_observer_->OnExit(
173 ScreenObserver::ENTERPRISE_AUTO_ENROLLMENT_CHECK_COMPLETED); 173 ScreenObserver::ENTERPRISE_AUTO_ENROLLMENT_CHECK_COMPLETED);
174 } 174 }
175 175
176 } // namespace chromeos 176 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698