Chromium Code Reviews| Index: chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_bubble_view.cc |
| diff --git a/chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_view.cc b/chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_bubble_view.cc |
| similarity index 58% |
| rename from chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_view.cc |
| rename to chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_bubble_view.cc |
| index 2407284eb936ca3413ea1b106eedaa93982b3ce4..cd64a2933a833d5672a9d44785d847c6244d567e 100644 |
| --- a/chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_view.cc |
| +++ b/chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_bubble_view.cc |
| @@ -2,17 +2,18 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_view.h" |
| +#include "chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_bubble_view.h" |
| #include "base/strings/utf_string_conversions.h" |
| +#include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/desktop_ios_promotion/desktop_ios_promotion_controller.h" |
| #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" |
| #include "chrome/grit/generated_resources.h" |
| #include "ui/base/l10n/l10n_util.h" |
| +#include "ui/base/resource/resource_bundle.h" |
| #include "ui/views/controls/button/button.h" |
| #include "ui/views/controls/button/md_text_button.h" |
| -#include "ui/views/controls/link.h" |
| #include "ui/views/layout/grid_layout.h" |
| #include "ui/views/layout/layout_constants.h" |
| @@ -29,12 +30,16 @@ int GetDesiredBubbleMaxWidth( |
| } // namespace |
| -DesktopIOSPromotionView::DesktopIOSPromotionView( |
| - desktop_ios_promotion::PromotionEntryPoint entry_point) { |
| - promotion_controller_ = new DesktopIOSPromotionController(); |
| - int bubbleWidth = ::GetDesiredBubbleMaxWidth(entry_point); |
| +DesktopIOSPromotionBubbleView::DesktopIOSPromotionBubbleView( |
| + Profile* profile, |
| + desktop_ios_promotion::PromotionEntryPoint entry_point) |
| + : recovery_phone_label_(new views::Label()), |
| + promotion_controller_( |
| + new DesktopIOSPromotionController(profile, this, entry_point)) { |
|
sky
2017/02/18 18:03:51
Use MakeUnique (see threads on chromium-dev for re
mrefaat
2017/02/18 19:12:00
Done.
|
| + int bubble_width = |
| + ::GetDesiredBubbleMaxWidth(promotion_controller_->entry_point()); |
| views::GridLayout* layout = new views::GridLayout(this); |
| - layout->set_minimum_size(gfx::Size(bubbleWidth, 0)); |
| + layout->set_minimum_size(gfx::Size(bubble_width, 0)); |
| SetLayoutManager(layout); |
| send_sms_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( |
| this, l10n_util::GetStringUTF16(IDS_DESKTOP_TO_IOS_PROMO_SEND_TO_PHONE)); |
| @@ -43,8 +48,9 @@ DesktopIOSPromotionView::DesktopIOSPromotionView( |
| constexpr int kLabelColumnSet = 1; |
| views::ColumnSet* column_set = layout->AddColumnSet(kLabelColumnSet); |
| + column_set->AddPaddingColumn(0, 8); |
| column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, |
| - views::GridLayout::FIXED, bubbleWidth, 0); |
| + views::GridLayout::FIXED, bubble_width, 0); |
| constexpr int kDoubleButtonColumnSet = 2; |
| column_set = layout->AddColumnSet(kDoubleButtonColumnSet); |
| @@ -53,23 +59,39 @@ DesktopIOSPromotionView::DesktopIOSPromotionView( |
| column_set->AddPaddingColumn(0, views::kRelatedButtonHSpacing); |
| column_set->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, |
| 0, views::GridLayout::USE_PREF, 0, 0); |
| - |
| + constexpr int kPhoneNumberColumnSet = 3; |
| + column_set = layout->AddColumnSet(kPhoneNumberColumnSet); |
| + column_set->AddPaddingColumn(0, 32); |
| + column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, |
| + views::GridLayout::FIXED, bubble_width, 0); |
| views::Label* label = |
| - new views::Label(desktop_ios_promotion::GetPromoBubbleText(entry_point)); |
| + new views::Label(desktop_ios_promotion::GetPromoBubbleText( |
| + promotion_controller_->entry_point())); |
| + label->SetEnabledColor(SK_ColorGRAY); |
| label->SetMultiLine(true); |
| label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| layout->StartRow(0, kLabelColumnSet); |
| layout->AddView(label); |
| + layout->StartRow(0, kPhoneNumberColumnSet); |
| + UpdateRecoveryPhoneLabel(); |
| + ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| + recovery_phone_label_->SetFontList( |
| + rb->GetFontList(ui::ResourceBundle::BoldFont)); |
| + recovery_phone_label_->SetEnabledColor(SK_ColorGRAY); |
| + recovery_phone_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| + layout->AddView(recovery_phone_label_); |
| layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); |
| layout->StartRow(0, kDoubleButtonColumnSet); |
| layout->AddView(send_sms_button_); |
| layout->AddView(no_button_); |
| - // TODO(crbug.com/676655): Log impression. |
| + promotion_controller_->OnPromotionShown(); |
| } |
| -void DesktopIOSPromotionView::ButtonPressed(views::Button* sender, |
| - const ui::Event& event) { |
| +DesktopIOSPromotionBubbleView::~DesktopIOSPromotionBubbleView() = default; |
| + |
| +void DesktopIOSPromotionBubbleView::ButtonPressed(views::Button* sender, |
| + const ui::Event& event) { |
| if (sender == send_sms_button_) { |
| promotion_controller_->OnSendSMSClicked(); |
| } else if (sender == no_button_) { |
| @@ -79,3 +101,8 @@ void DesktopIOSPromotionView::ButtonPressed(views::Button* sender, |
| } |
| GetWidget()->Close(); |
| } |
| + |
| +void DesktopIOSPromotionBubbleView::UpdateRecoveryPhoneLabel() { |
| + recovery_phone_label_->SetText( |
| + base::UTF8ToUTF16(promotion_controller_->GetUsersRecoveryPhoneNumber())); |
| +} |