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

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

Issue 2781553003: Integrate Desktop iOS promotion with bookmarks. (Closed)
Patch Set: address comments 3 Created 3 years, 8 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_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 14 matching lines...) Expand all
25 #include "ui/gfx/color_utils.h" 25 #include "ui/gfx/color_utils.h"
26 #include "ui/gfx/paint_vector_icon.h" 26 #include "ui/gfx/paint_vector_icon.h"
27 #include "ui/native_theme/native_theme.h" 27 #include "ui/native_theme/native_theme.h"
28 28
29 using i18n::phonenumbers::PhoneNumber; 29 using i18n::phonenumbers::PhoneNumber;
30 using i18n::phonenumbers::PhoneNumberUtil; 30 using i18n::phonenumbers::PhoneNumberUtil;
31 31
32 namespace desktop_ios_promotion { 32 namespace desktop_ios_promotion {
33 33
34 // Default Impression cap. for each entry point. 34 // Default Impression cap. for each entry point.
35 const int kEntryPointImpressionCap[] = {2, 2, 5, 10}; 35 const int kEntryPointImpressionCap[] = {0, 2, 2, 5, 10};
36 36
37 const char* kEntrypointHistogramPrefix[] = { 37 const char* kEntrypointHistogramPrefix[] = {
38 "SavePasswordsNewBubble", "BookmarksNewBubble", "BookmarksFootNote", 38 "", // Padding as PromotionEntryPoints values starts from 1.
39 "SavePasswordsNewBubble",
40 "BookmarksNewBubble",
41 "BookmarksFootNote",
39 "HistoryPage", 42 "HistoryPage",
40 }; 43 };
41 44
42 // Entry point string names, used to check which entry point is targeted from 45 // Entry point string names, used to check which entry point is targeted from
43 // finch parameters. 46 // finch parameters.
44 const char* kPromotionEntryPointNames[] = { 47 const char* kPromotionEntryPointNames[] = {
45 "", "SavePasswordsBubblePromotion", "BookmarksBubblePromotion", 48 "", "SavePasswordsBubblePromotion", "BookmarksBubblePromotion",
46 "BookmarksFootnotePromotion", "HistoryPagePromotion"}; 49 "BookmarksFootnotePromotion", "HistoryPagePromotion"};
47 50
48 // Text used on the promotion body, the first dimension is the text version 51 // 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 52 // this array is indexed by the text version specified by body_text_id Finch
50 // specifying if the phone number is available or not. 53 // parameter.
51 // TODO(crbug.com/676655): Add another dimension for entry points when needed. 54 const int kBubbleBodyTextNoPhoneNumberId[2] = {
52 const int kBodyTextId[2][2] = { 55 IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TEXT,
53 {IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TEXT, 56 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 57
58 // Text used on the promotion title, This array is indexed by the text version 58 // Text used on the promotion bubble body when the phone number is not present,
59 // specified by title_text_id Finch parameter. 59 // 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. 60 // parameter.
61 const int kTitleTextId[3] = { 61 const int kBubbleBodyTextWithPhoneNumberId[2] = {
62 IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TITLE, 62 IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TEXT_WITH_PHONE_NUMBER,
63 IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TITLE_V2, 63 IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TEXT_WITH_PHONE_NUMBER_V2};
64 IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TITLE_V3}; 64
65 // Text used on the promotion bubble title, The first dimension is the entry
66 // point, and the second is the text version specified by title_text_id Finch
67 // parameter.
68 const int kBubbleTitleTextId[3][3] = {
69 {0, 0, 0}, // Padding as PromotionEntryPoints values starts from 1.
70 {IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TITLE,
71 IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TITLE_V2,
72 IDS_PASSWORD_MANAGER_DESKTOP_TO_IOS_PROMO_TITLE_V3},
73 {IDS_BOOKMARK_BUBBLE_DESKTOP_TO_IOS_PROMO_TITLE,
74 IDS_BOOKMARK_BUBBLE_DESKTOP_TO_IOS_PROMO_TITLE_V2,
75 IDS_BOOKMARK_BUBBLE_DESKTOP_TO_IOS_PROMO_TITLE_V3}};
65 76
66 bool IsEligibleForIOSPromotion( 77 bool IsEligibleForIOSPromotion(
67 PrefService* prefs, 78 PrefService* prefs,
68 const syncer::SyncService* sync_service, 79 const syncer::SyncService* sync_service,
69 desktop_ios_promotion::PromotionEntryPoint entry_point) { 80 desktop_ios_promotion::PromotionEntryPoint entry_point) {
70 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 81 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
71 switches::kForceDesktopIOSPromotion)) { 82 switches::kForceDesktopIOSPromotion)) {
72 return true; 83 return true;
73 } 84 }
74 85
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 gfx::ImageSkia icon = gfx::CreateVectorIcon( 129 gfx::ImageSkia icon = gfx::CreateVectorIcon(
119 kOpenInPhoneIcon, color_utils::DeriveDefaultIconColor(color)); 130 kOpenInPhoneIcon, color_utils::DeriveDefaultIconColor(color));
120 return icon; 131 return icon;
121 } 132 }
122 133
123 base::string16 GetPromoText( 134 base::string16 GetPromoText(
124 desktop_ios_promotion::PromotionEntryPoint entry_point, 135 desktop_ios_promotion::PromotionEntryPoint entry_point,
125 const std::string& phone_number) { 136 const std::string& phone_number) {
126 int text_id_from_finch = base::GetFieldTrialParamByFeatureAsInt( 137 int text_id_from_finch = base::GetFieldTrialParamByFeatureAsInt(
127 features::kDesktopIOSPromotion, "body_text_id", 0); 138 features::kDesktopIOSPromotion, "body_text_id", 0);
128 int body_text_i10_id = kBodyTextId[text_id_from_finch][!phone_number.empty()]; 139 int body_text_i10_id = kBubbleBodyTextWithPhoneNumberId[text_id_from_finch];
129 if (phone_number.empty()) { 140 if (phone_number.empty()) {
141 body_text_i10_id = kBubbleBodyTextNoPhoneNumberId[text_id_from_finch];
130 return l10n_util::GetStringUTF16(body_text_i10_id) 142 return l10n_util::GetStringUTF16(body_text_i10_id)
131 .append(base::string16(13, ' ')); 143 .append(base::string16(13, ' '));
132 } 144 }
133 return l10n_util::GetStringFUTF16(body_text_i10_id, 145 return l10n_util::GetStringFUTF16(body_text_i10_id,
134 base::UTF8ToUTF16(phone_number)); 146 base::UTF8ToUTF16(phone_number));
135 } 147 }
136 148
137 base::string16 GetPromoTitle( 149 base::string16 GetPromoTitle(
138 desktop_ios_promotion::PromotionEntryPoint entry_point) { 150 desktop_ios_promotion::PromotionEntryPoint entry_point) {
139 int text_id_from_finch = base::GetFieldTrialParamByFeatureAsInt( 151 int text_id_from_finch = base::GetFieldTrialParamByFeatureAsInt(
140 features::kDesktopIOSPromotion, "title_text_id", 0); 152 features::kDesktopIOSPromotion, "title_text_id", 0);
141 return l10n_util::GetStringUTF16(kTitleTextId[text_id_from_finch]); 153 return l10n_util::GetStringUTF16(
154 kBubbleTitleTextId[static_cast<int>(entry_point)][text_id_from_finch]);
142 } 155 }
143 156
144 std::string GetSMSID() { 157 std::string GetSMSID() {
145 const std::string default_sms_message_id = "19001507"; 158 const std::string default_sms_message_id = "19001507";
146 // Get the SMS message id from the finch group. 159 // Get the SMS message id from the finch group.
147 std::string finch_sms_id = base::GetFieldTrialParamValueByFeature( 160 std::string finch_sms_id = base::GetFieldTrialParamValueByFeature(
148 features::kDesktopIOSPromotion, "sms_id"); 161 features::kDesktopIOSPromotion, "sms_id");
149 return finch_sms_id.empty() ? default_sms_message_id : finch_sms_id; 162 return finch_sms_id.empty() ? default_sms_message_id : finch_sms_id;
150 } 163 }
151 164
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 entry_point)]), 224 entry_point)]),
212 dismissal_reason_min, 225 dismissal_reason_min,
213 static_cast<int>(PromotionDismissalReason::DISMISSAL_REASON_MAX_VALUE), 226 static_cast<int>(PromotionDismissalReason::DISMISSAL_REASON_MAX_VALUE),
214 static_cast<int>(PromotionDismissalReason::DISMISSAL_REASON_MAX_VALUE) + 227 static_cast<int>(PromotionDismissalReason::DISMISSAL_REASON_MAX_VALUE) +
215 1, 228 1,
216 base::HistogramBase::kUmaTargetedHistogramFlag) 229 base::HistogramBase::kUmaTargetedHistogramFlag)
217 ->Add(static_cast<int>(reason)); 230 ->Add(static_cast<int>(reason));
218 } 231 }
219 232
220 } // namespace desktop_ios_promotion 233 } // namespace desktop_ios_promotion
OLDNEW
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698