| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/cross_device_promo.h" | 5 #include "chrome/browser/signin/cross_device_promo.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 | 380 |
| 381 void CrossDevicePromo::UnregisterForCookieChanges() { | 381 void CrossDevicePromo::UnregisterForCookieChanges() { |
| 382 cookie_manager_service_->RemoveObserver(this); | 382 cookie_manager_service_->RemoveObserver(this); |
| 383 } | 383 } |
| 384 | 384 |
| 385 base::Time CrossDevicePromo::GetTimePref(const std::string& pref) { | 385 base::Time CrossDevicePromo::GetTimePref(const std::string& pref) { |
| 386 return base::Time::FromInternalValue(prefs_->GetInt64(pref)); | 386 return base::Time::FromInternalValue(prefs_->GetInt64(pref)); |
| 387 } | 387 } |
| 388 | 388 |
| 389 void CrossDevicePromo::OnGaiaAccountsInCookieUpdated( | 389 void CrossDevicePromo::OnGaiaAccountsInCookieUpdated( |
| 390 const std::vector<std::pair<std::string, bool>>& accounts, | 390 const std::vector<gaia::ListedAccount>& accounts, |
| 391 const GoogleServiceAuthError& error) { | 391 const GoogleServiceAuthError& error) { |
| 392 VLOG(1) << "CrossDevicePromo::OnGaiaAccountsInCookieUpdated. " | 392 VLOG(1) << "CrossDevicePromo::OnGaiaAccountsInCookieUpdated. " |
| 393 << accounts.size() << " accounts with auth error " << error.state(); | 393 << accounts.size() << " accounts with auth error " << error.state(); |
| 394 if (error.state() != GoogleServiceAuthError::State::NONE) | 394 if (error.state() != GoogleServiceAuthError::State::NONE) |
| 395 return; | 395 return; |
| 396 | 396 |
| 397 // Multiple accounts seen - clear the pref. | 397 // Multiple accounts seen - clear the pref. |
| 398 bool single_account = accounts.size() == 1; | 398 bool single_account = accounts.size() == 1; |
| 399 bool has_pref = | 399 bool has_pref = |
| 400 prefs_->HasPrefPath(prefs::kCrossDevicePromoObservedSingleAccountCookie); | 400 prefs_->HasPrefPath(prefs::kCrossDevicePromoObservedSingleAccountCookie); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 419 } | 419 } |
| 420 | 420 |
| 421 void CrossDevicePromo::MarkPromoInactive() { | 421 void CrossDevicePromo::MarkPromoInactive() { |
| 422 VLOG(1) << "CrossDevicePromo::MarkPromoInactive."; | 422 VLOG(1) << "CrossDevicePromo::MarkPromoInactive."; |
| 423 if (prefs_->GetBoolean(prefs::kCrossDevicePromoActive)) { | 423 if (prefs_->GetBoolean(prefs::kCrossDevicePromoActive)) { |
| 424 prefs_->SetBoolean(prefs::kCrossDevicePromoActive, false); | 424 prefs_->SetBoolean(prefs::kCrossDevicePromoActive, false); |
| 425 FOR_EACH_OBSERVER(CrossDevicePromo::Observer, observer_list_, | 425 FOR_EACH_OBSERVER(CrossDevicePromo::Observer, observer_list_, |
| 426 OnPromoActivationChanged(false)); | 426 OnPromoActivationChanged(false)); |
| 427 } | 427 } |
| 428 } | 428 } |
| OLD | NEW |