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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 content::NotificationService::current()->Notify( | 184 content::NotificationService::current()->Notify( |
185 chrome::NOTIFICATION_TOKENS_CLEARED, | 185 chrome::NOTIFICATION_TOKENS_CLEARED, |
186 content::Source<TokenService>(this), | 186 content::Source<TokenService>(this), |
187 content::NotificationService::NoDetails()); | 187 content::NotificationService::NoDetails()); |
188 } | 188 } |
189 | 189 |
190 bool TokenService::TokensLoadedFromDB() const { | 190 bool TokenService::TokensLoadedFromDB() const { |
191 return tokens_loaded_; | 191 return tokens_loaded_; |
192 } | 192 } |
193 | 193 |
| 194 void TokenService::set_tokens_loaded(bool loaded) { |
| 195 tokens_loaded_ = loaded; |
| 196 } |
| 197 |
194 // static | 198 // static |
195 int TokenService::GetServiceIndex(const std::string& service) { | 199 int TokenService::GetServiceIndex(const std::string& service) { |
196 for (size_t i = 0; i < arraysize(kServices); ++i) { | 200 for (size_t i = 0; i < arraysize(kServices); ++i) { |
197 if (kServices[i] == service) | 201 if (kServices[i] == service) |
198 return i; | 202 return i; |
199 } | 203 } |
200 return -1; | 204 return -1; |
201 } | 205 } |
202 | 206 |
203 bool TokenService::AreCredentialsValid() const { | 207 bool TokenService::AreCredentialsValid() const { |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 if (!in_memory_tokens->count(service) && db_tokens.count(service)) { | 431 if (!in_memory_tokens->count(service) && db_tokens.count(service)) { |
428 std::string db_token = db_tokens.find(service)->second; | 432 std::string db_token = db_tokens.find(service)->second; |
429 if (!db_token.empty()) { | 433 if (!db_token.empty()) { |
430 VLOG(1) << "Loading " << service << " token from DB: " << db_token; | 434 VLOG(1) << "Loading " << service << " token from DB: " << db_token; |
431 (*in_memory_tokens)[service] = db_token; | 435 (*in_memory_tokens)[service] = db_token; |
432 FireTokenAvailableNotification(service, db_token); | 436 FireTokenAvailableNotification(service, db_token); |
433 // Failures are only for network errors. | 437 // Failures are only for network errors. |
434 } | 438 } |
435 } | 439 } |
436 } | 440 } |
OLD | NEW |