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

Unified Diff: chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_bubble_view.cc

Issue 2815303004: Update the Windows iOS promotion to have the same width as the bubble that appears before it. (Closed)
Patch Set: Comments 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 side-by-side diff with in-line comments
Download patch
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_bubble_view.cc b/chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_bubble_view.cc
index 47e050d0da5e8092c5ccfadd0c9818fd998035f0..45e7a1ffdbc4468eb8a16c4801cb5b23a6d47d33 100644
--- a/chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_bubble_view.cc
+++ b/chrome/browser/ui/views/desktop_ios_promotion/desktop_ios_promotion_bubble_view.cc
@@ -10,12 +10,27 @@
#include "chrome/browser/ui/views/harmony/layout_delegate.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
#include "chrome/grit/generated_resources.h"
+#include "chrome/grit/locale_settings.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/layout/grid_layout.h"
+namespace {
+// Returns the appropriate size for the promotion text label on the bubble.
+int GetPromoBubbleTextLabelWidth(
+ desktop_ios_promotion::PromotionEntryPoint entry_point) {
+ if (entry_point ==
+ desktop_ios_promotion::PromotionEntryPoint::SAVE_PASSWORD_BUBBLE) {
+ return views::Widget::GetLocalizedContentsWidth(
+ IDS_DESKTOP_IOS_PROMOTION_SAVE_PASSWORDS_BUBBLE_TEXT_WIDTH_CHARS);
+ }
+ return views::Widget::GetLocalizedContentsWidth(
+ IDS_DESKTOP_IOS_PROMOTION_TEXT_WIDTH_CHARS);
+}
+} // namespace
+
DesktopIOSPromotionBubbleView::DesktopIOSPromotionBubbleView(
Profile* profile,
desktop_ios_promotion::PromotionEntryPoint entry_point)
@@ -25,9 +40,7 @@ DesktopIOSPromotionBubbleView::DesktopIOSPromotionBubbleView(
base::MakeUnique<DesktopIOSPromotionController>(profile,
this,
entry_point)) {
- int bubble_width = ManagePasswordsBubbleView::kDesiredBubbleWidth;
views::GridLayout* layout = new views::GridLayout(this);
- layout->set_minimum_size(gfx::Size(bubble_width, 0));
layout->SetInsets(
0,
LayoutDelegate::Get()->GetMetric(
@@ -45,7 +58,7 @@ DesktopIOSPromotionBubbleView::DesktopIOSPromotionBubbleView(
constexpr int kLabelColumnSet = 1;
views::ColumnSet* column_set = layout->AddColumnSet(kLabelColumnSet);
column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
- views::GridLayout::FIXED, bubble_width, 0);
+ views::GridLayout::USE_PREF, 0, 0);
constexpr int kDoubleButtonColumnSet = 2;
column_set = layout->AddColumnSet(kDoubleButtonColumnSet);
column_set->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER,
@@ -57,6 +70,7 @@ DesktopIOSPromotionBubbleView::DesktopIOSPromotionBubbleView(
0, views::GridLayout::USE_PREF, 0, 0);
promotion_text_label_->SetEnabledColor(SK_ColorGRAY);
promotion_text_label_->SetMultiLine(true);
+ promotion_text_label_->SizeToFit(GetPromoBubbleTextLabelWidth(entry_point));
promotion_text_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
layout->StartRow(0, kLabelColumnSet);
layout->AddView(promotion_text_label_);
@@ -83,11 +97,18 @@ void DesktopIOSPromotionBubbleView::ButtonPressed(views::Button* sender,
GetWidget()->Close();
}
+void DesktopIOSPromotionBubbleView::UpdateBubbleHeight(gfx::Rect old_bounds) {
+ old_bounds.set_height(
+ GetWidget()->GetRootView()->GetHeightForWidth(old_bounds.width()));
+ GetWidget()->SetBounds(old_bounds);
+}
+
void DesktopIOSPromotionBubbleView::UpdateRecoveryPhoneLabel() {
std::string number = promotion_controller_->GetUsersRecoveryPhoneNumber();
if (!number.empty()) {
promotion_text_label_->SetText(desktop_ios_promotion::GetPromoText(
promotion_controller_->entry_point(), number));
- SizeToPreferredSize();
+ Layout();
+ UpdateBubbleHeight(GetWidget()->GetRootView()->GetBoundsInScreen());
}
}

Powered by Google App Engine
This is Rietveld 408576698