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

Side by Side Diff: chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_view.cc

Issue 2617543002: Create Desktop to iOS Promotion skeleton. (Closed)
Patch Set: Created 3 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_vi ew.h"
6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
9 #include "chrome/grit/generated_resources.h"
10 #include "ui/base/l10n/l10n_util.h"
11 #include "ui/views/controls/button/button.h"
12 #include "ui/views/controls/button/md_text_button.h"
13 #include "ui/views/controls/link.h"
14 #include "ui/views/layout/grid_layout.h"
15 #include "ui/views/layout/layout_constants.h"
16
17 DesktopIOSPromotionView::DesktopIOSPromotionView(
18 desktop_ios_promotion::PromotionEntryPoint entry_point) {
19 model_ = new DesktopIOSPromotionModel(entry_point);
20 int bubbleWidth = GetDesiredBubbleWidth(entry_point);
21 views::GridLayout* layout = new views::GridLayout(this);
22 layout->set_minimum_size(gfx::Size(bubbleWidth, 0));
23 SetLayoutManager(layout);
24 send_sms_button_ = views::MdTextButton::CreateSecondaryUiBlueButton(
25 this, l10n_util::GetStringUTF16(IDS_DESKTOP_IOS_PROMO_SEND_TO_PHONE));
26 no_button_ = views::MdTextButton::CreateSecondaryUiButton(
27 this, l10n_util::GetStringUTF16(IDS_DESKTOP_IOS_PROMO_NO_THANKS));
28
29 constexpr int kLabelColumnSet = 1;
30 views::ColumnSet* column_set = layout->AddColumnSet(kLabelColumnSet);
31 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
32 views::GridLayout::FIXED, bubbleWidth, 0);
33
34 constexpr int kDoubleButtonColumnSet = 2;
35 column_set = layout->AddColumnSet(kDoubleButtonColumnSet);
36 column_set->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER,
37 1, views::GridLayout::USE_PREF, 0, 0);
38 column_set->AddPaddingColumn(0, views::kRelatedButtonHSpacing);
39 column_set->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER,
40 0, views::GridLayout::USE_PREF, 0, 0);
41
42 views::Label* label = new views::Label(GetPromoBubbleText(entry_point));
43 label->SetMultiLine(true);
44 label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
45 layout->StartRow(0, kLabelColumnSet);
46 layout->AddView(label);
47 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing);
48 layout->StartRow(0, kDoubleButtonColumnSet);
49 layout->AddView(send_sms_button_);
50 layout->AddView(no_button_);
51
52 // TODO(crbug.com/676655): Log impression.
53 }
54
55 int DesktopIOSPromotionView::GetDesiredBubbleWidth(
sky 2017/01/04 20:52:37 AFAICT you don't need these to be member functions
56 desktop_ios_promotion::PromotionEntryPoint entry_point) {
57 if (entry_point ==
58 desktop_ios_promotion::PromotionEntryPoint::SAVE_PASSWORD_BUBBLE) {
59 return ManagePasswordsBubbleView::kDesiredBubbleWidth;
60 }
61 return 0;
62 }
63
64 base::string16 DesktopIOSPromotionView::GetPromoBubbleText(
65 desktop_ios_promotion::PromotionEntryPoint entry_point) {
66 if (entry_point ==
67 desktop_ios_promotion::PromotionEntryPoint::SAVE_PASSWORD_BUBBLE) {
68 return l10n_util::GetStringUTF16(
69 IDS_PASSWORD_MANAGER_DESKTOP_IOS_PROMO_TEXT);
70 }
71 return base::string16();
72 }
73
74 void DesktopIOSPromotionView::ButtonPressed(views::Button* sender,
75 const ui::Event& event) {
76 if (sender == send_sms_button_) {
sky 2017/01/04 20:52:37 no {}
77 model_->OnSendSMSClicked();
78 } else if (sender == no_button_) {
79 model_->OnNoThanksClicked();
80 } else {
81 NOTREACHED();
82 }
83 GetWidget()->Close();
84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698