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

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

Issue 2815303004: Update the Windows iOS promotion to have the same width as the bubble that appears before it. (Closed)
Patch Set: Same width bubble 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"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/app/vector_icons/vector_icons.h" 13 #include "chrome/app/vector_icons/vector_icons.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/common/chrome_features.h" 15 #include "chrome/common/chrome_features.h"
16 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/grit/chromium_strings.h" 17 #include "chrome/grit/chromium_strings.h"
18 #include "chrome/grit/generated_resources.h" 18 #include "chrome/grit/generated_resources.h"
19 #include "chrome/grit/locale_settings.h"
19 #include "components/browser_sync/profile_sync_service.h" 20 #include "components/browser_sync/profile_sync_service.h"
20 #include "components/pref_registry/pref_registry_syncable.h" 21 #include "components/pref_registry/pref_registry_syncable.h"
21 #include "components/prefs/pref_registry_simple.h" 22 #include "components/prefs/pref_registry_simple.h"
22 #include "components/prefs/pref_service.h" 23 #include "components/prefs/pref_service.h"
23 #include "third_party/libphonenumber/phonenumber_api.h" 24 #include "third_party/libphonenumber/phonenumber_api.h"
24 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
25 #include "ui/gfx/color_utils.h" 26 #include "ui/gfx/color_utils.h"
26 #include "ui/gfx/paint_vector_icon.h" 27 #include "ui/gfx/paint_vector_icon.h"
27 #include "ui/native_theme/native_theme.h" 28 #include "ui/native_theme/native_theme.h"
29 #include "ui/views/widget/widget.h"
sky 2017/04/17 17:21:55 Code in c/b/ui should not depend upon views. Code
mrefaat 2017/04/17 19:10:49 Done.
28 30
29 using i18n::phonenumbers::PhoneNumber; 31 using i18n::phonenumbers::PhoneNumber;
30 using i18n::phonenumbers::PhoneNumberUtil; 32 using i18n::phonenumbers::PhoneNumberUtil;
31 33
32 namespace desktop_ios_promotion { 34 namespace desktop_ios_promotion {
33 35
34 // Default Impression cap. for each entry point. 36 // Default Impression cap. for each entry point.
35 const int kEntryPointImpressionCap[] = {0, 2, 2, 5, 10}; 37 const int kEntryPointImpressionCap[] = {0, 2, 2, 5, 10};
36 38
37 const char* kEntrypointHistogramPrefix[] = { 39 const char* kEntrypointHistogramPrefix[] = {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 int body_text_i10_id = kBubbleBodyTextWithPhoneNumberId[text_id_from_finch]; 141 int body_text_i10_id = kBubbleBodyTextWithPhoneNumberId[text_id_from_finch];
140 if (phone_number.empty()) { 142 if (phone_number.empty()) {
141 body_text_i10_id = kBubbleBodyTextNoPhoneNumberId[text_id_from_finch]; 143 body_text_i10_id = kBubbleBodyTextNoPhoneNumberId[text_id_from_finch];
142 return l10n_util::GetStringUTF16(body_text_i10_id) 144 return l10n_util::GetStringUTF16(body_text_i10_id)
143 .append(base::string16(13, ' ')); 145 .append(base::string16(13, ' '));
144 } 146 }
145 return l10n_util::GetStringFUTF16(body_text_i10_id, 147 return l10n_util::GetStringFUTF16(body_text_i10_id,
146 base::UTF8ToUTF16(phone_number)); 148 base::UTF8ToUTF16(phone_number));
147 } 149 }
148 150
151 int GetPromoBubbleTextLabelWidth(PromotionEntryPoint entry_point) {
152 if (entry_point == PromotionEntryPoint::SAVE_PASSWORD_BUBBLE) {
153 return views::Widget::GetLocalizedContentsWidth(
154 IDS_DESKTOP_IOS_PROMOTION_SAVE_PASSWORDS_BUBBLE_TEXT_WIDTH_CHARS);
155 }
156 return views::Widget::GetLocalizedContentsWidth(
157 IDS_DESKTOP_IOS_PROMOTION_TEXT_WIDTH_CHARS);
158 }
159
149 base::string16 GetPromoTitle( 160 base::string16 GetPromoTitle(
150 desktop_ios_promotion::PromotionEntryPoint entry_point) { 161 desktop_ios_promotion::PromotionEntryPoint entry_point) {
151 int text_id_from_finch = base::GetFieldTrialParamByFeatureAsInt( 162 int text_id_from_finch = base::GetFieldTrialParamByFeatureAsInt(
152 features::kDesktopIOSPromotion, "title_text_id", 0); 163 features::kDesktopIOSPromotion, "title_text_id", 0);
153 return l10n_util::GetStringUTF16( 164 return l10n_util::GetStringUTF16(
154 kBubbleTitleTextId[static_cast<int>(entry_point)][text_id_from_finch]); 165 kBubbleTitleTextId[static_cast<int>(entry_point)][text_id_from_finch]);
155 } 166 }
156 167
157 std::string GetSMSID() { 168 std::string GetSMSID() {
158 const std::string default_sms_message_id = "19001507"; 169 const std::string default_sms_message_id = "19001507";
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 entry_point)]), 235 entry_point)]),
225 dismissal_reason_min, 236 dismissal_reason_min,
226 static_cast<int>(PromotionDismissalReason::DISMISSAL_REASON_MAX_VALUE), 237 static_cast<int>(PromotionDismissalReason::DISMISSAL_REASON_MAX_VALUE),
227 static_cast<int>(PromotionDismissalReason::DISMISSAL_REASON_MAX_VALUE) + 238 static_cast<int>(PromotionDismissalReason::DISMISSAL_REASON_MAX_VALUE) +
228 1, 239 1,
229 base::HistogramBase::kUmaTargetedHistogramFlag) 240 base::HistogramBase::kUmaTargetedHistogramFlag)
230 ->Add(static_cast<int>(reason)); 241 ->Add(static_cast<int>(reason));
231 } 242 }
232 243
233 } // namespace desktop_ios_promotion 244 } // namespace desktop_ios_promotion
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698