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