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 #include "chrome/browser/ui/desktop_ios_promotion/desktop_ios_promotion_util.h" | 5 #include "chrome/browser/ui/desktop_ios_promotion/desktop_ios_promotion_util.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
9 #include "base/metrics/field_trial_params.h" | 9 #include "base/metrics/field_trial_params.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 27 matching lines...) Expand all Loading... | |
38 "SavePasswordsNewBubble", "BookmarksNewBubble", "BookmarksFootNote", | 38 "SavePasswordsNewBubble", "BookmarksNewBubble", "BookmarksFootNote", |
39 "HistoryPage", | 39 "HistoryPage", |
40 }; | 40 }; |
41 | 41 |
42 // Entry point string names, used to check which entry point is targeted from | 42 // Entry point string names, used to check which entry point is targeted from |
43 // finch parameters. | 43 // finch parameters. |
44 const char* kPromotionEntryPointNames[] = { | 44 const char* kPromotionEntryPointNames[] = { |
45 "", "SavePasswordsBubblePromotion", "BookmarksBubblePromotion", | 45 "", "SavePasswordsBubblePromotion", "BookmarksBubblePromotion", |
46 "BookmarksFootnotePromotion", "HistoryPagePromotion"}; | 46 "BookmarksFootnotePromotion", "HistoryPagePromotion"}; |
47 | 47 |
48 // Text used on the promotion body, the first dimension is the text version | 48 // Text used on the promotion bubble body when the phone number is present, |
49 // specified by body_text_id Finch parameter, and the second dimension is for | 49 // this array is indexed by the text version specified by body_text_id Finch |
50 // specifying if the phone number is available or not. | 50 // parameter. |
51 // TODO(crbug.com/676655): Add another dimension for entry points when needed. | 51 const int kBubbleBodyTextNoPhoneNumberId[2] = { |
52 const int kBodyTextId[2][2] = { | 52 IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TEXT, |
53 {IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TEXT, | 53 IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TEXT_V2}; |
54 IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TEXT_WITH_PHONE_NUMBER}, | |
55 {IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TEXT_V2, | |
56 IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TEXT_WITH_PHONE_NUMBER_V2}}; | |
57 | 54 |
58 // Text used on the promotion title, This array is indexed by the text version | 55 // Text used on the promotion bubble body when the phone number is not present, |
59 // specified by title_text_id Finch parameter. | 56 // this array is indexed by the text version specified by body_text_id Finch |
60 // TODO(crbug.com/676655): Add another dimension for entry points when needed. | 57 // parameter. |
61 const int kTitleTextId[3] = { | 58 const int kBubbleBodyTextWithPhoneNumberId[2] = { |
62 IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TITLE, | 59 IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TEXT_WITH_PHONE_NUMBER, |
63 IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TITLE_V2, | 60 IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TEXT_WITH_PHONE_NUMBER_V2}; |
64 IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TITLE_V3}; | 61 |
62 // Text used on the promotion bubble title, The first dimension is the entry | |
63 // point, and the second is the text version specified by title_text_id Finch | |
64 // parameter. | |
65 const int kBubbleTitleTextId[2][3] = { | |
66 {IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TITLE, | |
67 IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TITLE_V2, | |
68 IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TITLE_V3}, | |
69 {IDS_BOOKMARK_BUBBLE_DESKTOP_TO_IOS_PROMO_TITLE, | |
70 IDS_BOOKMARK_BUBBLE_DESKTOP_TO_IOS_PROMO_TITLE_V2, | |
71 IDS_BOOKMARK_BUBBLE_DESKTOP_TO_IOS_PROMO_TITLE_V3}}; | |
65 | 72 |
66 bool IsEligibleForIOSPromotion( | 73 bool IsEligibleForIOSPromotion( |
67 PrefService* prefs, | 74 PrefService* prefs, |
68 const syncer::SyncService* sync_service, | 75 const syncer::SyncService* sync_service, |
69 desktop_ios_promotion::PromotionEntryPoint entry_point) { | 76 desktop_ios_promotion::PromotionEntryPoint entry_point) { |
70 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 77 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
71 switches::kForceDesktopIOSPromotion)) { | 78 switches::kForceDesktopIOSPromotion)) { |
72 return true; | 79 return true; |
73 } | 80 } |
74 | 81 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 gfx::ImageSkia icon = gfx::CreateVectorIcon( | 125 gfx::ImageSkia icon = gfx::CreateVectorIcon( |
119 kOpenInPhoneIcon, color_utils::DeriveDefaultIconColor(color)); | 126 kOpenInPhoneIcon, color_utils::DeriveDefaultIconColor(color)); |
120 return icon; | 127 return icon; |
121 } | 128 } |
122 | 129 |
123 base::string16 GetPromoText( | 130 base::string16 GetPromoText( |
124 desktop_ios_promotion::PromotionEntryPoint entry_point, | 131 desktop_ios_promotion::PromotionEntryPoint entry_point, |
125 const std::string& phone_number) { | 132 const std::string& phone_number) { |
126 int text_id_from_finch = base::GetFieldTrialParamByFeatureAsInt( | 133 int text_id_from_finch = base::GetFieldTrialParamByFeatureAsInt( |
127 features::kDesktopIOSPromotion, "body_text_id", 0); | 134 features::kDesktopIOSPromotion, "body_text_id", 0); |
128 int body_text_i10_id = kBodyTextId[text_id_from_finch][!phone_number.empty()]; | 135 int body_text_i10_id = kBubbleBodyTextWithPhoneNumberId[text_id_from_finch]; |
129 if (phone_number.empty()) { | 136 if (phone_number.empty()) { |
137 body_text_i10_id = kBubbleBodyTextNoPhoneNumberId[text_id_from_finch]; | |
130 return l10n_util::GetStringUTF16(body_text_i10_id) | 138 return l10n_util::GetStringUTF16(body_text_i10_id) |
131 .append(base::string16(13, ' ')); | 139 .append(base::string16(13, ' ')); |
132 } | 140 } |
133 return l10n_util::GetStringFUTF16(body_text_i10_id, | 141 return l10n_util::GetStringFUTF16(body_text_i10_id, |
134 base::UTF8ToUTF16(phone_number)); | 142 base::UTF8ToUTF16(phone_number)); |
135 } | 143 } |
136 | 144 |
137 base::string16 GetPromoTitle( | 145 base::string16 GetPromoTitle( |
138 desktop_ios_promotion::PromotionEntryPoint entry_point) { | 146 desktop_ios_promotion::PromotionEntryPoint entry_point) { |
139 int text_id_from_finch = base::GetFieldTrialParamByFeatureAsInt( | 147 int text_id_from_finch = base::GetFieldTrialParamByFeatureAsInt( |
140 features::kDesktopIOSPromotion, "title_text_id", 0); | 148 features::kDesktopIOSPromotion, "title_text_id", 0); |
141 return l10n_util::GetStringUTF16(kTitleTextId[text_id_from_finch]); | 149 return l10n_util::GetStringUTF16( |
150 kBubbleTitleTextId[static_cast<int>(entry_point) - 1] | |
sky
2017/03/27 20:03:55
Don't hardcode the -1, use a constant. And by that
mrefaat
2017/03/29 19:50:18
used padding instead to keep the consistency
| |
151 [text_id_from_finch]); | |
142 } | 152 } |
143 | 153 |
144 std::string GetSMSID() { | 154 std::string GetSMSID() { |
145 const std::string default_sms_message_id = "19001507"; | 155 const std::string default_sms_message_id = "19001507"; |
146 // Get the SMS message id from the finch group. | 156 // Get the SMS message id from the finch group. |
147 std::string finch_sms_id = base::GetFieldTrialParamValueByFeature( | 157 std::string finch_sms_id = base::GetFieldTrialParamValueByFeature( |
148 features::kDesktopIOSPromotion, "sms_id"); | 158 features::kDesktopIOSPromotion, "sms_id"); |
149 return finch_sms_id.empty() ? default_sms_message_id : finch_sms_id; | 159 return finch_sms_id.empty() ? default_sms_message_id : finch_sms_id; |
150 } | 160 } |
151 | 161 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
211 entry_point)]), | 221 entry_point)]), |
212 dismissal_reason_min, | 222 dismissal_reason_min, |
213 static_cast<int>(PromotionDismissalReason::DISMISSAL_REASON_MAX_VALUE), | 223 static_cast<int>(PromotionDismissalReason::DISMISSAL_REASON_MAX_VALUE), |
214 static_cast<int>(PromotionDismissalReason::DISMISSAL_REASON_MAX_VALUE) + | 224 static_cast<int>(PromotionDismissalReason::DISMISSAL_REASON_MAX_VALUE) + |
215 1, | 225 1, |
216 base::HistogramBase::kUmaTargetedHistogramFlag) | 226 base::HistogramBase::kUmaTargetedHistogramFlag) |
217 ->Add(static_cast<int>(reason)); | 227 ->Add(static_cast<int>(reason)); |
218 } | 228 } |
219 | 229 |
220 } // namespace desktop_ios_promotion | 230 } // namespace desktop_ios_promotion |
OLD | NEW |