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

Unified Diff: chrome/browser/chromeos/login/signin/token_handle_util.cc

Issue 1128923006: Do not invalidate OAuth token status user when token handle is invalid. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/login/signin/token_handle_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3d6c4662732f04aa21c7a07bcfd9debaa4d7b7f1..910e4a03b41032b0a7c0f7ed6661080bac4e0809 100644
--- a/chrome/browser/chromeos/login/signin/token_handle_util.cc
+++ b/chrome/browser/chromeos/login/signin/token_handle_util.cc
@@ -15,8 +15,15 @@
namespace {
const char kTokenHandlePref[] = "PasswordTokenHandle";
+const char kTokenHandleStatusPref[] = "TokenHandleStatus";
+
+const char kHandleStatusValid[] = "valid";
+const char kHandleStatusInvalid[] = "invalid";
+const char* kDefaultHandleStatus = kHandleStatusValid;
+
static const int kMaxRetries = 3;
-}
+
+} // namespace
TokenHandleUtil::TokenHandleUtil(user_manager::UserManager* user_manager)
: user_manager_(user_manager), weak_factory_(this) {
@@ -37,17 +44,36 @@ bool TokenHandleUtil::HasToken(const user_manager::UserID& user_id) {
return !token.empty();
}
-void TokenHandleUtil::DeleteToken(const user_manager::UserID& user_id) {
+bool TokenHandleUtil::ShouldObtainHandle(const user_manager::UserID& user_id) {
+ const base::DictionaryValue* dict = nullptr;
+ std::string token;
+ if (!user_manager_->FindKnownUserPrefs(user_id, &dict))
+ return true;
+ if (!dict->GetString(kTokenHandlePref, &token))
+ return true;
+ if (token.empty())
+ return true;
+ std::string status(kDefaultHandleStatus);
+ dict->GetString(kTokenHandleStatusPref, &status);
+ return kHandleStatusInvalid == status;
+}
+
+void TokenHandleUtil::DeleteHandle(const user_manager::UserID& user_id) {
const base::DictionaryValue* dict = nullptr;
if (!user_manager_->FindKnownUserPrefs(user_id, &dict))
return;
scoped_ptr<base::DictionaryValue> dict_copy(dict->DeepCopy());
- if (!dict_copy->Remove(kTokenHandlePref, nullptr))
- return;
+ dict_copy->Remove(kTokenHandlePref, nullptr);
+ dict_copy->Remove(kTokenHandleStatusPref, nullptr);
user_manager_->UpdateKnownUserPrefs(user_id, *dict_copy.get(),
/* replace values */ true);
}
+void TokenHandleUtil::MarkHandleInvalid(const user_manager::UserID& user_id) {
+ user_manager_->SetKnownUserStringPref(user_id, kTokenHandleStatusPref,
+ kHandleStatusInvalid);
+}
+
void TokenHandleUtil::CheckToken(const user_manager::UserID& user_id,
const TokenValidationCallback& callback) {
const base::DictionaryValue* dict = nullptr;
@@ -78,6 +104,8 @@ void TokenHandleUtil::CheckToken(const user_manager::UserID& user_id,
void TokenHandleUtil::StoreTokenHandle(const user_manager::UserID& user_id,
const std::string& handle) {
user_manager_->SetKnownUserStringPref(user_id, kTokenHandlePref, handle);
+ user_manager_->SetKnownUserStringPref(user_id, kTokenHandleStatusPref,
+ kHandleStatusValid);
}
void TokenHandleUtil::OnValidationComplete(const std::string& token) {
« no previous file with comments | « chrome/browser/chromeos/login/signin/token_handle_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698