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

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: comments 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
7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/desktop_ios_promotion/desktop_ios_promotion_model.h"
10 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
11 #include "chrome/grit/generated_resources.h"
12 #include "ui/base/l10n/l10n_util.h"
13 #include "ui/views/controls/button/button.h"
14 #include "ui/views/controls/button/md_text_button.h"
15 #include "ui/views/controls/link.h"
16 #include "ui/views/layout/grid_layout.h"
17 #include "ui/views/layout/layout_constants.h"
18
19 namespace {
20 int GetDesiredBubbleMaxWidth(
21 desktop_ios_promotion::PromotionEntryPoint entry_point) {
22 if (entry_point ==
23 desktop_ios_promotion::PromotionEntryPoint::SAVE_PASSWORD_BUBBLE) {
24 return ManagePasswordsBubbleView::kDesiredBubbleWidth;
25 }
26 return 0;
27 }
28 }
sky 2017/01/05 00:35:21 Generally we add // namespace for the closing }
mrefaat 2017/01/05 23:54:42 Done, thanks for the advice
29
30 DesktopIOSPromotionView::DesktopIOSPromotionView(
31 desktop_ios_promotion::PromotionEntryPoint entry_point) {
32 model_ = new DesktopIOSPromotionModel(entry_point);
33 int bubbleWidth = ::GetDesiredBubbleMaxWidth(entry_point);
34 views::GridLayout* layout = new views::GridLayout(this);
35 layout->set_minimum_size(gfx::Size(bubbleWidth, 0));
36 SetLayoutManager(layout);
37 send_sms_button_ = views::MdTextButton::CreateSecondaryUiBlueButton(
38 this, l10n_util::GetStringUTF16(IDS_DESKTOP_TO_IOS_PROMO_SEND_TO_PHONE));
39 no_button_ = views::MdTextButton::CreateSecondaryUiButton(
40 this, l10n_util::GetStringUTF16(IDS_DESKTOP_TO_IOS_PROMO_NO_THANKS));
41
42 constexpr int kLabelColumnSet = 1;
43 views::ColumnSet* column_set = layout->AddColumnSet(kLabelColumnSet);
44 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
45 views::GridLayout::FIXED, bubbleWidth, 0);
46
47 constexpr int kDoubleButtonColumnSet = 2;
48 column_set = layout->AddColumnSet(kDoubleButtonColumnSet);
49 column_set->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER,
50 1, views::GridLayout::USE_PREF, 0, 0);
51 column_set->AddPaddingColumn(0, views::kRelatedButtonHSpacing);
52 column_set->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER,
53 0, views::GridLayout::USE_PREF, 0, 0);
54
55 views::Label* label =
56 new views::Label(desktop_ios_promotion::GetPromoBubbleText(entry_point));
57 label->SetMultiLine(true);
58 label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
59 layout->StartRow(0, kLabelColumnSet);
60 layout->AddView(label);
61 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing);
62 layout->StartRow(0, kDoubleButtonColumnSet);
63 layout->AddView(send_sms_button_);
64 layout->AddView(no_button_);
65
66 // TODO(crbug.com/676655): Log impression.
67 }
68
69 void DesktopIOSPromotionView::ButtonPressed(views::Button* sender,
70 const ui::Event& event) {
71 if (sender == send_sms_button_) {
72 model_->OnSendSMSClicked();
73 } else if (sender == no_button_) {
74 model_->OnNoThanksClicked();
75 } else {
76 NOTREACHED();
77 }
78 GetWidget()->Close();
79 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698