Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: chrome/browser/ui/desktop_ios_promotion/desktop_ios_promotion_controller.cc

Issue 2803293002: Create Bookmark Footnote desktop iOS promotion (Closed)
Patch Set: Add footnote promotion Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "chrome/browser/ui/desktop_ios_promotion/desktop_ios_promotion_controll er.h" 5 #include "chrome/browser/ui/desktop_ios_promotion/desktop_ios_promotion_controll er.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/field_trial_params.h" 8 #include "base/metrics/field_trial_params.h"
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 10 matching lines...) Expand all
21 Profile* profile, 21 Profile* profile,
22 DesktopIOSPromotionView* promotion_view, 22 DesktopIOSPromotionView* promotion_view,
23 desktop_ios_promotion::PromotionEntryPoint entry_point) 23 desktop_ios_promotion::PromotionEntryPoint entry_point)
24 : profile_prefs_(profile->GetPrefs()), 24 : profile_prefs_(profile->GetPrefs()),
25 entry_point_(entry_point), 25 entry_point_(entry_point),
26 sms_service_(SMSServiceFactory::GetForProfile(profile)), 26 sms_service_(SMSServiceFactory::GetForProfile(profile)),
27 promotion_view_(promotion_view), 27 promotion_view_(promotion_view),
28 dismissal_reason_( 28 dismissal_reason_(
29 desktop_ios_promotion::PromotionDismissalReason::FOCUS_LOST), 29 desktop_ios_promotion::PromotionDismissalReason::FOCUS_LOST),
30 weak_ptr_factory_(this) { 30 weak_ptr_factory_(this) {
31 sms_service_->QueryPhoneNumber( 31 if (entry_point_ !=
32 base::Bind(&DesktopIOSPromotionController::OnGotPhoneNumber, 32 desktop_ios_promotion::PromotionEntryPoint::BOOKMARKS_FOOTNOTE) {
33 weak_ptr_factory_.GetWeakPtr())); 33 // Footnote promotion doesn't have a phone number.
34 sms_service_->QueryPhoneNumber(
35 base::Bind(&DesktopIOSPromotionController::OnGotPhoneNumber,
36 weak_ptr_factory_.GetWeakPtr()));
37 }
34 } 38 }
35 39
36 DesktopIOSPromotionController::~DesktopIOSPromotionController() { 40 DesktopIOSPromotionController::~DesktopIOSPromotionController() {
37 desktop_ios_promotion::LogDismissalReason(dismissal_reason_, entry_point_); 41 desktop_ios_promotion::LogDismissalReason(dismissal_reason_, entry_point_);
38 } 42 }
39 43
40 void DesktopIOSPromotionController::OnSendSMSClicked() { 44 void DesktopIOSPromotionController::OnSendSMSClicked() {
41 sms_service_->SendSMS(desktop_ios_promotion::GetSMSID(), 45 sms_service_->SendSMS(desktop_ios_promotion::GetSMSID(),
42 base::Bind(&DesktopIOSPromotionController::OnSendSMS, 46 base::Bind(&DesktopIOSPromotionController::OnSendSMS,
43 weak_ptr_factory_.GetWeakPtr())); 47 weak_ptr_factory_.GetWeakPtr()));
44 48
45 // Update Profile prefs. 49 // Update Profile prefs.
46 profile_prefs_->SetInteger(prefs::kIOSPromotionSMSEntryPoint, 50 profile_prefs_->SetInteger(prefs::kIOSPromotionSMSEntryPoint,
47 static_cast<int>(entry_point_)); 51 static_cast<int>(entry_point_));
48 52
49 // Update dismissal reason. 53 // Update dismissal reason.
50 dismissal_reason_ = desktop_ios_promotion::PromotionDismissalReason::SEND_SMS; 54 dismissal_reason_ = desktop_ios_promotion::PromotionDismissalReason::SEND_SMS;
51 } 55 }
52 56
53 void DesktopIOSPromotionController::OnPromotionShown() { 57 void DesktopIOSPromotionController::OnPromotionShown() {
58 // Update histograms.
sky 2017/05/17 16:00:41 Remove this comment as it just documents what the
mrefaat 2017/05/17 19:44:56 Done.
59 UMA_HISTOGRAM_ENUMERATION(
60 "DesktopIOSPromotion.ImpressionFromEntryPoint",
61 static_cast<int>(entry_point_),
62 static_cast<int>(
63 desktop_ios_promotion::PromotionEntryPoint::ENTRY_POINT_MAX_VALUE));
64
65 if (entry_point_ ==
66 desktop_ios_promotion::PromotionEntryPoint::FOOTNOTE_FOLLOWUP_BUBBLE) {
67 // We don't want to update sync with the impression of this entrypoint.
68 return;
69 }
70
54 // update the impressions count. 71 // update the impressions count.
55 PrefService* local_state = g_browser_process->local_state(); 72 PrefService* local_state = g_browser_process->local_state();
56 int impressions = local_state->GetInteger( 73 int impressions = local_state->GetInteger(
57 desktop_ios_promotion::kEntryPointLocalPrefs 74 desktop_ios_promotion::kEntryPointLocalPrefs
58 [static_cast<int>(entry_point_)][static_cast<int>( 75 [static_cast<int>(entry_point_)][static_cast<int>(
59 desktop_ios_promotion::EntryPointLocalPrefType::IMPRESSIONS)]); 76 desktop_ios_promotion::EntryPointLocalPrefType::IMPRESSIONS)]);
60 impressions++; 77 impressions++;
61 local_state->SetInteger( 78 local_state->SetInteger(
62 desktop_ios_promotion::kEntryPointLocalPrefs 79 desktop_ios_promotion::kEntryPointLocalPrefs
63 [static_cast<int>(entry_point_)][static_cast<int>( 80 [static_cast<int>(entry_point_)][static_cast<int>(
(...skipping 14 matching lines...) Expand all
78 double last_impression = base::Time::NowFromSystemTime().ToDoubleT(); 95 double last_impression = base::Time::NowFromSystemTime().ToDoubleT();
79 profile_prefs_->SetDouble(prefs::kIOSPromotionLastImpression, 96 profile_prefs_->SetDouble(prefs::kIOSPromotionLastImpression,
80 last_impression); 97 last_impression);
81 98
82 // If the variation id paramater is set on the finch experiement, set this 99 // If the variation id paramater is set on the finch experiement, set this
83 // variation id to chrome sync pref to be accessed from iOS side. 100 // variation id to chrome sync pref to be accessed from iOS side.
84 int variation_id = base::GetFieldTrialParamByFeatureAsInt( 101 int variation_id = base::GetFieldTrialParamByFeatureAsInt(
85 features::kDesktopIOSPromotion, "promo_variation_id", 0); 102 features::kDesktopIOSPromotion, "promo_variation_id", 0);
86 if (variation_id) 103 if (variation_id)
87 profile_prefs_->SetInteger(prefs::kIOSPromotionVariationId, variation_id); 104 profile_prefs_->SetInteger(prefs::kIOSPromotionVariationId, variation_id);
105 }
88 106
89 // Update histograms. 107 void DesktopIOSPromotionController::OnLearnMoreLinkClicked() {
90 UMA_HISTOGRAM_ENUMERATION( 108 dismissal_reason_ =
91 "DesktopIOSPromotion.ImpressionFromEntryPoint", 109 desktop_ios_promotion::PromotionDismissalReason::LEARN_MORE;
92 static_cast<int>(entry_point_),
93 static_cast<int>(
94 desktop_ios_promotion::PromotionEntryPoint::ENTRY_POINT_MAX_VALUE));
95 } 110 }
96 111
97 void DesktopIOSPromotionController::OnNoThanksClicked() { 112 void DesktopIOSPromotionController::OnNoThanksClicked() {
98 PrefService* local_state = g_browser_process->local_state(); 113 if (entry_point_ !=
99 local_state->SetBoolean( 114 desktop_ios_promotion::PromotionEntryPoint::FOOTNOTE_FOLLOWUP_BUBBLE) {
100 desktop_ios_promotion::kEntryPointLocalPrefs 115 PrefService* local_state = g_browser_process->local_state();
101 [static_cast<int>(entry_point_)][static_cast<int>( 116 local_state->SetBoolean(
102 desktop_ios_promotion::EntryPointLocalPrefType::DISMISSED)], 117 desktop_ios_promotion::kEntryPointLocalPrefs
103 true); 118 [static_cast<int>(entry_point_)][static_cast<int>(
119 desktop_ios_promotion::EntryPointLocalPrefType::DISMISSED)],
120 true);
121 }
104 dismissal_reason_ = 122 dismissal_reason_ =
105 desktop_ios_promotion::PromotionDismissalReason::NO_THANKS; 123 desktop_ios_promotion::PromotionDismissalReason::NO_THANKS;
106 } 124 }
107 125
108 std::string DesktopIOSPromotionController::GetUsersRecoveryPhoneNumber() { 126 std::string DesktopIOSPromotionController::GetUsersRecoveryPhoneNumber() {
109 return recovery_number_; 127 return recovery_number_;
110 } 128 }
111 129
112 void DesktopIOSPromotionController::OnGotPhoneNumber( 130 void DesktopIOSPromotionController::OnGotPhoneNumber(
113 SMSService::Request* request, 131 SMSService::Request* request,
114 bool success, 132 bool success,
115 const std::string& number) { 133 const std::string& number) {
134 DCHECK(promotion_view_);
116 if (success) { 135 if (success) {
117 recovery_number_ = desktop_ios_promotion::FormatPhoneNumber(number); 136 recovery_number_ = desktop_ios_promotion::FormatPhoneNumber(number);
118 promotion_view_->UpdateRecoveryPhoneLabel(); 137 promotion_view_->UpdateRecoveryPhoneLabel();
119 } 138 }
120 UMA_HISTOGRAM_BOOLEAN("DesktopIOSPromotion.QueryPhoneNumberSucceeded", 139 UMA_HISTOGRAM_BOOLEAN("DesktopIOSPromotion.QueryPhoneNumberSucceeded",
121 success); 140 success);
122 } 141 }
123 142
124 void DesktopIOSPromotionController::OnSendSMS(SMSService::Request* request, 143 void DesktopIOSPromotionController::OnSendSMS(SMSService::Request* request,
125 bool success, 144 bool success,
126 const std::string& number) { 145 const std::string& number) {
127 UMA_HISTOGRAM_BOOLEAN("DesktopIOSPromotion.SendSMSSucceeded", success); 146 UMA_HISTOGRAM_BOOLEAN("DesktopIOSPromotion.SendSMSSucceeded", success);
128 } 147 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698