| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 // When sign-in enforcement is not dropped, OnSignedOut will also clear all | 104 // When sign-in enforcement is not dropped, OnSignedOut will also clear all |
| 105 // the GCM data and a new GCM ID will be retrieved after the user signs in | 105 // the GCM data and a new GCM ID will be retrieved after the user signs in |
| 106 // again. Otherwise, the user sign-out will not affect the existing GCM | 106 // again. Otherwise, the user sign-out will not affect the existing GCM |
| 107 // data. | 107 // data. |
| 108 driver_->OnSignedOut(); | 108 driver_->OnSignedOut(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 std::string GCMProfileService::IdentityObserver::SignedInUserName() const { | 111 std::string GCMProfileService::IdentityObserver::SignedInUserName() const { |
| 112 return driver_->IsStarted() ? account_id_ : std::string(); | 112 return driver_->IsStarted() ? account_id_ : std::string(); |
| 113 } | 113 } |
| 114 | |
| 115 void GCMProfileService::IdentityObserver::StartAccountTracker() { | 114 void GCMProfileService::IdentityObserver::StartAccountTracker() { |
| 116 if (gcm_account_tracker_) | 115 if (gcm_account_tracker_) |
| 117 return; | 116 return; |
| 118 | 117 |
| 119 scoped_ptr<gaia::AccountTracker> gaia_account_tracker( | 118 scoped_ptr<gaia::AccountTracker> gaia_account_tracker( |
| 120 new gaia::AccountTracker(identity_provider_.get(), | 119 new gaia::AccountTracker(identity_provider_.get(), |
| 121 profile_->GetRequestContext())); | 120 profile_->GetRequestContext())); |
| 122 | 121 |
| 123 gcm_account_tracker_.reset( | 122 gcm_account_tracker_.reset(new GCMAccountTracker( |
| 124 new GCMAccountTracker(gaia_account_tracker.Pass(), driver_)); | 123 gaia_account_tracker.Pass(), driver_, profile_->GetPrefs())); |
| 125 | 124 |
| 126 gcm_account_tracker_->Start(); | 125 gcm_account_tracker_->Start(); |
| 127 } | 126 } |
| 128 | 127 |
| 129 #endif // !defined(OS_ANDROID) | 128 #endif // !defined(OS_ANDROID) |
| 130 | 129 |
| 131 // static | 130 // static |
| 132 bool GCMProfileService::IsGCMEnabled(Profile* profile) { | 131 bool GCMProfileService::IsGCMEnabled(Profile* profile) { |
| 133 return profile->GetPrefs()->GetBoolean(prefs::kGCMChannelEnabled); | 132 return profile->GetPrefs()->GetBoolean(prefs::kGCMChannelEnabled); |
| 134 } | 133 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 #endif // defined(OS_ANDROID) | 222 #endif // defined(OS_ANDROID) |
| 224 } | 223 } |
| 225 | 224 |
| 226 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { | 225 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { |
| 227 driver_.reset(driver); | 226 driver_.reset(driver); |
| 228 if (identity_observer_) | 227 if (identity_observer_) |
| 229 identity_observer_.reset(new IdentityObserver(profile_, driver)); | 228 identity_observer_.reset(new IdentityObserver(profile_, driver)); |
| 230 } | 229 } |
| 231 | 230 |
| 232 } // namespace gcm | 231 } // namespace gcm |
| OLD | NEW |