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

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

Issue 2781553003: Integrate Desktop iOS promotion with bookmarks. (Closed)
Patch Set: address comments 3 Created 3 years, 8 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
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_bu bble_view.h" 5 #include "chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_bu bble_view.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/desktop_ios_promotion/desktop_ios_promotion_controll er.h" 9 #include "chrome/browser/ui/desktop_ios_promotion/desktop_ios_promotion_controll er.h"
10 #include "chrome/browser/ui/views/harmony/layout_delegate.h" 10 #include "chrome/browser/ui/views/harmony/layout_delegate.h"
11 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" 11 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
12 #include "chrome/grit/generated_resources.h" 12 #include "chrome/grit/generated_resources.h"
13 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/base/resource/resource_bundle.h" 14 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/views/controls/button/button.h" 15 #include "ui/views/controls/button/button.h"
16 #include "ui/views/controls/button/md_text_button.h" 16 #include "ui/views/controls/button/md_text_button.h"
17 #include "ui/views/layout/grid_layout.h" 17 #include "ui/views/layout/grid_layout.h"
18 18
19 namespace {
20
21 int GetDesiredBubbleMaxWidth(
22 desktop_ios_promotion::PromotionEntryPoint entry_point) {
23 if (entry_point ==
24 desktop_ios_promotion::PromotionEntryPoint::SAVE_PASSWORD_BUBBLE) {
25 return ManagePasswordsBubbleView::kDesiredBubbleWidth;
26 }
27 return 0;
28 }
29
30 } // namespace
31
32 DesktopIOSPromotionBubbleView::DesktopIOSPromotionBubbleView( 19 DesktopIOSPromotionBubbleView::DesktopIOSPromotionBubbleView(
33 Profile* profile, 20 Profile* profile,
34 desktop_ios_promotion::PromotionEntryPoint entry_point) 21 desktop_ios_promotion::PromotionEntryPoint entry_point)
35 : promotion_text_label_( 22 : promotion_text_label_(
36 new views::Label(desktop_ios_promotion::GetPromoText(entry_point))), 23 new views::Label(desktop_ios_promotion::GetPromoText(entry_point))),
37 promotion_controller_( 24 promotion_controller_(
38 base::MakeUnique<DesktopIOSPromotionController>(profile, 25 base::MakeUnique<DesktopIOSPromotionController>(profile,
39 this, 26 this,
40 entry_point)) { 27 entry_point)) {
41 int bubble_width = 28 int bubble_width = ManagePasswordsBubbleView::kDesiredBubbleWidth;
42 ::GetDesiredBubbleMaxWidth(promotion_controller_->entry_point());
43 views::GridLayout* layout = new views::GridLayout(this); 29 views::GridLayout* layout = new views::GridLayout(this);
44 layout->set_minimum_size(gfx::Size(bubble_width, 0)); 30 layout->set_minimum_size(gfx::Size(bubble_width, 0));
45 SetLayoutManager(layout); 31 SetLayoutManager(layout);
46 send_sms_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( 32 send_sms_button_ = views::MdTextButton::CreateSecondaryUiBlueButton(
47 this, l10n_util::GetStringUTF16(IDS_DESKTOP_TO_IOS_PROMO_SEND_TO_PHONE)); 33 this, l10n_util::GetStringUTF16(IDS_DESKTOP_TO_IOS_PROMO_SEND_TO_PHONE));
48 no_button_ = views::MdTextButton::CreateSecondaryUiButton( 34 no_button_ = views::MdTextButton::CreateSecondaryUiButton(
49 this, l10n_util::GetStringUTF16(IDS_DESKTOP_TO_IOS_PROMO_NO_THANKS)); 35 this, l10n_util::GetStringUTF16(IDS_DESKTOP_TO_IOS_PROMO_NO_THANKS));
50 constexpr int kLabelColumnSet = 1; 36 constexpr int kLabelColumnSet = 1;
51 views::ColumnSet* column_set = layout->AddColumnSet(kLabelColumnSet); 37 views::ColumnSet* column_set = layout->AddColumnSet(kLabelColumnSet);
52 column_set->AddPaddingColumn( 38 column_set->AddPaddingColumn(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 86 }
101 87
102 void DesktopIOSPromotionBubbleView::UpdateRecoveryPhoneLabel() { 88 void DesktopIOSPromotionBubbleView::UpdateRecoveryPhoneLabel() {
103 std::string number = promotion_controller_->GetUsersRecoveryPhoneNumber(); 89 std::string number = promotion_controller_->GetUsersRecoveryPhoneNumber();
104 if (!number.empty()) { 90 if (!number.empty()) {
105 promotion_text_label_->SetText(desktop_ios_promotion::GetPromoText( 91 promotion_text_label_->SetText(desktop_ios_promotion::GetPromoText(
106 promotion_controller_->entry_point(), number)); 92 promotion_controller_->entry_point(), number));
107 SizeToPreferredSize(); 93 SizeToPreferredSize();
108 } 94 }
109 } 95 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_bubble_view_browsertest.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698