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

Unified Diff: chrome/browser/chromeos/login/signin/token_handle_util.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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/signin/token_handle_util.cc
diff --git a/chrome/browser/chromeos/login/signin/token_handle_util.cc b/chrome/browser/chromeos/login/signin/token_handle_util.cc
index 4e688a747cf7e6da7bfd3aa19760e65547f027ef..5304a945c08df37a2cc44236f252d3f74c9b5e42 100644
--- a/chrome/browser/chromeos/login/signin/token_handle_util.cc
+++ b/chrome/browser/chromeos/login/signin/token_handle_util.cc
@@ -9,7 +9,6 @@
#include "base/values.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
-#include "components/user_manager/user_id.h"
#include "components/user_manager/user_manager.h"
#include "google_apis/gaia/gaia_oauth_client.h"
@@ -35,20 +34,20 @@ TokenHandleUtil::~TokenHandleUtil() {
gaia_client_.reset();
}
-bool TokenHandleUtil::HasToken(const user_manager::UserID& user_id) {
+bool TokenHandleUtil::HasToken(const AccountId& account_id) {
const base::DictionaryValue* dict = nullptr;
std::string token;
- if (!user_manager_->FindKnownUserPrefs(user_id, &dict))
+ if (!user_manager_->FindKnownUserPrefs(account_id, &dict))
return false;
if (!dict->GetString(kTokenHandlePref, &token))
return false;
return !token.empty();
}
-bool TokenHandleUtil::ShouldObtainHandle(const user_manager::UserID& user_id) {
+bool TokenHandleUtil::ShouldObtainHandle(const AccountId& account_id) {
const base::DictionaryValue* dict = nullptr;
std::string token;
- if (!user_manager_->FindKnownUserPrefs(user_id, &dict))
+ if (!user_manager_->FindKnownUserPrefs(account_id, &dict))
return true;
if (!dict->GetString(kTokenHandlePref, &token))
return true;
@@ -59,32 +58,32 @@ bool TokenHandleUtil::ShouldObtainHandle(const user_manager::UserID& user_id) {
return kHandleStatusInvalid == status;
}
-void TokenHandleUtil::DeleteHandle(const user_manager::UserID& user_id) {
+void TokenHandleUtil::DeleteHandle(const AccountId& account_id) {
const base::DictionaryValue* dict = nullptr;
- if (!user_manager_->FindKnownUserPrefs(user_id, &dict))
+ if (!user_manager_->FindKnownUserPrefs(account_id, &dict))
return;
scoped_ptr<base::DictionaryValue> dict_copy(dict->DeepCopy());
dict_copy->Remove(kTokenHandlePref, nullptr);
dict_copy->Remove(kTokenHandleStatusPref, nullptr);
- user_manager_->UpdateKnownUserPrefs(user_id, *dict_copy.get(),
+ user_manager_->UpdateKnownUserPrefs(account_id, *dict_copy.get(),
/* replace values */ true);
}
-void TokenHandleUtil::MarkHandleInvalid(const user_manager::UserID& user_id) {
- user_manager_->SetKnownUserStringPref(user_id, kTokenHandleStatusPref,
+void TokenHandleUtil::MarkHandleInvalid(const AccountId& account_id) {
+ user_manager_->SetKnownUserStringPref(account_id, kTokenHandleStatusPref,
kHandleStatusInvalid);
}
-void TokenHandleUtil::CheckToken(const user_manager::UserID& user_id,
+void TokenHandleUtil::CheckToken(const AccountId& account_id,
const TokenValidationCallback& callback) {
const base::DictionaryValue* dict = nullptr;
std::string token;
- if (!user_manager_->FindKnownUserPrefs(user_id, &dict)) {
- callback.Run(user_id, UNKNOWN);
+ if (!user_manager_->FindKnownUserPrefs(account_id, &dict)) {
+ callback.Run(account_id, UNKNOWN);
return;
}
if (!dict->GetString(kTokenHandlePref, &token)) {
- callback.Run(user_id, UNKNOWN);
+ callback.Run(account_id, UNKNOWN);
return;
}
@@ -96,15 +95,15 @@ void TokenHandleUtil::CheckToken(const user_manager::UserID& user_id,
validation_delegates_.set(
token, scoped_ptr<TokenDelegate>(new TokenDelegate(
- weak_factory_.GetWeakPtr(), user_id, token, callback)));
+ weak_factory_.GetWeakPtr(), account_id, token, callback)));
gaia_client_->GetTokenHandleInfo(token, kMaxRetries,
validation_delegates_.get(token));
}
-void TokenHandleUtil::StoreTokenHandle(const user_manager::UserID& user_id,
+void TokenHandleUtil::StoreTokenHandle(const AccountId& account_id,
const std::string& handle) {
- user_manager_->SetKnownUserStringPref(user_id, kTokenHandlePref, handle);
- user_manager_->SetKnownUserStringPref(user_id, kTokenHandleStatusPref,
+ user_manager_->SetKnownUserStringPref(account_id, kTokenHandlePref, handle);
+ user_manager_->SetKnownUserStringPref(account_id, kTokenHandleStatusPref,
kHandleStatusValid);
}
@@ -112,28 +111,26 @@ void TokenHandleUtil::OnValidationComplete(const std::string& token) {
validation_delegates_.erase(token);
}
-void TokenHandleUtil::OnObtainTokenComplete(
- const user_manager::UserID& user_id) {
- obtain_delegates_.erase(user_id);
+void TokenHandleUtil::OnObtainTokenComplete(const AccountId& account_id) {
+ obtain_delegates_.erase(account_id);
}
TokenHandleUtil::TokenDelegate::TokenDelegate(
const base::WeakPtr<TokenHandleUtil>& owner,
- const user_manager::UserID& user_id,
+ const AccountId& account_id,
const std::string& token,
const TokenValidationCallback& callback)
: owner_(owner),
- user_id_(user_id),
+ account_id_(account_id),
token_(token),
tokeninfo_response_start_time_(base::TimeTicks::Now()),
- callback_(callback) {
-}
+ callback_(callback) {}
TokenHandleUtil::TokenDelegate::~TokenDelegate() {
}
void TokenHandleUtil::TokenDelegate::OnOAuthError() {
- callback_.Run(user_id_, INVALID);
+ callback_.Run(account_id_, INVALID);
NotifyDone();
}
@@ -144,7 +141,7 @@ void TokenHandleUtil::TokenDelegate::NotifyDone() {
}
void TokenHandleUtil::TokenDelegate::OnNetworkError(int response_code) {
- callback_.Run(user_id_, UNKNOWN);
+ callback_.Run(account_id_, UNKNOWN);
NotifyDone();
}
@@ -160,6 +157,6 @@ void TokenHandleUtil::TokenDelegate::OnGetTokenInfoResponse(
const base::TimeDelta duration =
base::TimeTicks::Now() - tokeninfo_response_start_time_;
UMA_HISTOGRAM_TIMES("Login.TokenCheckResponseTime", duration);
- callback_.Run(user_id_, outcome);
+ callback_.Run(account_id_, outcome);
NotifyDone();
}
« no previous file with comments | « chrome/browser/chromeos/login/signin/token_handle_util.h ('k') | chrome/browser/chromeos/login/signin_screen_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698