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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 signin_metrics::LogXDevicePromoInitialized(signin_metrics::INITIALIZED); | 276 signin_metrics::LogXDevicePromoInitialized(signin_metrics::INITIALIZED); |
277 return; | 277 return; |
278 } | 278 } |
279 | 279 |
280 void CrossDevicePromo::MarkPromoShouldBeShown() { | 280 void CrossDevicePromo::MarkPromoShouldBeShown() { |
281 VLOG(1) << "CrossDevicePromo::MarkPromoShouldBeShown."; | 281 VLOG(1) << "CrossDevicePromo::MarkPromoShouldBeShown."; |
282 DCHECK(!prefs_->GetBoolean(prefs::kCrossDevicePromoOptedOut)); | 282 DCHECK(!prefs_->GetBoolean(prefs::kCrossDevicePromoOptedOut)); |
283 | 283 |
284 if (!prefs_->GetBoolean(prefs::kCrossDevicePromoShouldBeShown)) { | 284 if (!prefs_->GetBoolean(prefs::kCrossDevicePromoShouldBeShown)) { |
285 prefs_->SetBoolean(prefs::kCrossDevicePromoShouldBeShown, true); | 285 prefs_->SetBoolean(prefs::kCrossDevicePromoShouldBeShown, true); |
286 FOR_EACH_OBSERVER(CrossDevicePromo::Observer, observer_list_, | 286 for (CrossDevicePromo::Observer& observer : observer_list_) |
287 OnPromoEligibilityChanged(true)); | 287 observer.OnPromoEligibilityChanged(true); |
288 } | 288 } |
289 } | 289 } |
290 | 290 |
291 void CrossDevicePromo::MarkPromoShouldNotBeShown() { | 291 void CrossDevicePromo::MarkPromoShouldNotBeShown() { |
292 VLOG(1) << "CrossDevicePromo::MarkPromoShouldNotBeShown."; | 292 VLOG(1) << "CrossDevicePromo::MarkPromoShouldNotBeShown."; |
293 if (prefs_->GetBoolean(prefs::kCrossDevicePromoShouldBeShown)) { | 293 if (prefs_->GetBoolean(prefs::kCrossDevicePromoShouldBeShown)) { |
294 prefs_->SetBoolean(prefs::kCrossDevicePromoShouldBeShown, false); | 294 prefs_->SetBoolean(prefs::kCrossDevicePromoShouldBeShown, false); |
295 FOR_EACH_OBSERVER(CrossDevicePromo::Observer, observer_list_, | 295 for (CrossDevicePromo::Observer& observer : observer_list_) |
296 OnPromoEligibilityChanged(false)); | 296 observer.OnPromoEligibilityChanged(false); |
297 } | 297 } |
298 } | 298 } |
299 | 299 |
300 bool CrossDevicePromo::CheckPromoEligibility() { | 300 bool CrossDevicePromo::CheckPromoEligibility() { |
301 if (!initialized_) | 301 if (!initialized_) |
302 return false; | 302 return false; |
303 | 303 |
304 if (prefs_->GetBoolean(prefs::kCrossDevicePromoOptedOut)) { | 304 if (prefs_->GetBoolean(prefs::kCrossDevicePromoOptedOut)) { |
305 signin_metrics::LogXDevicePromoEligible(signin_metrics::OPTED_OUT); | 305 signin_metrics::LogXDevicePromoEligible(signin_metrics::OPTED_OUT); |
306 return false; | 306 return false; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 device_activity_fetcher_->Start(); | 450 device_activity_fetcher_->Start(); |
451 } | 451 } |
452 | 452 |
453 void CrossDevicePromo::RegisterForCookieChanges() { | 453 void CrossDevicePromo::RegisterForCookieChanges() { |
454 cookie_manager_service_->AddObserver(this); | 454 cookie_manager_service_->AddObserver(this); |
455 } | 455 } |
456 | 456 |
457 void CrossDevicePromo::UnregisterForCookieChanges() { | 457 void CrossDevicePromo::UnregisterForCookieChanges() { |
458 cookie_manager_service_->RemoveObserver(this); | 458 cookie_manager_service_->RemoveObserver(this); |
459 } | 459 } |
OLD | NEW |