| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/services/gcm/gcm_profile_service.h" | 5 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 gcm_account_tracker_->Start(); | 114 gcm_account_tracker_->Start(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void GCMProfileService::IdentityObserver::OnActiveAccountLogout() { | 117 void GCMProfileService::IdentityObserver::OnActiveAccountLogout() { |
| 118 account_id_.clear(); | 118 account_id_.clear(); |
| 119 | 119 |
| 120 // Check is necessary to not crash browser_tests. | 120 // Check is necessary to not crash browser_tests. |
| 121 if (gcm_account_tracker_) | 121 if (gcm_account_tracker_) |
| 122 gcm_account_tracker_->Stop(); | 122 gcm_account_tracker_->Stop(); |
| 123 // TODO(fgorski): If we purge here, what should happen when we get | 123 // When sign-in enforcement is not dropped, OnSignedOut will also clear all |
| 124 // OnActiveAccountLogin() right after that? | 124 // the GCM data and a new GCM ID will be retrieved after the user signs in |
| 125 driver_->Purge(); | 125 // again. Otherwise, the user sign-out will not affect the existing GCM |
| 126 // data. |
| 127 driver_->OnSignedOut(); |
| 126 } | 128 } |
| 127 | 129 |
| 128 std::string GCMProfileService::IdentityObserver::SignedInUserName() const { | 130 std::string GCMProfileService::IdentityObserver::SignedInUserName() const { |
| 129 return driver_->IsStarted() ? account_id_ : std::string(); | 131 return driver_->IsStarted() ? account_id_ : std::string(); |
| 130 } | 132 } |
| 131 | 133 |
| 132 void GCMProfileService::IdentityObserver::AccountsUpdated( | 134 void GCMProfileService::IdentityObserver::AccountsUpdated( |
| 133 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) { | 135 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) { |
| 134 driver_->SetAccountTokens(account_tokens); | 136 driver_->SetAccountTokens(account_tokens); |
| 135 } | 137 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 return identity_observer_ ? identity_observer_->SignedInUserName() | 230 return identity_observer_ ? identity_observer_->SignedInUserName() |
| 229 : std::string(); | 231 : std::string(); |
| 230 #endif // defined(OS_ANDROID) | 232 #endif // defined(OS_ANDROID) |
| 231 } | 233 } |
| 232 | 234 |
| 233 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { | 235 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { |
| 234 driver_.reset(driver); | 236 driver_.reset(driver); |
| 235 } | 237 } |
| 236 | 238 |
| 237 } // namespace gcm | 239 } // namespace gcm |
| OLD | NEW |