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

Side by Side Diff: components/signin/ios/browser/profile_oauth2_token_service_ios.mm

Issue 809313009: Make the SigninErrorController a PKS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Copyrighted: 2015 Created 5 years, 11 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 "components/signin/ios/browser/profile_oauth2_token_service_ios.h" 5 #include "components/signin/ios/browser/profile_oauth2_token_service_ios.h"
6 6
7 #include <Foundation/Foundation.h> 7 #include <Foundation/Foundation.h>
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 base::Time::FromDoubleT([expiration timeIntervalSince1970]); 123 base::Time::FromDoubleT([expiration timeIntervalSince1970]);
124 FireOnGetTokenSuccess(base::SysNSStringToUTF8(token), expiration_date); 124 FireOnGetTokenSuccess(base::SysNSStringToUTF8(token), expiration_date);
125 } else { 125 } else {
126 FireOnGetTokenFailure(auth_error); 126 FireOnGetTokenFailure(auth_error);
127 } 127 }
128 } 128 }
129 129
130 } // namespace 130 } // namespace
131 131
132 ProfileOAuth2TokenServiceIOS::AccountInfo::AccountInfo( 132 ProfileOAuth2TokenServiceIOS::AccountInfo::AccountInfo(
133 ProfileOAuth2TokenService* token_service, 133 SigninErrorController* signin_error_controller,
134 const std::string& account_id) 134 const std::string& account_id)
135 : token_service_(token_service), 135 : signin_error_controller_(signin_error_controller),
136 account_id_(account_id), 136 account_id_(account_id),
137 last_auth_error_(GoogleServiceAuthError::NONE) { 137 last_auth_error_(GoogleServiceAuthError::NONE) {
138 DCHECK(token_service_); 138 DCHECK(signin_error_controller_);
139 DCHECK(!account_id_.empty()); 139 DCHECK(!account_id_.empty());
140 token_service_->signin_error_controller()->AddProvider(this); 140 signin_error_controller_->AddProvider(this);
141 } 141 }
142 142
143 ProfileOAuth2TokenServiceIOS::AccountInfo::~AccountInfo() { 143 ProfileOAuth2TokenServiceIOS::AccountInfo::~AccountInfo() {
144 token_service_->signin_error_controller()->RemoveProvider(this); 144 signin_error_controller_->RemoveProvider(this);
145 } 145 }
146 146
147 void ProfileOAuth2TokenServiceIOS::AccountInfo::SetLastAuthError( 147 void ProfileOAuth2TokenServiceIOS::AccountInfo::SetLastAuthError(
148 const GoogleServiceAuthError& error) { 148 const GoogleServiceAuthError& error) {
149 if (error.state() != last_auth_error_.state()) { 149 if (error.state() != last_auth_error_.state()) {
150 last_auth_error_ = error; 150 last_auth_error_ = error;
151 token_service_->signin_error_controller()->AuthStatusChanged(); 151 signin_error_controller_->AuthStatusChanged();
152 } 152 }
153 } 153 }
154 154
155 std::string ProfileOAuth2TokenServiceIOS::AccountInfo::GetAccountId() const { 155 std::string ProfileOAuth2TokenServiceIOS::AccountInfo::GetAccountId() const {
156 return account_id_; 156 return account_id_;
157 } 157 }
158 158
159 std::string ProfileOAuth2TokenServiceIOS::AccountInfo::GetUsername() const { 159 std::string ProfileOAuth2TokenServiceIOS::AccountInfo::GetUsername() const {
160 // TODO(rogerta): when |account_id| becomes the obfuscated gaia id, this 160 // TODO(rogerta): when |account_id| becomes the obfuscated gaia id, this
161 // will need to be changed. 161 // will need to be changed.
162 return account_id_; 162 return account_id_;
163 } 163 }
164 164
165 GoogleServiceAuthError 165 GoogleServiceAuthError
166 ProfileOAuth2TokenServiceIOS::AccountInfo::GetAuthStatus() const { 166 ProfileOAuth2TokenServiceIOS::AccountInfo::GetAuthStatus() const {
167 return last_auth_error_; 167 return last_auth_error_;
168 } 168 }
169 169
170 ProfileOAuth2TokenServiceIOS::ProfileOAuth2TokenServiceIOS() 170 ProfileOAuth2TokenServiceIOS::ProfileOAuth2TokenServiceIOS()
171 : ProfileOAuth2TokenService() { 171 : ProfileOAuth2TokenService() {
172 DCHECK(thread_checker_.CalledOnValidThread()); 172 DCHECK(thread_checker_.CalledOnValidThread());
173 } 173 }
174 174
175 ProfileOAuth2TokenServiceIOS::~ProfileOAuth2TokenServiceIOS() { 175 ProfileOAuth2TokenServiceIOS::~ProfileOAuth2TokenServiceIOS() {
176 DCHECK(thread_checker_.CalledOnValidThread()); 176 DCHECK(thread_checker_.CalledOnValidThread());
177 } 177 }
178 178
179 void ProfileOAuth2TokenServiceIOS::Initialize(SigninClient* client) { 179 void ProfileOAuth2TokenServiceIOS::Initialize(
180 SigninClient* client, SigninErrorController* signin_error_controller) {
180 DCHECK(thread_checker_.CalledOnValidThread()); 181 DCHECK(thread_checker_.CalledOnValidThread());
181 ProfileOAuth2TokenService::Initialize(client); 182 ProfileOAuth2TokenService::Initialize(client, signin_error_controller);
182 } 183 }
183 184
184 void ProfileOAuth2TokenServiceIOS::Shutdown() { 185 void ProfileOAuth2TokenServiceIOS::Shutdown() {
185 DCHECK(thread_checker_.CalledOnValidThread()); 186 DCHECK(thread_checker_.CalledOnValidThread());
186 CancelAllRequests(); 187 CancelAllRequests();
187 accounts_.clear(); 188 accounts_.clear();
188 ProfileOAuth2TokenService::Shutdown(); 189 ProfileOAuth2TokenService::Shutdown();
189 } 190 }
190 191
191 ios::ProfileOAuth2TokenServiceIOSProvider* 192 ios::ProfileOAuth2TokenServiceIOSProvider*
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 GoogleServiceAuthError::NONE) { 326 GoogleServiceAuthError::NONE) {
326 // No need to update the account if it is already a known account and if 327 // No need to update the account if it is already a known account and if
327 // there is no auth error. 328 // there is no auth error.
328 return; 329 return;
329 } 330 }
330 331
331 if (account_present) { 332 if (account_present) {
332 CancelRequestsForAccount(account_id); 333 CancelRequestsForAccount(account_id);
333 ClearCacheForAccount(account_id); 334 ClearCacheForAccount(account_id);
334 } else { 335 } else {
335 accounts_[account_id].reset(new AccountInfo(this, account_id)); 336 accounts_[account_id].reset(
337 new AccountInfo(signin_error_controller(), account_id));
336 } 338 }
337 UpdateAuthError(account_id, GoogleServiceAuthError::AuthErrorNone()); 339 UpdateAuthError(account_id, GoogleServiceAuthError::AuthErrorNone());
338 FireRefreshTokenAvailable(account_id); 340 FireRefreshTokenAvailable(account_id);
339 } 341 }
340 342
341 void ProfileOAuth2TokenServiceIOS::RemoveAccount( 343 void ProfileOAuth2TokenServiceIOS::RemoveAccount(
342 const std::string& account_id) { 344 const std::string& account_id) {
343 DCHECK(thread_checker_.CalledOnValidThread()); 345 DCHECK(thread_checker_.CalledOnValidThread());
344 DCHECK(!account_id.empty()); 346 DCHECK(!account_id.empty());
345 347
346 if (accounts_.count(account_id) > 0) { 348 if (accounts_.count(account_id) > 0) {
347 CancelRequestsForAccount(account_id); 349 CancelRequestsForAccount(account_id);
348 ClearCacheForAccount(account_id); 350 ClearCacheForAccount(account_id);
349 accounts_.erase(account_id); 351 accounts_.erase(account_id);
350 FireRefreshTokenRevoked(account_id); 352 FireRefreshTokenRevoked(account_id);
351 } 353 }
352 } 354 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698