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

Side by Side Diff: chrome/browser/signin/easy_unlock_auth_attempt.cc

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
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/signin/easy_unlock_auth_attempt.h" 5 #include "chrome/browser/signin/easy_unlock_auth_attempt.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/signin/easy_unlock_app_manager.h" 9 #include "chrome/browser/signin/easy_unlock_app_manager.h"
10 #include "chrome/browser/signin/proximity_auth_facade.h" 10 #include "chrome/browser/signin/proximity_auth_facade.h"
(...skipping 30 matching lines...) Expand all
41 std::string secret; 41 std::string secret;
42 if (!encryptor.Decrypt(wrapped_secret, &secret)) 42 if (!encryptor.Decrypt(wrapped_secret, &secret))
43 return std::string(); 43 return std::string();
44 44
45 return secret; 45 return secret;
46 } 46 }
47 47
48 void DefaultAuthAttemptFinalizedHandler( 48 void DefaultAuthAttemptFinalizedHandler(
49 EasyUnlockAuthAttempt::Type auth_attempt_type, 49 EasyUnlockAuthAttempt::Type auth_attempt_type,
50 bool success, 50 bool success,
51 const std::string& user_id, 51 const user_manager::UserID& user_id,
52 const std::string& key_secret, 52 const std::string& key_secret,
53 const std::string& key_label) { 53 const std::string& key_label) {
54 if (!GetScreenlockBridgeInstance()->IsLocked()) 54 if (!GetScreenlockBridgeInstance()->IsLocked())
55 return; 55 return;
56 56
57 switch (auth_attempt_type) { 57 switch (auth_attempt_type) {
58 case EasyUnlockAuthAttempt::TYPE_UNLOCK: 58 case EasyUnlockAuthAttempt::TYPE_UNLOCK:
59 if (success) { 59 if (success) {
60 GetScreenlockBridgeInstance()->lock_handler()->Unlock(user_id); 60 GetScreenlockBridgeInstance()->lock_handler()->Unlock(user_id);
61 } else { 61 } else {
(...skipping 11 matching lines...) Expand all
73 user_id, std::string(), std::string()); 73 user_id, std::string(), std::string());
74 } 74 }
75 return; 75 return;
76 } 76 }
77 } 77 }
78 78
79 } // namespace 79 } // namespace
80 80
81 EasyUnlockAuthAttempt::EasyUnlockAuthAttempt( 81 EasyUnlockAuthAttempt::EasyUnlockAuthAttempt(
82 EasyUnlockAppManager* app_manager, 82 EasyUnlockAppManager* app_manager,
83 const std::string& user_id, 83 const user_manager::UserID& user_id,
84 Type type, 84 Type type,
85 const FinalizedCallback& finalized_callback) 85 const FinalizedCallback& finalized_callback)
86 : app_manager_(app_manager), 86 : app_manager_(app_manager),
87 state_(STATE_IDLE), 87 state_(STATE_IDLE),
88 user_id_(user_id), 88 user_id_(user_id),
89 type_(type), 89 type_(type),
90 finalized_callback_(finalized_callback) { 90 finalized_callback_(finalized_callback) {
91 if (finalized_callback_.is_null()) 91 if (finalized_callback_.is_null())
92 finalized_callback_ = base::Bind(&DefaultAuthAttemptFinalizedHandler); 92 finalized_callback_ = base::Bind(&DefaultAuthAttemptFinalizedHandler);
93 } 93 }
(...skipping 20 matching lines...) Expand all
114 state_ = STATE_RUNNING; 114 state_ = STATE_RUNNING;
115 115
116 if (!app_manager_->SendAuthAttemptEvent()) { 116 if (!app_manager_->SendAuthAttemptEvent()) {
117 Cancel(user_id_); 117 Cancel(user_id_);
118 return false; 118 return false;
119 } 119 }
120 120
121 return true; 121 return true;
122 } 122 }
123 123
124 void EasyUnlockAuthAttempt::FinalizeUnlock(const std::string& user_id, 124 void EasyUnlockAuthAttempt::FinalizeUnlock(const user_manager::UserID& user_id,
125 bool success) { 125 bool success) {
126 if (state_ != STATE_RUNNING || user_id != user_id_) 126 if (state_ != STATE_RUNNING || user_id != user_id_)
127 return; 127 return;
128 128
129 if (!GetScreenlockBridgeInstance()->IsLocked()) 129 if (!GetScreenlockBridgeInstance()->IsLocked())
130 return; 130 return;
131 131
132 if (type_ != TYPE_UNLOCK) { 132 if (type_ != TYPE_UNLOCK) {
133 Cancel(user_id_); 133 Cancel(user_id_);
134 return; 134 return;
135 } 135 }
136 136
137 finalized_callback_.Run(type_, success, user_id, std::string(), 137 finalized_callback_.Run(type_, success, user_id, std::string(),
138 std::string()); 138 std::string());
139 state_ = STATE_DONE; 139 state_ = STATE_DONE;
140 } 140 }
141 141
142 void EasyUnlockAuthAttempt::FinalizeSignin(const std::string& user_id, 142 void EasyUnlockAuthAttempt::FinalizeSignin(const user_manager::UserID& user_id,
143 const std::string& wrapped_secret, 143 const std::string& wrapped_secret,
144 const std::string& raw_session_key) { 144 const std::string& raw_session_key) {
145 if (state_ != STATE_RUNNING || user_id != user_id_) 145 if (state_ != STATE_RUNNING || user_id != user_id_)
146 return; 146 return;
147 147
148 if (!GetScreenlockBridgeInstance()->IsLocked()) 148 if (!GetScreenlockBridgeInstance()->IsLocked())
149 return; 149 return;
150 150
151 if (type_ != TYPE_SIGNIN) { 151 if (type_ != TYPE_SIGNIN) {
152 Cancel(user_id_); 152 Cancel(user_id_);
(...skipping 11 matching lines...) Expand all
164 #if defined(OS_CHROMEOS) 164 #if defined(OS_CHROMEOS)
165 key_label = chromeos::EasyUnlockKeyManager::GetKeyLabel(0u); 165 key_label = chromeos::EasyUnlockKeyManager::GetKeyLabel(0u);
166 #endif // defined(OS_CHROMEOS) 166 #endif // defined(OS_CHROMEOS)
167 167
168 const bool kSuccess = true; 168 const bool kSuccess = true;
169 finalized_callback_.Run(type_, kSuccess, user_id, unwrapped_secret, 169 finalized_callback_.Run(type_, kSuccess, user_id, unwrapped_secret,
170 key_label); 170 key_label);
171 state_ = STATE_DONE; 171 state_ = STATE_DONE;
172 } 172 }
173 173
174 void EasyUnlockAuthAttempt::Cancel(const std::string& user_id) { 174 void EasyUnlockAuthAttempt::Cancel(const user_manager::UserID& user_id) {
175 state_ = STATE_DONE; 175 state_ = STATE_DONE;
176 176
177 const bool kFailure = false; 177 const bool kFailure = false;
178 finalized_callback_.Run(type_, kFailure, user_id, std::string(), 178 finalized_callback_.Run(type_, kFailure, user_id, std::string(),
179 std::string()); 179 std::string());
180 } 180 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698