| 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 <map> | 7 #include <map> |
| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 gcm_account_tracker_->Start(); | 110 gcm_account_tracker_->Start(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void GCMProfileService::IdentityObserver::OnActiveAccountLogout() { | 113 void GCMProfileService::IdentityObserver::OnActiveAccountLogout() { |
| 114 account_id_.clear(); | 114 account_id_.clear(); |
| 115 | 115 |
| 116 // Check is necessary to not crash browser_tests. | 116 // Check is necessary to not crash browser_tests. |
| 117 if (gcm_account_tracker_) | 117 if (gcm_account_tracker_) |
| 118 gcm_account_tracker_->Stop(); | 118 gcm_account_tracker_->Stop(); |
| 119 // When sign-in enforcement is not dropped, OnSignedOut will also clear all | 119 // TODO(fgorski): If we purge here, what should happen when we get |
| 120 // the GCM data and a new GCM ID will be retrieved after the user signs in | 120 // OnActiveAccountLogin() right after that? |
| 121 // again. Otherwise, the user sign-out will not affect the existing GCM | 121 driver_->Purge(); |
| 122 // data. | |
| 123 driver_->OnSignedOut(); | |
| 124 } | 122 } |
| 125 | 123 |
| 126 std::string GCMProfileService::IdentityObserver::SignedInUserName() const { | 124 std::string GCMProfileService::IdentityObserver::SignedInUserName() const { |
| 127 return driver_->IsStarted() ? account_id_ : std::string(); | 125 return driver_->IsStarted() ? account_id_ : std::string(); |
| 128 } | 126 } |
| 129 | 127 |
| 130 void GCMProfileService::IdentityObserver::AccountsUpdated( | 128 void GCMProfileService::IdentityObserver::AccountsUpdated( |
| 131 const std::map<std::string, std::string>& account_tokens) { | 129 const std::map<std::string, std::string>& account_tokens) { |
| 132 driver_->SetAccountsForCheckin(account_tokens); | 130 driver_->SetAccountsForCheckin(account_tokens); |
| 133 } | 131 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 return identity_observer_ ? identity_observer_->SignedInUserName() | 216 return identity_observer_ ? identity_observer_->SignedInUserName() |
| 219 : std::string(); | 217 : std::string(); |
| 220 #endif // defined(OS_ANDROID) | 218 #endif // defined(OS_ANDROID) |
| 221 } | 219 } |
| 222 | 220 |
| 223 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { | 221 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { |
| 224 driver_.reset(driver); | 222 driver_.reset(driver); |
| 225 } | 223 } |
| 226 | 224 |
| 227 } // namespace gcm | 225 } // namespace gcm |
| OLD | NEW |