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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_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_view.cc
new file mode 100644
index 0000000000000000000000000000000000000000..96233e58b85eae215f52d62ba75da1b6d5305778
--- /dev/null
+++ b/chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_view.cc
@@ -0,0 +1,84 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// 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 "base/strings/utf_string_conversions.h"
+#include "chrome/browser/ui/browser.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/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"
+
+DesktopIOSPromotionView::DesktopIOSPromotionView(
+ desktop_ios_promotion::PromotionEntryPoint entry_point) {
+ model_ = new DesktopIOSPromotionModel(entry_point);
+ int bubbleWidth = GetDesiredBubbleWidth(entry_point);
+ views::GridLayout* layout = new views::GridLayout(this);
+ layout->set_minimum_size(gfx::Size(bubbleWidth, 0));
+ SetLayoutManager(layout);
+ send_sms_button_ = views::MdTextButton::CreateSecondaryUiBlueButton(
+ this, l10n_util::GetStringUTF16(IDS_DESKTOP_IOS_PROMO_SEND_TO_PHONE));
+ no_button_ = views::MdTextButton::CreateSecondaryUiButton(
+ this, l10n_util::GetStringUTF16(IDS_DESKTOP_IOS_PROMO_NO_THANKS));
+
+ constexpr int kLabelColumnSet = 1;
+ views::ColumnSet* column_set = layout->AddColumnSet(kLabelColumnSet);
+ column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
+ views::GridLayout::FIXED, bubbleWidth, 0);
+
+ constexpr int kDoubleButtonColumnSet = 2;
+ column_set = layout->AddColumnSet(kDoubleButtonColumnSet);
+ column_set->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER,
+ 1, views::GridLayout::USE_PREF, 0, 0);
+ column_set->AddPaddingColumn(0, views::kRelatedButtonHSpacing);
+ column_set->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER,
+ 0, views::GridLayout::USE_PREF, 0, 0);
+
+ views::Label* label = new views::Label(GetPromoBubbleText(entry_point));
+ label->SetMultiLine(true);
+ label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
+ layout->StartRow(0, kLabelColumnSet);
+ layout->AddView(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.
+}
+
+int DesktopIOSPromotionView::GetDesiredBubbleWidth(
sky 2017/01/04 20:52:37 AFAICT you don't need these to be member functions
+ desktop_ios_promotion::PromotionEntryPoint entry_point) {
+ if (entry_point ==
+ desktop_ios_promotion::PromotionEntryPoint::SAVE_PASSWORD_BUBBLE) {
+ return ManagePasswordsBubbleView::kDesiredBubbleWidth;
+ }
+ return 0;
+}
+
+base::string16 DesktopIOSPromotionView::GetPromoBubbleText(
+ desktop_ios_promotion::PromotionEntryPoint entry_point) {
+ if (entry_point ==
+ desktop_ios_promotion::PromotionEntryPoint::SAVE_PASSWORD_BUBBLE) {
+ return l10n_util::GetStringUTF16(
+ IDS_PASSWORD_MANAGER_DESKTOP_IOS_PROMO_TEXT);
+ }
+ return base::string16();
+}
+
+void DesktopIOSPromotionView::ButtonPressed(views::Button* sender,
+ const ui::Event& event) {
+ if (sender == send_sms_button_) {
sky 2017/01/04 20:52:37 no {}
+ model_->OnSendSMSClicked();
+ } else if (sender == no_button_) {
+ model_->OnNoThanksClicked();
+ } else {
+ NOTREACHED();
+ }
+ GetWidget()->Close();
+}

Powered by Google App Engine
This is Rietveld 408576698