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

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, remove blocking GetOwnershipStatus() Created 8 years, 4 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 screen_lock_requested_ = false; 253 screen_lock_requested_ = false;
254 ResolveScreenLocked(); 254 ResolveScreenLocked();
255 } 255 }
256 } else { 256 } else {
257 ResolveScreenUnlocked(); 257 ResolveScreenUnlocked();
258 } 258 }
259 } 259 }
260 260
261 //////////////////////////////////////////////////////////////////////////////// 261 ////////////////////////////////////////////////////////////////////////////////
262 // LoginPerformer, public: 262 // LoginPerformer, public:
263 void LoginPerformer::CompleteLogin(const std::string& username, 263 void LoginPerformer::PerformLogin(const std::string& username,
Nikita (slow) 2012/08/08 09:46:36 Why it is being renamed? The point of "CompleteLog
Nikita (slow) 2012/08/08 10:28:39 Ok, I think it makes sense to combine these.
264 const std::string& password) { 264 const std::string& password,
265 auth_mode_ = AUTH_MODE_EXTENSION; 265 AuthorizationMode auth_mode) {
266 auth_mode_ = auth_mode;
266 username_ = username; 267 username_ = username;
267 password_ = password; 268 password_ = password;
268 269
269 CrosSettings* cros_settings = CrosSettings::Get(); 270 CrosSettings* cros_settings = CrosSettings::Get();
270 271
271 // Whitelist check is always performed during initial login and 272 // Whitelist check is always performed during initial login and
272 // should not be performed when ScreenLock is active (pending online auth). 273 // should not be performed when ScreenLock is active (pending online auth).
273 if (!ScreenLocker::default_screen_locker()) { 274 if (!ScreenLocker::default_screen_locker()) {
274 CrosSettingsProvider::TrustedStatus status = 275 CrosSettingsProvider::TrustedStatus status =
275 cros_settings->PrepareTrustedValues( 276 cros_settings->PrepareTrustedValues(
276 base::Bind(&LoginPerformer::CompleteLogin, 277 base::Bind(&LoginPerformer::PerformLogin,
277 weak_factory_.GetWeakPtr(), 278 weak_factory_.GetWeakPtr(),
278 username, password)); 279 username, password, auth_mode));
279 // Must not proceed without signature verification. 280 // Must not proceed without signature verification.
280 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) { 281 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) {
281 if (delegate_) 282 if (delegate_)
282 delegate_->PolicyLoadFailed(); 283 delegate_->PolicyLoadFailed();
283 else 284 else
284 NOTREACHED(); 285 NOTREACHED();
285 return; 286 return;
286 } else if (status != CrosSettingsProvider::TRUSTED) { 287 } else if (status != CrosSettingsProvider::TRUSTED) {
287 // Value of AllowNewUser setting is still not verified. 288 // Value of AllowNewUser setting is still not verified.
288 // Another attempt will be invoked after verification completion. 289 // Another attempt will be invoked after verification completion.
289 return; 290 return;
290 } 291 }
291 } 292 }
292 293
293 bool is_whitelisted = LoginUtils::IsWhitelisted( 294 bool is_whitelisted = LoginUtils::IsWhitelisted(
294 gaia::CanonicalizeEmail(username)); 295 gaia::CanonicalizeEmail(username));
295 if (ScreenLocker::default_screen_locker() || is_whitelisted) { 296 if (ScreenLocker::default_screen_locker() || is_whitelisted) {
296 // Starts authentication if guest login is allowed or online auth pending. 297 switch (auth_mode_) {
297 StartLoginCompletion(); 298 case AUTH_MODE_EXTENSION:
299 StartLoginCompletion();
300 break;
301 case AUTH_MODE_INTERNAL:
302 StartAuthentication();
303 break;
304 }
298 } else { 305 } else {
299 if (delegate_) 306 if (delegate_)
300 delegate_->WhiteListCheckFailed(username); 307 delegate_->WhiteListCheckFailed(username);
301 else
302 NOTREACHED();
303 }
304 }
305
306 void LoginPerformer::Login(const std::string& username,
307 const std::string& password) {
308 auth_mode_ = AUTH_MODE_INTERNAL;
309 username_ = username;
310 password_ = password;
311
312 CrosSettings* cros_settings = CrosSettings::Get();
313
314 // Whitelist check is always performed during initial login and
315 // should not be performed when ScreenLock is active (pending online auth).
316 if (!ScreenLocker::default_screen_locker()) {
317 CrosSettingsProvider::TrustedStatus status =
318 cros_settings->PrepareTrustedValues(
319 base::Bind(&LoginPerformer::Login,
320 weak_factory_.GetWeakPtr(),
321 username, password));
322 // Must not proceed without signature verification.
323 if (status == CrosSettingsProvider::PERMANENTLY_UNTRUSTED) {
324 if (delegate_)
325 delegate_->PolicyLoadFailed();
326 else
327 NOTREACHED();
328 return;
329 } else if (status != CrosSettingsProvider::TRUSTED) {
330 // Value of AllowNewUser setting is still not verified.
331 // Another attempt will be invoked after verification completion.
332 return;
333 }
334 }
335
336 bool is_whitelisted = LoginUtils::IsWhitelisted(username);
337 if (ScreenLocker::default_screen_locker() || is_whitelisted) {
338 // Starts authentication if guest login is allowed or online auth pending.
339 StartAuthentication();
340 } else {
341 if (delegate_)
342 delegate_->WhiteListCheckFailed(username);
343 else 308 else
344 NOTREACHED(); 309 NOTREACHED();
345 } 310 }
346 } 311 }
347 312
348 void LoginPerformer::LoginDemoUser() { 313 void LoginPerformer::LoginDemoUser() {
349 authenticator_ = LoginUtils::Get()->CreateAuthenticator(this); 314 authenticator_ = LoginUtils::Get()->CreateAuthenticator(this);
350 BrowserThread::PostTask( 315 BrowserThread::PostTask(
351 BrowserThread::UI, FROM_HERE, 316 BrowserThread::UI, FROM_HERE,
352 base::Bind(&Authenticator::LoginDemoUser, authenticator_.get())); 317 base::Bind(&Authenticator::LoginDemoUser, authenticator_.get()));
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 profile, 532 profile,
568 username_, 533 username_,
569 password_, 534 password_,
570 std::string(), 535 std::string(),
571 std::string())); 536 std::string()));
572 } 537 }
573 password_.clear(); 538 password_.clear();
574 } 539 }
575 540
576 } // namespace chromeos 541 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698