| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 151 // Try to track down http://crbug.com/121755 - we should never clear the | 151 // Try to track down http://crbug.com/121755 - we should never clear the |
| 152 // token DB while we're still logged in. | 152 // token DB while we're still logged in. |
| 153 if (profile_) { | 153 if (profile_) { |
| 154 std::string user = profile_->GetPrefs()->GetString( | 154 std::string user = profile_->GetPrefs()->GetString( |
| 155 prefs::kGoogleServicesUsername); | 155 prefs::kGoogleServicesUsername); |
| 156 CHECK(user.empty()); | 156 CHECK(user.empty()); |
| 157 } | 157 } |
| 158 if (web_data_service_.get()) | 158 if (web_data_service_.get()) |
| 159 web_data_service_->RemoveAllTokens(); | 159 web_data_service_->RemoveAllTokens(); |
| 160 |
| 161 content::NotificationService::current()->Notify( |
| 162 chrome::NOTIFICATION_TOKENS_CLEARED, |
| 163 content::Source<TokenService>(this), |
| 164 content::NotificationService::NoDetails()); |
| 160 } | 165 } |
| 161 | 166 |
| 162 bool TokenService::TokensLoadedFromDB() const { | 167 bool TokenService::TokensLoadedFromDB() const { |
| 163 return tokens_loaded_; | 168 return tokens_loaded_; |
| 164 } | 169 } |
| 165 | 170 |
| 166 // static | 171 // static |
| 167 int TokenService::GetServiceIndex(const std::string& service) { | 172 int TokenService::GetServiceIndex(const std::string& service) { |
| 168 for (size_t i = 0; i < arraysize(kServices); ++i) { | 173 for (size_t i = 0; i < arraysize(kServices); ++i) { |
| 169 if (kServices[i] == service) | 174 if (kServices[i] == service) |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 } | 388 } |
| 384 | 389 |
| 385 void TokenService::Observe(int type, | 390 void TokenService::Observe(int type, |
| 386 const content::NotificationSource& source, | 391 const content::NotificationSource& source, |
| 387 const content::NotificationDetails& details) { | 392 const content::NotificationDetails& details) { |
| 388 DCHECK_EQ(type, chrome::NOTIFICATION_TOKEN_UPDATED); | 393 DCHECK_EQ(type, chrome::NOTIFICATION_TOKEN_UPDATED); |
| 389 TokenAvailableDetails* tok_details = | 394 TokenAvailableDetails* tok_details = |
| 390 content::Details<TokenAvailableDetails>(details).ptr(); | 395 content::Details<TokenAvailableDetails>(details).ptr(); |
| 391 OnIssueAuthTokenSuccess(tok_details->service(), tok_details->token()); | 396 OnIssueAuthTokenSuccess(tok_details->service(), tok_details->token()); |
| 392 } | 397 } |
| OLD | NEW |