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

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

Issue 6882038: Move writing information to the lockbox after registering with the DM server. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/enterprise_enrollment_screen.h" 5 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/chromeos/cros/cros_library.h" 9 #include "chrome/browser/chromeos/cros/cros_library.h"
10 #include "chrome/browser/chromeos/cros/cryptohome_library.h" 10 #include "chrome/browser/chromeos/cros/cryptohome_library.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 93 }
94 } 94 }
95 LOG(ERROR) << "Enrollment will not finish because the InstallAttrs has " 95 LOG(ERROR) << "Enrollment will not finish because the InstallAttrs has "
96 << "been locked already but does not contain valid data."; 96 << "been locked already but does not contain valid data.";
97 } 97 }
98 return false; 98 return false;
99 } 99 }
100 100
101 void EnterpriseEnrollmentScreen::OnClientLoginSuccess( 101 void EnterpriseEnrollmentScreen::OnClientLoginSuccess(
102 const ClientLoginResult& result) { 102 const ClientLoginResult& result) {
103 WriteInstallAttributesData(result); 103 auth_fetcher_->StartIssueAuthToken(
104 result.sid, result.lsid, GaiaConstants::kDeviceManagementService);
104 } 105 }
105 106
106 void EnterpriseEnrollmentScreen::OnClientLoginFailure( 107 void EnterpriseEnrollmentScreen::OnClientLoginFailure(
107 const GoogleServiceAuthError& error) { 108 const GoogleServiceAuthError& error) {
108 HandleAuthError(error); 109 HandleAuthError(error);
109 } 110 }
110 111
111 void EnterpriseEnrollmentScreen::OnIssueAuthTokenSuccess( 112 void EnterpriseEnrollmentScreen::OnIssueAuthTokenSuccess(
112 const std::string& service, 113 const std::string& service,
113 const std::string& auth_token) { 114 const std::string& auth_token) {
114 if (service != GaiaConstants::kDeviceManagementService) { 115 if (service != GaiaConstants::kDeviceManagementService) {
115 NOTREACHED() << service; 116 NOTREACHED() << service;
116 return; 117 return;
117 } 118 }
118 119
119 scoped_ptr<GaiaAuthFetcher> auth_fetcher(auth_fetcher_.release()); 120 scoped_ptr<GaiaAuthFetcher> auth_fetcher(auth_fetcher_.release());
120 121
121 policy::BrowserPolicyConnector* connector = 122 policy::BrowserPolicyConnector* connector =
122 g_browser_process->browser_policy_connector(); 123 g_browser_process->browser_policy_connector();
123 if (!connector->cloud_policy_subsystem()) { 124 if (!connector->cloud_policy_subsystem()) {
124 NOTREACHED() << "Cloud policy subsystem not initialized."; 125 NOTREACHED() << "Cloud policy subsystem not initialized.";
125 if (view()) 126 if (view())
126 view()->ShowFatalEnrollmentError(); 127 view()->ShowFatalEnrollmentError();
127 return; 128 return;
128 } 129 }
129 130
130 registrar_.reset(new policy::CloudPolicySubsystem::ObserverRegistrar( 131 registrar_.reset(new policy::CloudPolicySubsystem::ObserverRegistrar(
131 connector->cloud_policy_subsystem(), this)); 132 connector->cloud_policy_subsystem(), this));
132 133 LOG(ERROR) << "### Auth done!";
Mattias Nissler (ping if slow) 2011/04/19 12:15:25 Be sure to remove this or make it a VLOG() before
134 connector->cloud_policy_subsystem()->StopAfterTokenFetch(true);
133 // Push the credentials to the policy infrastructure. It'll start enrollment 135 // Push the credentials to the policy infrastructure. It'll start enrollment
134 // and notify us of progress through CloudPolicySubsystem::Observer. 136 // and notify us of progress through CloudPolicySubsystem::Observer.
135 connector->SetCredentials(user_, auth_token); 137 connector->SetCredentials(user_, auth_token);
136 } 138 }
137 139
138 void EnterpriseEnrollmentScreen::OnIssueAuthTokenFailure( 140 void EnterpriseEnrollmentScreen::OnIssueAuthTokenFailure(
139 const std::string& service, 141 const std::string& service,
140 const GoogleServiceAuthError& error) { 142 const GoogleServiceAuthError& error) {
141 if (service != GaiaConstants::kDeviceManagementService) { 143 if (service != GaiaConstants::kDeviceManagementService) {
142 NOTREACHED() << service; 144 NOTREACHED() << service;
143 return; 145 return;
144 } 146 }
145 147
146 HandleAuthError(error); 148 HandleAuthError(error);
147 } 149 }
148 150
149 void EnterpriseEnrollmentScreen::OnPolicyStateChanged( 151 void EnterpriseEnrollmentScreen::OnPolicyStateChanged(
150 policy::CloudPolicySubsystem::PolicySubsystemState state, 152 policy::CloudPolicySubsystem::PolicySubsystemState state,
151 policy::CloudPolicySubsystem::ErrorDetails error_details) { 153 policy::CloudPolicySubsystem::ErrorDetails error_details) {
152 154
155 LOG(ERROR) << "### State change : " << state;
Mattias Nissler (ping if slow) 2011/04/19 12:15:25 same here.
153 if (view()) { 156 if (view()) {
154 switch (state) { 157 switch (state) {
155 case policy::CloudPolicySubsystem::UNENROLLED: 158 case policy::CloudPolicySubsystem::UNENROLLED:
156 // Still working... 159 // Still working...
157 return; 160 return;
158 case policy::CloudPolicySubsystem::BAD_GAIA_TOKEN: 161 case policy::CloudPolicySubsystem::BAD_GAIA_TOKEN:
159 case policy::CloudPolicySubsystem::LOCAL_ERROR: 162 case policy::CloudPolicySubsystem::LOCAL_ERROR:
160 view()->ShowFatalEnrollmentError(); 163 view()->ShowFatalEnrollmentError();
161 break; 164 break;
162 case policy::CloudPolicySubsystem::UNMANAGED: 165 case policy::CloudPolicySubsystem::UNMANAGED:
163 view()->ShowAccountError(); 166 view()->ShowAccountError();
164 break; 167 break;
165 case policy::CloudPolicySubsystem::NETWORK_ERROR: 168 case policy::CloudPolicySubsystem::NETWORK_ERROR:
166 view()->ShowNetworkEnrollmentError(); 169 view()->ShowNetworkEnrollmentError();
167 break; 170 break;
171 case policy::CloudPolicySubsystem::TOKEN_FETCHED:
172 WriteInstallAttributesData();
173 return;
168 case policy::CloudPolicySubsystem::SUCCESS: 174 case policy::CloudPolicySubsystem::SUCCESS:
169 // Success! 175 // Success!
170 registrar_.reset(); 176 registrar_.reset();
171 view()->ShowConfirmationScreen(); 177 view()->ShowConfirmationScreen();
172 return; 178 return;
173 } 179 }
174 180
175 // We have an error. 181 // We have an error.
176 LOG(WARNING) << "Policy subsystem error during enrollment: " << state 182 LOG(WARNING) << "Policy subsystem error during enrollment: " << state
177 << " details: " << error_details; 183 << " details: " << error_details;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // fall through. 218 // fall through.
213 case GoogleServiceAuthError::REQUEST_CANCELED: 219 case GoogleServiceAuthError::REQUEST_CANCELED:
214 LOG(ERROR) << "Unexpected GAIA auth error: " << error.state(); 220 LOG(ERROR) << "Unexpected GAIA auth error: " << error.state();
215 view()->ShowFatalAuthError(); 221 view()->ShowFatalAuthError();
216 return; 222 return;
217 } 223 }
218 224
219 NOTREACHED() << error.state(); 225 NOTREACHED() << error.state();
220 } 226 }
221 227
222 void EnterpriseEnrollmentScreen::WriteInstallAttributesData( 228 void EnterpriseEnrollmentScreen::WriteInstallAttributesData() {
223 const ClientLoginResult& result) {
224 // Since this method is also called directly. 229 // Since this method is also called directly.
225 runnable_method_factory_.RevokeAll(); 230 runnable_method_factory_.RevokeAll();
226 231
227 if (!view()) 232 if (!view())
228 return; 233 return;
229 234
235 LOG(ERROR) << "### Lock it!";
Mattias Nissler (ping if slow) 2011/04/19 12:15:25 And here!
236
230 switch (g_browser_process->browser_policy_connector()->LockDevice(user_)) { 237 switch (g_browser_process->browser_policy_connector()->LockDevice(user_)) {
231 case policy::EnterpriseInstallAttributes::LOCK_SUCCESS: 238 case policy::EnterpriseInstallAttributes::LOCK_SUCCESS: {
232 // Proceed with register and policy fetch. 239 // Proceed with policy fetch.
233 auth_fetcher_->StartIssueAuthToken( 240 policy::BrowserPolicyConnector* connector =
234 result.sid, result.lsid, GaiaConstants::kDeviceManagementService); 241 g_browser_process->browser_policy_connector();
242 connector->cloud_policy_subsystem()->SendPolicyRequest();
Mattias Nissler (ping if slow) 2011/04/19 12:15:25 This should probably be connector->EnablePolicy(),
243 LOG(ERROR) << "### Locked!";
Mattias Nissler (ping if slow) 2011/04/19 12:15:25 And here.
235 return; 244 return;
236 case policy::EnterpriseInstallAttributes::LOCK_NOT_READY: 245 }
246 case policy::EnterpriseInstallAttributes::LOCK_NOT_READY: {
237 // InstallAttributes not ready yet, retry later. 247 // InstallAttributes not ready yet, retry later.
238 LOG(WARNING) << "Install Attributes not ready yet will retry in " 248 LOG(WARNING) << "Install Attributes not ready yet will retry in "
239 << kLockRetryIntervalMs << "ms."; 249 << kLockRetryIntervalMs << "ms.";
240 MessageLoop::current()->PostDelayedTask( 250 MessageLoop::current()->PostDelayedTask(
241 FROM_HERE, 251 FROM_HERE,
242 runnable_method_factory_.NewRunnableMethod( 252 runnable_method_factory_.NewRunnableMethod(
243 &EnterpriseEnrollmentScreen::WriteInstallAttributesData, result), 253 &EnterpriseEnrollmentScreen::WriteInstallAttributesData),
244 kLockRetryIntervalMs); 254 kLockRetryIntervalMs);
245 return; 255 return;
246 case policy::EnterpriseInstallAttributes::LOCK_BACKEND_ERROR: 256 }
257 case policy::EnterpriseInstallAttributes::LOCK_BACKEND_ERROR: {
247 view()->ShowFatalEnrollmentError(); 258 view()->ShowFatalEnrollmentError();
248 return; 259 return;
249 case policy::EnterpriseInstallAttributes::LOCK_WRONG_USER: 260 }
261 case policy::EnterpriseInstallAttributes::LOCK_WRONG_USER: {
250 LOG(ERROR) << "Enrollment can not proceed because the InstallAttrs " 262 LOG(ERROR) << "Enrollment can not proceed because the InstallAttrs "
251 << "has been locked already!"; 263 << "has been locked already!";
252 view()->ShowFatalEnrollmentError(); 264 view()->ShowFatalEnrollmentError();
253 return; 265 return;
266 }
254 } 267 }
255 268
256 NOTREACHED(); 269 NOTREACHED();
257 } 270 }
258 271
259 } // namespace chromeos 272 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698