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

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

Issue 10832035: Switch from SignedSettings to DeviceSettingsService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 3 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) 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/login_performer.h" 5 #include "chrome/browser/chromeos/login/login_performer.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 screen_lock_requested_ = false; 251 screen_lock_requested_ = false;
252 ResolveScreenLocked(); 252 ResolveScreenLocked();
253 } 253 }
254 } else { 254 } else {
255 ResolveScreenUnlocked(); 255 ResolveScreenUnlocked();
256 } 256 }
257 } 257 }
258 258
259 //////////////////////////////////////////////////////////////////////////////// 259 ////////////////////////////////////////////////////////////////////////////////
260 // LoginPerformer, public: 260 // LoginPerformer, public:
261 void LoginPerformer::CompleteLogin(const std::string& username, 261 void LoginPerformer::PerformLogin(const std::string& username,
262 const std::string& password) { 262 const std::string& password,
263 auth_mode_ = AUTH_MODE_EXTENSION; 263 AuthorizationMode auth_mode) {
264 auth_mode_ = auth_mode;
264 username_ = username; 265 username_ = username;
265 password_ = password; 266 password_ = password;
266 267
267 CrosSettings* cros_settings = CrosSettings::Get(); 268 CrosSettings* cros_settings = CrosSettings::Get();
268 269
269 // Whitelist check is always performed during initial login and 270 // Whitelist check is always performed during initial login and
270 // should not be performed when ScreenLock is active (pending online auth). 271 // should not be performed when ScreenLock is active (pending online auth).
271 if (!ScreenLocker::default_screen_locker()) { 272 if (!ScreenLocker::default_screen_locker()) {
272 CrosSettingsProvider::TrustedStatus status = 273 CrosSettingsProvider::TrustedStatus status =
273 cros_settings->PrepareTrustedValues( 274 cros_settings->PrepareTrustedValues(
274 base::Bind(&LoginPerformer::CompleteLogin, 275 base::Bind(&LoginPerformer::PerformLogin,
275 weak_factory_.GetWeakPtr(), 276 weak_factory_.GetWeakPtr(),
276 username, password)); 277 username, password, auth_mode));
277 // Must not proceed without signature verification. 278 // Must not proceed without signature verification.
278 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { 279 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) {
279 if (delegate_) 280 if (delegate_)
280 delegate_->PolicyLoadFailed(); 281 delegate_->PolicyLoadFailed();
281 else 282 else
282 NOTREACHED(); 283 NOTREACHED();
283 return; 284 return;
284 } else if (status != CrosSettingsProvider::TRUSTED) { 285 } else if (status != CrosSettingsProvider::TRUSTED) {
285 // Value of AllowNewUser setting is still not verified. 286 // Value of AllowNewUser setting is still not verified.
286 // Another attempt will be invoked after verification completion. 287 // Another attempt will be invoked after verification completion.
287 return; 288 return;
288 } 289 }
289 } 290 }
290 291
291 bool is_whitelisted = LoginUtils::IsWhitelisted( 292 bool is_whitelisted = LoginUtils::IsWhitelisted(
292 gaia::CanonicalizeEmail(username)); 293 gaia::CanonicalizeEmail(username));
293 if (ScreenLocker::default_screen_locker() || is_whitelisted) { 294 if (ScreenLocker::default_screen_locker() || is_whitelisted) {
294 // Starts authentication if guest login is allowed or online auth pending. 295 switch (auth_mode_) {
295 StartLoginCompletion(); 296 case AUTH_MODE_EXTENSION:
297 StartLoginCompletion();
298 break;
299 case AUTH_MODE_INTERNAL:
300 StartAuthentication();
301 break;
302 }
296 } else { 303 } else {
297 if (delegate_) 304 if (delegate_)
298 delegate_->WhiteListCheckFailed(username); 305 delegate_->WhiteListCheckFailed(username);
299 else
300 NOTREACHED();
301 }
302 }
303
304 void LoginPerformer::Login(const std::string& username,
305 const std::string& password) {
306 auth_mode_ = AUTH_MODE_INTERNAL;
307 username_ = username;
308 password_ = password;
309
310 CrosSettings* cros_settings = CrosSettings::Get();
311
312 // Whitelist check is always performed during initial login and
313 // should not be performed when ScreenLock is active (pending online auth).
314 if (!ScreenLocker::default_screen_locker()) {
315 CrosSettingsProvider::TrustedStatus status =
316 cros_settings->PrepareTrustedValues(
317 base::Bind(&LoginPerformer::Login,
318 weak_factory_.GetWeakPtr(),
319 username, password));
320 // Must not proceed without signature verification.
321 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) {
322 if (delegate_)
323 delegate_->PolicyLoadFailed();
324 else
325 NOTREACHED();
326 return;
327 } else if (status != CrosSettingsProvider::TRUSTED) {
328 // Value of AllowNewUser setting is still not verified.
329 // Another attempt will be invoked after verification completion.
330 return;
331 }
332 }
333
334 bool is_whitelisted = LoginUtils::IsWhitelisted(username);
335 if (ScreenLocker::default_screen_locker() || is_whitelisted) {
336 // Starts authentication if guest login is allowed or online auth pending.
337 StartAuthentication();
338 } else {
339 if (delegate_)
340 delegate_->WhiteListCheckFailed(username);
341 else 306 else
342 NOTREACHED(); 307 NOTREACHED();
343 } 308 }
344 } 309 }
345 310
346 void LoginPerformer::LoginDemoUser() { 311 void LoginPerformer::LoginDemoUser() {
347 authenticator_ = LoginUtils::Get()->CreateAuthenticator(this); 312 authenticator_ = LoginUtils::Get()->CreateAuthenticator(this);
348 BrowserThread::PostTask( 313 BrowserThread::PostTask(
349 BrowserThread::UI, FROM_HERE, 314 BrowserThread::UI, FROM_HERE,
350 base::Bind(&Authenticator::LoginDemoUser, authenticator_.get())); 315 base::Bind(&Authenticator::LoginDemoUser, authenticator_.get()));
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 profile, 530 profile,
566 username_, 531 username_,
567 password_, 532 password_,
568 std::string(), 533 std::string(),
569 std::string())); 534 std::string()));
570 } 535 }
571 password_.clear(); 536 password_.clear();
572 } 537 }
573 538
574 } // namespace chromeos 539 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698