OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #import "ios/chrome/browser/desktop_promotion/desktop_promotion_sync_observer.h" | 5 #import "ios/chrome/browser/desktop_promotion/desktop_promotion_sync_observer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 : pref_service_(pref_service), sync_service_(sync_service) { | 31 : pref_service_(pref_service), sync_service_(sync_service) { |
32 DCHECK(pref_service_); | 32 DCHECK(pref_service_); |
33 DCHECK(sync_service_); | 33 DCHECK(sync_service_); |
34 sync_service_->AddObserver(this); | 34 sync_service_->AddObserver(this); |
35 } | 35 } |
36 | 36 |
37 DesktopPromotionSyncObserver::~DesktopPromotionSyncObserver() { | 37 DesktopPromotionSyncObserver::~DesktopPromotionSyncObserver() { |
38 sync_service_->RemoveObserver(this); | 38 sync_service_->RemoveObserver(this); |
39 } | 39 } |
40 | 40 |
41 void DesktopPromotionSyncObserver::OnStateChanged() { | 41 void DesktopPromotionSyncObserver::OnStateChanged(syncer::SyncService* sync) { |
42 if (desktop_metrics_logger_initiated_ || | 42 if (desktop_metrics_logger_initiated_ || |
43 !sync_service_->GetActiveDataTypes().Has(syncer::PRIORITY_PREFERENCES)) { | 43 !sync_service_->GetActiveDataTypes().Has(syncer::PRIORITY_PREFERENCES)) { |
44 return; | 44 return; |
45 } | 45 } |
46 | 46 |
47 desktop_metrics_logger_initiated_ = true; | 47 desktop_metrics_logger_initiated_ = true; |
48 bool done_logging = | 48 bool done_logging = |
49 pref_service_->GetBoolean(prefs::kDesktopIOSPromotionDone); | 49 pref_service_->GetBoolean(prefs::kDesktopIOSPromotionDone); |
50 double last_impression = | 50 double last_impression = |
51 pref_service_->GetDouble(prefs::kDesktopIOSPromotionLastImpression); | 51 pref_service_->GetDouble(prefs::kDesktopIOSPromotionLastImpression); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // If the user saw this promotion type, log that it could be a reason | 83 // If the user saw this promotion type, log that it could be a reason |
84 // for the signin. | 84 // for the signin. |
85 if ((1 << i) & shown_entrypoints) | 85 if ((1 << i) & shown_entrypoints) |
86 UMA_HISTOGRAM_ENUMERATION("DesktopIOSPromotion.NoSMS.IOSSigninReason", | 86 UMA_HISTOGRAM_ENUMERATION("DesktopIOSPromotion.NoSMS.IOSSigninReason", |
87 i, entrypoint_prefixes_count + 1); | 87 i, entrypoint_prefixes_count + 1); |
88 } | 88 } |
89 } | 89 } |
90 pref_service_->SetBoolean(prefs::kDesktopIOSPromotionDone, true); | 90 pref_service_->SetBoolean(prefs::kDesktopIOSPromotionDone, true); |
91 sync_service_->RemoveObserver(this); | 91 sync_service_->RemoveObserver(this); |
92 } | 92 } |
OLD | NEW |