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/views/desktop_ios_promotion/desktop_ios_promotion_vi ew.h" | 5 #include "chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_vi ew.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/profiles/profile.h" | |
8 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/desktop_ios_promotion/desktop_ios_promotion_controll er.h" | 10 #include "chrome/browser/ui/desktop_ios_promotion/desktop_ios_promotion_controll er.h" |
10 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" | 11 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" |
11 #include "chrome/grit/generated_resources.h" | 12 #include "chrome/grit/generated_resources.h" |
12 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
13 #include "ui/views/controls/button/button.h" | 14 #include "ui/views/controls/button/button.h" |
14 #include "ui/views/controls/button/md_text_button.h" | 15 #include "ui/views/controls/button/md_text_button.h" |
15 #include "ui/views/controls/link.h" | 16 #include "ui/views/controls/link.h" |
16 #include "ui/views/layout/grid_layout.h" | 17 #include "ui/views/layout/grid_layout.h" |
17 #include "ui/views/layout/layout_constants.h" | 18 #include "ui/views/layout/layout_constants.h" |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 int GetDesiredBubbleMaxWidth( | 22 int GetDesiredBubbleMaxWidth( |
22 desktop_ios_promotion::PromotionEntryPoint entry_point) { | 23 desktop_ios_promotion::PromotionEntryPoint entry_point) { |
23 if (entry_point == | 24 if (entry_point == |
24 desktop_ios_promotion::PromotionEntryPoint::SAVE_PASSWORD_BUBBLE) { | 25 desktop_ios_promotion::PromotionEntryPoint::SAVE_PASSWORD_BUBBLE) { |
25 return ManagePasswordsBubbleView::kDesiredBubbleWidth; | 26 return ManagePasswordsBubbleView::kDesiredBubbleWidth; |
26 } | 27 } |
27 return 0; | 28 return 0; |
28 } | 29 } |
29 | 30 |
30 } // namespace | 31 } // namespace |
31 | 32 |
32 DesktopIOSPromotionView::DesktopIOSPromotionView( | 33 DesktopIOSPromotionView::DesktopIOSPromotionView( |
34 Profile* profile, | |
33 desktop_ios_promotion::PromotionEntryPoint entry_point) { | 35 desktop_ios_promotion::PromotionEntryPoint entry_point) { |
34 promotion_controller_ = new DesktopIOSPromotionController(); | 36 promotion_controller_ = |
sky
2017/02/16 00:13:36
Who owns this?
Also, I tend to think you have the
mrefaat
2017/02/16 21:02:40
Done.
| |
37 new DesktopIOSPromotionController(profile, entry_point); | |
35 int bubbleWidth = ::GetDesiredBubbleMaxWidth(entry_point); | 38 int bubbleWidth = ::GetDesiredBubbleMaxWidth(entry_point); |
36 views::GridLayout* layout = new views::GridLayout(this); | 39 views::GridLayout* layout = new views::GridLayout(this); |
37 layout->set_minimum_size(gfx::Size(bubbleWidth, 0)); | 40 layout->set_minimum_size(gfx::Size(bubbleWidth, 0)); |
38 SetLayoutManager(layout); | 41 SetLayoutManager(layout); |
39 send_sms_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( | 42 send_sms_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( |
40 this, l10n_util::GetStringUTF16(IDS_DESKTOP_TO_IOS_PROMO_SEND_TO_PHONE)); | 43 this, l10n_util::GetStringUTF16(IDS_DESKTOP_TO_IOS_PROMO_SEND_TO_PHONE)); |
41 no_button_ = views::MdTextButton::CreateSecondaryUiButton( | 44 no_button_ = views::MdTextButton::CreateSecondaryUiButton( |
42 this, l10n_util::GetStringUTF16(IDS_DESKTOP_TO_IOS_PROMO_NO_THANKS)); | 45 this, l10n_util::GetStringUTF16(IDS_DESKTOP_TO_IOS_PROMO_NO_THANKS)); |
43 | 46 |
44 constexpr int kLabelColumnSet = 1; | 47 constexpr int kLabelColumnSet = 1; |
(...skipping 13 matching lines...) Expand all Loading... | |
58 new views::Label(desktop_ios_promotion::GetPromoBubbleText(entry_point)); | 61 new views::Label(desktop_ios_promotion::GetPromoBubbleText(entry_point)); |
59 label->SetMultiLine(true); | 62 label->SetMultiLine(true); |
60 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 63 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
61 layout->StartRow(0, kLabelColumnSet); | 64 layout->StartRow(0, kLabelColumnSet); |
62 layout->AddView(label); | 65 layout->AddView(label); |
63 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); | 66 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); |
64 layout->StartRow(0, kDoubleButtonColumnSet); | 67 layout->StartRow(0, kDoubleButtonColumnSet); |
65 layout->AddView(send_sms_button_); | 68 layout->AddView(send_sms_button_); |
66 layout->AddView(no_button_); | 69 layout->AddView(no_button_); |
67 | 70 |
68 // TODO(crbug.com/676655): Log impression. | 71 promotion_controller_->OnPromotionShown(); |
69 } | 72 } |
70 | 73 |
71 void DesktopIOSPromotionView::ButtonPressed(views::Button* sender, | 74 void DesktopIOSPromotionView::ButtonPressed(views::Button* sender, |
72 const ui::Event& event) { | 75 const ui::Event& event) { |
73 if (sender == send_sms_button_) { | 76 if (sender == send_sms_button_) { |
74 promotion_controller_->OnSendSMSClicked(); | 77 promotion_controller_->OnSendSMSClicked(); |
75 } else if (sender == no_button_) { | 78 } else if (sender == no_button_) { |
76 promotion_controller_->OnNoThanksClicked(); | 79 promotion_controller_->OnNoThanksClicked(); |
77 } else { | 80 } else { |
78 NOTREACHED(); | 81 NOTREACHED(); |
79 } | 82 } |
80 GetWidget()->Close(); | 83 GetWidget()->Close(); |
81 } | 84 } |
OLD | NEW |