| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/token_service.h" | 5 #include "chrome/browser/signin/token_service.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 const std::string& service, | 246 const std::string& service, |
| 247 const GoogleServiceAuthError& error) { | 247 const GoogleServiceAuthError& error) { |
| 248 | 248 |
| 249 TokenRequestFailedDetails details(service, error); | 249 TokenRequestFailedDetails details(service, error); |
| 250 content::NotificationService::current()->Notify( | 250 content::NotificationService::current()->Notify( |
| 251 chrome::NOTIFICATION_TOKEN_REQUEST_FAILED, | 251 chrome::NOTIFICATION_TOKEN_REQUEST_FAILED, |
| 252 content::Source<TokenService>(this), | 252 content::Source<TokenService>(this), |
| 253 content::Details<const TokenRequestFailedDetails>(&details)); | 253 content::Details<const TokenRequestFailedDetails>(&details)); |
| 254 } | 254 } |
| 255 | 255 |
| 256 void TokenService::SaveCachedSyncTokenToDB(const std::string& sync_token) { |
| 257 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 258 VLOG(1) << "Got an authorization token for sync."; |
| 259 token_map_[GaiaConstants::kSyncService] = sync_token; |
| 260 SaveAuthTokenToDB(GaiaConstants::kSyncService, sync_token); |
| 261 TokenAvailableDetails details(GaiaConstants::kSyncService, sync_token); |
| 262 content::NotificationService::current()->Notify( |
| 263 chrome::NOTIFICATION_TOKEN_AVAILABLE, |
| 264 content::Source<TokenService>(this), |
| 265 content::Details<const TokenAvailableDetails>(&details)); |
| 266 } |
| 267 |
| 256 void TokenService::IssueAuthTokenForTest(const std::string& service, | 268 void TokenService::IssueAuthTokenForTest(const std::string& service, |
| 257 const std::string& auth_token) { | 269 const std::string& auth_token) { |
| 258 token_map_[service] = auth_token; | 270 token_map_[service] = auth_token; |
| 259 FireTokenAvailableNotification(service, auth_token); | 271 FireTokenAvailableNotification(service, auth_token); |
| 260 } | 272 } |
| 261 | 273 |
| 262 void TokenService::OnIssueAuthTokenSuccess(const std::string& service, | 274 void TokenService::OnIssueAuthTokenSuccess(const std::string& service, |
| 263 const std::string& auth_token) { | 275 const std::string& auth_token) { |
| 264 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 276 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 265 VLOG(1) << "Got an authorization token for " << service; | 277 VLOG(1) << "Got an authorization token for " << service; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 } | 400 } |
| 389 | 401 |
| 390 void TokenService::Observe(int type, | 402 void TokenService::Observe(int type, |
| 391 const content::NotificationSource& source, | 403 const content::NotificationSource& source, |
| 392 const content::NotificationDetails& details) { | 404 const content::NotificationDetails& details) { |
| 393 DCHECK_EQ(type, chrome::NOTIFICATION_TOKEN_UPDATED); | 405 DCHECK_EQ(type, chrome::NOTIFICATION_TOKEN_UPDATED); |
| 394 TokenAvailableDetails* tok_details = | 406 TokenAvailableDetails* tok_details = |
| 395 content::Details<TokenAvailableDetails>(details).ptr(); | 407 content::Details<TokenAvailableDetails>(details).ptr(); |
| 396 OnIssueAuthTokenSuccess(tok_details->service(), tok_details->token()); | 408 OnIssueAuthTokenSuccess(tok_details->service(), tok_details->token()); |
| 397 } | 409 } |
| OLD | NEW |