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

Side by Side Diff: chrome/browser/chromeos/login/signin/token_handle_util.cc

Issue 1191273002: ChromeOS: Show the new POD RE-AUTH ICON when users needs to re-auth (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update after review. Created 5 years, 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/signin/token_handle_util.h" 5 #include "chrome/browser/chromeos/login/signin/token_handle_util.h"
6 6
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/chromeos/profiles/profile_helper.h" 10 #include "chrome/browser/chromeos/profiles/profile_helper.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 dict_copy->Remove(kTokenHandleStatusPref, nullptr); 68 dict_copy->Remove(kTokenHandleStatusPref, nullptr);
69 user_manager_->UpdateKnownUserPrefs(user_id, *dict_copy.get(), 69 user_manager_->UpdateKnownUserPrefs(user_id, *dict_copy.get(),
70 /* replace values */ true); 70 /* replace values */ true);
71 } 71 }
72 72
73 void TokenHandleUtil::MarkHandleInvalid(const user_manager::UserID& user_id) { 73 void TokenHandleUtil::MarkHandleInvalid(const user_manager::UserID& user_id) {
74 user_manager_->SetKnownUserStringPref(user_id, kTokenHandleStatusPref, 74 user_manager_->SetKnownUserStringPref(user_id, kTokenHandleStatusPref,
75 kHandleStatusInvalid); 75 kHandleStatusInvalid);
76 } 76 }
77 77
78 void TokenHandleUtil::CheckToken(const user_manager::UserID& user_id, 78 bool TokenHandleUtil::CheckToken(const user_manager::UserID& user_id,
79 const TokenValidationCallback& callback) { 79 const TokenValidationCallback& callback) {
80 const base::DictionaryValue* dict = nullptr; 80 const base::DictionaryValue* dict = nullptr;
81 std::string token; 81 std::string token;
82 if (!user_manager_->FindKnownUserPrefs(user_id, &dict)) { 82 if (!user_manager_->FindKnownUserPrefs(user_id, &dict)) {
83 callback.Run(user_id, UNKNOWN); 83 callback.Run(user_id, UNKNOWN);
84 return; 84 return true;
85 } 85 }
86 if (!dict->GetString(kTokenHandlePref, &token)) { 86 if (!dict->GetString(kTokenHandlePref, &token)) {
87 callback.Run(user_id, UNKNOWN); 87 callback.Run(user_id, UNKNOWN);
88 return; 88 return true;
89 } 89 }
90 90
91 if (!gaia_client_.get()) { 91 if (!gaia_client_.get()) {
92 auto request_context = 92 auto request_context =
93 chromeos::ProfileHelper::Get()->GetSigninProfile()->GetRequestContext(); 93 chromeos::ProfileHelper::Get()->GetSigninProfile()->GetRequestContext();
94 gaia_client_.reset(new gaia::GaiaOAuthClient(request_context)); 94 gaia_client_.reset(new gaia::GaiaOAuthClient(request_context));
95 } 95 }
96 if (validation_delegates_.count(token) != 0)
97 return false;
96 98
97 validation_delegates_.set( 99 validation_delegates_.set(
98 token, scoped_ptr<TokenDelegate>(new TokenDelegate( 100 token, scoped_ptr<TokenDelegate>(new TokenDelegate(
99 weak_factory_.GetWeakPtr(), user_id, token, callback))); 101 weak_factory_.GetWeakPtr(), user_id, token, callback)));
100 gaia_client_->GetTokenHandleInfo(token, kMaxRetries, 102 gaia_client_->GetTokenHandleInfo(token, kMaxRetries,
101 validation_delegates_.get(token)); 103 validation_delegates_.get(token));
104 return true;
102 } 105 }
103 106
104 void TokenHandleUtil::StoreTokenHandle(const user_manager::UserID& user_id, 107 void TokenHandleUtil::StoreTokenHandle(const user_manager::UserID& user_id,
105 const std::string& handle) { 108 const std::string& handle) {
106 user_manager_->SetKnownUserStringPref(user_id, kTokenHandlePref, handle); 109 user_manager_->SetKnownUserStringPref(user_id, kTokenHandlePref, handle);
107 user_manager_->SetKnownUserStringPref(user_id, kTokenHandleStatusPref, 110 user_manager_->SetKnownUserStringPref(user_id, kTokenHandleStatusPref,
108 kHandleStatusValid); 111 kHandleStatusValid);
109 } 112 }
110 113
111 void TokenHandleUtil::OnValidationComplete(const std::string& token) { 114 void TokenHandleUtil::OnValidationComplete(const std::string& token) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 if (token_info->GetInteger("expires_in", &expires_in)) 159 if (token_info->GetInteger("expires_in", &expires_in))
157 outcome = (expires_in < 0) ? INVALID : VALID; 160 outcome = (expires_in < 0) ? INVALID : VALID;
158 } 161 }
159 162
160 const base::TimeDelta duration = 163 const base::TimeDelta duration =
161 base::TimeTicks::Now() - tokeninfo_response_start_time_; 164 base::TimeTicks::Now() - tokeninfo_response_start_time_;
162 UMA_HISTOGRAM_TIMES("Login.TokenCheckResponseTime", duration); 165 UMA_HISTOGRAM_TIMES("Login.TokenCheckResponseTime", duration);
163 callback_.Run(user_id_, outcome); 166 callback_.Run(user_id_, outcome);
164 NotifyDone(); 167 NotifyDone();
165 } 168 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698