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

Side by Side Diff: chromeos/login/auth/stub_authenticator.cc

Issue 1412813003: This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Fix Win GN build. Created 5 years, 1 month 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
« no previous file with comments | « chromeos/login/auth/login_performer.cc ('k') | chromeos/login/auth/user_context.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chromeos/login/auth/stub_authenticator.h" 5 #include "chromeos/login/auth/stub_authenticator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 20 matching lines...) Expand all
31 if (expected_user_context_ != user_context) 31 if (expected_user_context_ != user_context)
32 NOTREACHED(); 32 NOTREACHED();
33 OnAuthSuccess(); 33 OnAuthSuccess();
34 } 34 }
35 35
36 void StubAuthenticator::AuthenticateToLogin(content::BrowserContext* context, 36 void StubAuthenticator::AuthenticateToLogin(content::BrowserContext* context,
37 const UserContext& user_context) { 37 const UserContext& user_context) {
38 authentication_context_ = context; 38 authentication_context_ = context;
39 // Don't compare the entire |expected_user_context_| to |user_context| because 39 // Don't compare the entire |expected_user_context_| to |user_context| because
40 // during non-online re-auth |user_context| does not have a gaia id. 40 // during non-online re-auth |user_context| does not have a gaia id.
41 if (expected_user_context_.GetUserID() == user_context.GetUserID() && 41 if (expected_user_context_.GetAccountId() == user_context.GetAccountId() &&
42 *expected_user_context_.GetKey() == *user_context.GetKey()) { 42 *expected_user_context_.GetKey() == *user_context.GetKey()) {
43 task_runner_->PostTask(FROM_HERE, 43 task_runner_->PostTask(FROM_HERE,
44 base::Bind(&StubAuthenticator::OnAuthSuccess, this)); 44 base::Bind(&StubAuthenticator::OnAuthSuccess, this));
45 return; 45 return;
46 } 46 }
47 GoogleServiceAuthError error( 47 GoogleServiceAuthError error(
48 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); 48 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
49 task_runner_->PostTask( 49 task_runner_->PostTask(
50 FROM_HERE, base::Bind(&StubAuthenticator::OnAuthFailure, this, 50 FROM_HERE, base::Bind(&StubAuthenticator::OnAuthFailure, this,
51 AuthFailure::FromNetworkAuthFailure(error))); 51 AuthFailure::FromNetworkAuthFailure(error)));
52 } 52 }
53 53
54 void StubAuthenticator::AuthenticateToUnlock(const UserContext& user_context) { 54 void StubAuthenticator::AuthenticateToUnlock(const UserContext& user_context) {
55 AuthenticateToLogin(NULL /* not used */, user_context); 55 AuthenticateToLogin(NULL /* not used */, user_context);
56 } 56 }
57 57
58 void StubAuthenticator::LoginAsSupervisedUser(const UserContext& user_context) { 58 void StubAuthenticator::LoginAsSupervisedUser(const UserContext& user_context) {
59 UserContext new_user_context = user_context; 59 UserContext new_user_context = user_context;
60 new_user_context.SetUserIDHash(user_context.GetUserID() + kUserIdHashSuffix); 60 new_user_context.SetUserIDHash(user_context.GetAccountId().GetUserEmail() +
61 kUserIdHashSuffix);
61 consumer_->OnAuthSuccess(new_user_context); 62 consumer_->OnAuthSuccess(new_user_context);
62 } 63 }
63 64
64 void StubAuthenticator::LoginOffTheRecord() { 65 void StubAuthenticator::LoginOffTheRecord() {
65 consumer_->OnOffTheRecordAuthSuccess(); 66 consumer_->OnOffTheRecordAuthSuccess();
66 } 67 }
67 68
68 void StubAuthenticator::LoginAsPublicSession(const UserContext& user_context) { 69 void StubAuthenticator::LoginAsPublicSession(const UserContext& user_context) {
69 UserContext logged_in_user_context = user_context; 70 UserContext logged_in_user_context = user_context;
70 logged_in_user_context.SetIsUsingOAuth(false); 71 logged_in_user_context.SetIsUsingOAuth(false);
71 logged_in_user_context.SetUserIDHash(logged_in_user_context.GetUserID() + 72 logged_in_user_context.SetUserIDHash(
72 kUserIdHashSuffix); 73 logged_in_user_context.GetAccountId().GetUserEmail() + kUserIdHashSuffix);
73 consumer_->OnAuthSuccess(logged_in_user_context); 74 consumer_->OnAuthSuccess(logged_in_user_context);
74 } 75 }
75 76
76 void StubAuthenticator::LoginAsKioskAccount(const std::string& app_user_id, 77 void StubAuthenticator::LoginAsKioskAccount(
77 bool use_guest_mount) { 78 const std::string& /* app_user_id */,
78 UserContext user_context(expected_user_context_.GetUserID()); 79 bool use_guest_mount) {
80 UserContext user_context(expected_user_context_.GetAccountId());
79 user_context.SetIsUsingOAuth(false); 81 user_context.SetIsUsingOAuth(false);
80 user_context.SetUserIDHash(expected_user_context_.GetUserID() + 82 user_context.SetUserIDHash(
81 kUserIdHashSuffix); 83 expected_user_context_.GetAccountId().GetUserEmail() + kUserIdHashSuffix);
82 consumer_->OnAuthSuccess(user_context); 84 consumer_->OnAuthSuccess(user_context);
83 } 85 }
84 86
85 void StubAuthenticator::OnAuthSuccess() { 87 void StubAuthenticator::OnAuthSuccess() {
86 // If we want to be more like the real thing, we could save the user ID 88 // If we want to be more like the real thing, we could save the user ID
87 // in AuthenticateToLogin, but there's not much of a point. 89 // in AuthenticateToLogin, but there's not much of a point.
88 UserContext user_context(expected_user_context_); 90 UserContext user_context(expected_user_context_);
89 user_context.SetUserIDHash(expected_user_context_.GetUserID() + 91 user_context.SetUserIDHash(
90 kUserIdHashSuffix); 92 expected_user_context_.GetAccountId().GetUserEmail() + kUserIdHashSuffix);
91 consumer_->OnAuthSuccess(user_context); 93 consumer_->OnAuthSuccess(user_context);
92 } 94 }
93 95
94 void StubAuthenticator::OnAuthFailure(const AuthFailure& failure) { 96 void StubAuthenticator::OnAuthFailure(const AuthFailure& failure) {
95 consumer_->OnAuthFailure(failure); 97 consumer_->OnAuthFailure(failure);
96 } 98 }
97 99
98 void StubAuthenticator::RecoverEncryptedData(const std::string& old_password) { 100 void StubAuthenticator::RecoverEncryptedData(const std::string& old_password) {
99 } 101 }
100 102
101 void StubAuthenticator::ResyncEncryptedData() { 103 void StubAuthenticator::ResyncEncryptedData() {
102 } 104 }
103 105
104 void StubAuthenticator::SetExpectedCredentials( 106 void StubAuthenticator::SetExpectedCredentials(
105 const UserContext& user_context) { 107 const UserContext& user_context) {
106 expected_user_context_ = user_context; 108 expected_user_context_ = user_context;
107 } 109 }
108 110
109 StubAuthenticator::~StubAuthenticator() { 111 StubAuthenticator::~StubAuthenticator() {
110 } 112 }
111 113
112 } // namespace chromeos 114 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/login/auth/login_performer.cc ('k') | chromeos/login/auth/user_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698