Commit f9f29203 authored by tapted's avatar tapted Committed by Commit Bot

Use buttons from DialogClientView in BookmakBubbleView.

Currently the bookmark bubble builds its own button row, but that's
unnecessary and causes it to miss out on shared framework code for
layout and button style.

BUG=726187

Review-Url: https://codereview.chromium.org/2908963002
Cr-Commit-Position: refs/heads/master@{#475833}
parent 09bcca49
...@@ -200,16 +200,16 @@ ...@@ -200,16 +200,16 @@
<message name="IDS_BOOKMARK_AX_BUBBLE_PAGE_BOOKMARK" desc="Title of the bubble when re-clicking on a bookmark, read by spoken feedback"> <message name="IDS_BOOKMARK_AX_BUBBLE_PAGE_BOOKMARK" desc="Title of the bubble when re-clicking on a bookmark, read by spoken feedback">
Edit bookmark Edit bookmark
</message> </message>
<message name="IDS_BOOKMARK_BUBBLE_TITLE_TEXT" desc="Text preceding the title of the page that was bookmarked"> <message name="IDS_BOOKMARK_BUBBLE_NAME_LABEL" desc="Text preceding the title of the page that was bookmarked">
Name: Name:
</message> </message>
<message name="IDS_BOOKMARK_AX_BUBBLE_TITLE_TEXT" desc="Text preceding the title of the page that was bookmarked, read by spoken feedback"> <message name="IDS_BOOKMARK_AX_BUBBLE_NAME_LABEL" desc="Text preceding the title of the page that was bookmarked, read by spoken feedback">
Bookmark name Bookmark name
</message> </message>
<message name="IDS_BOOKMARK_BUBBLE_FOLDER_TEXT" desc="Text preceding the folder selector"> <message name="IDS_BOOKMARK_BUBBLE_FOLDER_LABEL" desc="Text preceding the folder selector">
Folder: Folder:
</message> </message>
<message name="IDS_BOOKMARK_AX_BUBBLE_FOLDER_TEXT" desc="Text preceding the folder selector"> <message name="IDS_BOOKMARK_AX_BUBBLE_FOLDER_LABEL" desc="Text preceding the folder selector">
Bookmark folder Bookmark folder
</message> </message>
<message name="IDS_BOOKMARK_BUBBLE_OPTIONS" desc="Title of the button the user can click to edit details of the bookmark"> <message name="IDS_BOOKMARK_BUBBLE_OPTIONS" desc="Title of the button the user can click to edit details of the bookmark">
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
<textField verticalHuggingPriority="750" id="10"> <textField verticalHuggingPriority="750" id="10">
<rect key="frame" x="17" y="6" width="65" height="14"/> <rect key="frame" x="17" y="6" width="65" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="^IDS_BOOKMARK_BUBBLE_FOLDER_TEXT" id="11"> <textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="^IDS_BOOKMARK_BUBBLE_FOLDER_LABEL" id="11">
<font key="font" metaFont="smallSystem"/> <font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
<textField verticalHuggingPriority="750" id="8"> <textField verticalHuggingPriority="750" id="8">
<rect key="frame" x="17" y="31" width="65" height="14"/> <rect key="frame" x="17" y="31" width="65" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="^IDS_BOOKMARK_BUBBLE_TITLE_TEXT" id="9"> <textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="^IDS_BOOKMARK_BUBBLE_NAME_LABEL" id="9">
<font key="font" metaFont="smallSystem"/> <font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "ui/views/layout/fill_layout.h" #include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/grid_layout.h" #include "ui/views/layout/grid_layout.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#include "ui/views/window/dialog_client_view.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/sync/profile_sync_service_factory.h"
...@@ -42,8 +43,6 @@ ...@@ -42,8 +43,6 @@
using base::UserMetricsAction; using base::UserMetricsAction;
using bookmarks::BookmarkModel; using bookmarks::BookmarkModel;
using bookmarks::BookmarkNode; using bookmarks::BookmarkNode;
using views::ColumnSet;
using views::GridLayout;
namespace { namespace {
...@@ -128,8 +127,17 @@ BookmarkBubbleView::~BookmarkBubbleView() { ...@@ -128,8 +127,17 @@ BookmarkBubbleView::~BookmarkBubbleView() {
// ui::DialogModel ------------------------------------------------------------- // ui::DialogModel -------------------------------------------------------------
int BookmarkBubbleView::GetDialogButtons() const { int BookmarkBubbleView::GetDialogButtons() const {
// TODO(tapted): DialogClientView should manage the buttons. // TODO(tapted): DialogClientView should manage the ios promo buttons too.
return ui::DIALOG_BUTTON_NONE; return is_showing_ios_promotion_
? ui::DIALOG_BUTTON_NONE
: (ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL);
}
base::string16 BookmarkBubbleView::GetDialogButtonLabel(
ui::DialogButton button) const {
return l10n_util::GetStringUTF16((button == ui::DIALOG_BUTTON_OK)
? IDS_DONE
: IDS_BOOKMARK_BUBBLE_REMOVE_BOOKMARK);
} }
// views::WidgetDelegate ------------------------------------------------------- // views::WidgetDelegate -------------------------------------------------------
...@@ -178,6 +186,19 @@ void BookmarkBubbleView::WindowClosing() { ...@@ -178,6 +186,19 @@ void BookmarkBubbleView::WindowClosing() {
// views::DialogDelegate ------------------------------------------------------- // views::DialogDelegate -------------------------------------------------------
views::View* BookmarkBubbleView::CreateExtraView() {
edit_button_ = views::MdTextButton::CreateSecondaryUiButton(
this, l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_OPTIONS));
edit_button_->AddAccelerator(ui::Accelerator(ui::VKEY_E, ui::EF_ALT_DOWN));
return edit_button_;
}
bool BookmarkBubbleView::GetExtraViewPadding(int* padding) {
*padding = ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_UNRELATED_CONTROL_HORIZONTAL_LARGE);
return true;
}
views::View* BookmarkBubbleView::CreateFootnoteView() { views::View* BookmarkBubbleView::CreateFootnoteView() {
#if defined(OS_WIN) #if defined(OS_WIN)
if (!is_showing_ios_promotion_ && if (!is_showing_ios_promotion_ &&
...@@ -198,29 +219,41 @@ views::View* BookmarkBubbleView::CreateFootnoteView() { ...@@ -198,29 +219,41 @@ views::View* BookmarkBubbleView::CreateFootnoteView() {
return footnote_view_; return footnote_view_;
} }
// views::View ----------------------------------------------------------------- bool BookmarkBubbleView::Cancel() {
base::RecordAction(UserMetricsAction("BookmarkBubble_Unstar"));
const char* BookmarkBubbleView::GetClassName() const { // Set this so we remove the bookmark after the window closes.
return "BookmarkBubbleView"; remove_bookmark_ = true;
apply_edits_ = false;
return true;
} }
bool BookmarkBubbleView::AcceleratorPressed( bool BookmarkBubbleView::Accept() {
const ui::Accelerator& accelerator) { #if defined(OS_WIN)
ui::KeyboardCode key_code = accelerator.key_code(); using desktop_ios_promotion::PromotionEntryPoint;
if (key_code == ui::VKEY_RETURN) { if (IsIOSPromotionEligible(PromotionEntryPoint::BOOKMARKS_BUBBLE)) {
HandleButtonPressed(save_button_); ShowIOSPromotion(PromotionEntryPoint::BOOKMARKS_BUBBLE);
return true; return false;
} }
if (key_code == ui::VKEY_E && accelerator.IsAltDown()) { #endif
HandleButtonPressed(edit_button_);
return true; return true;
} }
if (key_code == ui::VKEY_R && accelerator.IsAltDown()) {
HandleButtonPressed(remove_button_); bool BookmarkBubbleView::Close() {
// Allow closing when activation lost. Default would call Accept().
return true; return true;
} }
return LocationBarBubbleDelegateView::AcceleratorPressed(accelerator); void BookmarkBubbleView::UpdateButton(views::LabelButton* button,
ui::DialogButton type) {
LocationBarBubbleDelegateView::UpdateButton(button, type);
if (type == ui::DIALOG_BUTTON_CANCEL)
button->AddAccelerator(ui::Accelerator(ui::VKEY_R, ui::EF_ALT_DOWN));
}
// views::View -----------------------------------------------------------------
const char* BookmarkBubbleView::GetClassName() const {
return "BookmarkBubbleView";
} }
void BookmarkBubbleView::GetAccessibleNodeData(ui::AXNodeData* node_data) { void BookmarkBubbleView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
...@@ -234,7 +267,8 @@ void BookmarkBubbleView::GetAccessibleNodeData(ui::AXNodeData* node_data) { ...@@ -234,7 +267,8 @@ void BookmarkBubbleView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
void BookmarkBubbleView::ButtonPressed(views::Button* sender, void BookmarkBubbleView::ButtonPressed(views::Button* sender,
const ui::Event& event) { const ui::Event& event) {
HandleButtonPressed(sender); base::RecordAction(UserMetricsAction("BookmarkBubble_Edit"));
ShowEditor();
} }
// views::ComboboxListener ----------------------------------------------------- // views::ComboboxListener -----------------------------------------------------
...@@ -258,82 +292,54 @@ void BookmarkBubbleView::OnIOSPromotionFootnoteLinkClicked() { ...@@ -258,82 +292,54 @@ void BookmarkBubbleView::OnIOSPromotionFootnoteLinkClicked() {
// views::BubbleDialogDelegateView --------------------------------------------- // views::BubbleDialogDelegateView ---------------------------------------------
void BookmarkBubbleView::Init() { void BookmarkBubbleView::Init() {
remove_button_ = views::MdTextButton::CreateSecondaryUiButton( using views::GridLayout;
this, l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_REMOVE_BOOKMARK));
edit_button_ = views::MdTextButton::CreateSecondaryUiButton(
this, l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_OPTIONS));
save_button_ = views::MdTextButton::CreateSecondaryUiButton(
this, l10n_util::GetStringUTF16(IDS_DONE));
save_button_->SetIsDefault(true);
views::Label* combobox_label = new views::Label( SetLayoutManager(new views::FillLayout());
l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_FOLDER_TEXT));
parent_combobox_ = new UnsizedCombobox(&parent_model_);
parent_combobox_->set_listener(this);
parent_combobox_->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_BOOKMARK_AX_BUBBLE_FOLDER_TEXT));
SetLayoutManager(new views::FillLayout);
bookmark_contents_view_ = new views::View(); bookmark_contents_view_ = new views::View();
GridLayout* layout = new GridLayout(bookmark_contents_view_); GridLayout* layout = new GridLayout(bookmark_contents_view_);
bookmark_contents_view_->SetLayoutManager(layout); bookmark_contents_view_->SetLayoutManager(layout);
// This column set is used for the labels and textfields as well as the // This column set is used for the labels and textfields.
// buttons at the bottom. constexpr int kColumnId = 0;
const int cs_id = 0; constexpr float kFixed = 0.f;
ColumnSet* cs = layout->AddColumnSet(cs_id); constexpr float kStretchy = 1.f;
views::ColumnSet* cs = layout->AddColumnSet(kColumnId);
ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
cs->AddColumn(provider->GetControlLabelGridAlignment(), GridLayout::CENTER, 0, cs->AddColumn(provider->GetControlLabelGridAlignment(), GridLayout::CENTER,
GridLayout::USE_PREF, 0, 0); kFixed, GridLayout::USE_PREF, 0, 0);
cs->AddPaddingColumn( cs->AddPaddingColumn(kFixed, provider->GetDistanceMetric(
0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_HORIZONTAL)); DISTANCE_UNRELATED_CONTROL_HORIZONTAL));
cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, kStretchy,
cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, GridLayout::USE_PREF,
0, 0);
cs->AddPaddingColumn(1, provider->GetDistanceMetric(
DISTANCE_UNRELATED_CONTROL_HORIZONTAL_LARGE));
cs->AddColumn(GridLayout::LEADING, GridLayout::TRAILING, 0,
GridLayout::USE_PREF, 0, 0);
cs->AddPaddingColumn(0, provider->GetDistanceMetric(
views::DISTANCE_RELATED_BUTTON_HORIZONTAL));
cs->AddColumn(GridLayout::LEADING, GridLayout::TRAILING, 0,
GridLayout::USE_PREF, 0, 0); GridLayout::USE_PREF, 0, 0);
layout->StartRow(0, cs_id); layout->StartRow(kFixed, kColumnId);
views::Label* label = new views::Label( views::Label* label = new views::Label(
l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_TITLE_TEXT)); l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_NAME_LABEL));
layout->AddView(label); layout->AddView(label);
name_field_ = new views::Textfield(); name_field_ = new views::Textfield();
name_field_->SetText(GetBookmarkName()); name_field_->SetText(GetBookmarkName());
name_field_->SetAccessibleName( name_field_->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_BOOKMARK_AX_BUBBLE_TITLE_TEXT)); l10n_util::GetStringUTF16(IDS_BOOKMARK_AX_BUBBLE_NAME_LABEL));
layout->AddView(name_field_);
layout->AddView(name_field_, 5, 1);
layout->AddPaddingRow( layout->StartRowWithPadding(
0, provider->GetInsetsMetric(views::INSETS_DIALOG_CONTENTS).top()); kFixed, kColumnId, kFixed,
provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL));
layout->StartRow(0, cs_id); views::Label* combobox_label = new views::Label(
l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_FOLDER_LABEL));
layout->AddView(combobox_label); layout->AddView(combobox_label);
layout->AddView(parent_combobox_, 5, 1);
layout->AddPaddingRow( parent_combobox_ = new UnsizedCombobox(&parent_model_);
0, provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL)); parent_combobox_->set_listener(this);
parent_combobox_->SetAccessibleName(
layout->StartRow(0, cs_id); l10n_util::GetStringUTF16(IDS_BOOKMARK_AX_BUBBLE_FOLDER_LABEL));
layout->SkipColumns(2); layout->AddView(parent_combobox_);
layout->AddView(remove_button_);
layout->AddView(edit_button_);
layout->AddView(save_button_);
AddAccelerator(ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE)); layout->AddPaddingRow(
AddAccelerator(ui::Accelerator(ui::VKEY_E, ui::EF_ALT_DOWN)); kFixed,
AddAccelerator(ui::Accelerator(ui::VKEY_R, ui::EF_ALT_DOWN)); provider->GetInsetsMetric(views::INSETS_DIALOG_CONTENTS).bottom());
AddChildView(bookmark_contents_view_); AddChildView(bookmark_contents_view_);
} }
...@@ -355,17 +361,7 @@ BookmarkBubbleView::BookmarkBubbleView( ...@@ -355,17 +361,7 @@ BookmarkBubbleView::BookmarkBubbleView(
newly_bookmarked_(newly_bookmarked), newly_bookmarked_(newly_bookmarked),
parent_model_(BookmarkModelFactory::GetForBrowserContext(profile_), parent_model_(BookmarkModelFactory::GetForBrowserContext(profile_),
BookmarkModelFactory::GetForBrowserContext(profile_) BookmarkModelFactory::GetForBrowserContext(profile_)
->GetMostRecentlyAddedUserNodeForURL(url)), ->GetMostRecentlyAddedUserNodeForURL(url)) {
remove_button_(nullptr),
edit_button_(nullptr),
save_button_(nullptr),
name_field_(nullptr),
parent_combobox_(nullptr),
ios_promo_view_(nullptr),
footnote_view_(nullptr),
remove_bookmark_(false),
apply_edits_(true),
is_showing_ios_promotion_(false) {
chrome::RecordDialogCreation(chrome::DialogIdentifier::BOOKMARK); chrome::RecordDialogCreation(chrome::DialogIdentifier::BOOKMARK);
} }
...@@ -381,32 +377,6 @@ base::string16 BookmarkBubbleView::GetBookmarkName() { ...@@ -381,32 +377,6 @@ base::string16 BookmarkBubbleView::GetBookmarkName() {
return base::string16(); return base::string16();
} }
void BookmarkBubbleView::HandleButtonPressed(views::Button* sender) {
if (sender == remove_button_) {
base::RecordAction(UserMetricsAction("BookmarkBubble_Unstar"));
// Set this so we remove the bookmark after the window closes.
remove_bookmark_ = true;
apply_edits_ = false;
GetWidget()->Close();
} else if (sender == edit_button_) {
base::RecordAction(UserMetricsAction("BookmarkBubble_Edit"));
ShowEditor();
} else {
DCHECK_EQ(save_button_, sender);
#if defined(OS_WIN)
if (IsIOSPromotionEligible(
desktop_ios_promotion::PromotionEntryPoint::BOOKMARKS_BUBBLE)) {
ShowIOSPromotion(
desktop_ios_promotion::PromotionEntryPoint::BOOKMARKS_BUBBLE);
} else {
GetWidget()->Close();
}
#else
GetWidget()->Close();
#endif
}
}
void BookmarkBubbleView::ShowEditor() { void BookmarkBubbleView::ShowEditor() {
const BookmarkNode* node = const BookmarkNode* node =
BookmarkModelFactory::GetForBrowserContext(profile_) BookmarkModelFactory::GetForBrowserContext(profile_)
...@@ -457,6 +427,7 @@ bool BookmarkBubbleView::IsIOSPromotionEligible( ...@@ -457,6 +427,7 @@ bool BookmarkBubbleView::IsIOSPromotionEligible(
void BookmarkBubbleView::ShowIOSPromotion( void BookmarkBubbleView::ShowIOSPromotion(
desktop_ios_promotion::PromotionEntryPoint entry_point) { desktop_ios_promotion::PromotionEntryPoint entry_point) {
DCHECK(!is_showing_ios_promotion_); DCHECK(!is_showing_ios_promotion_);
edit_button_->SetVisible(false);
// Hide the contents, but don't delete. Its child views are accessed in the // Hide the contents, but don't delete. Its child views are accessed in the
// destructor if there are edits to apply. // destructor if there are edits to apply.
bookmark_contents_view_->SetVisible(false); bookmark_contents_view_->SetVisible(false);
...@@ -467,7 +438,7 @@ void BookmarkBubbleView::ShowIOSPromotion( ...@@ -467,7 +438,7 @@ void BookmarkBubbleView::ShowIOSPromotion(
AddChildView(ios_promo_view_); AddChildView(ios_promo_view_);
GetWidget()->UpdateWindowIcon(); GetWidget()->UpdateWindowIcon();
GetWidget()->UpdateWindowTitle(); GetWidget()->UpdateWindowTitle();
// Resize the bubble so it has the same width as the parent bubble. GetDialogClientView()->UpdateDialogButtons();
ios_promo_view_->UpdateBubbleHeight(); SizeToContents();
} }
#endif #endif
...@@ -66,16 +66,22 @@ class BookmarkBubbleView : public LocationBarBubbleDelegateView, ...@@ -66,16 +66,22 @@ class BookmarkBubbleView : public LocationBarBubbleDelegateView,
~BookmarkBubbleView() override; ~BookmarkBubbleView() override;
// views::LocationBarBubbleDelegateView: // LocationBarBubbleDelegateView:
int GetDialogButtons() const override; int GetDialogButtons() const override;
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
View* GetInitiallyFocusedView() override; View* GetInitiallyFocusedView() override;
base::string16 GetWindowTitle() const override; base::string16 GetWindowTitle() const override;
gfx::ImageSkia GetWindowIcon() override; gfx::ImageSkia GetWindowIcon() override;
bool ShouldShowWindowIcon() const override; bool ShouldShowWindowIcon() const override;
void WindowClosing() override; void WindowClosing() override;
View* CreateFootnoteView() override; views::View* CreateExtraView() override;
bool GetExtraViewPadding(int* padding) override;
views::View* CreateFootnoteView() override;
bool Cancel() override;
bool Accept() override;
bool Close() override;
void UpdateButton(views::LabelButton* button, ui::DialogButton type) override;
const char* GetClassName() const override; const char* GetClassName() const override;
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override; void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
// views::ButtonListener: // views::ButtonListener:
...@@ -88,7 +94,7 @@ class BookmarkBubbleView : public LocationBarBubbleDelegateView, ...@@ -88,7 +94,7 @@ class BookmarkBubbleView : public LocationBarBubbleDelegateView,
void OnIOSPromotionFootnoteLinkClicked() override; void OnIOSPromotionFootnoteLinkClicked() override;
protected: protected:
// views::LocationBarBubbleDelegateView: // LocationBarBubbleDelegateView:
void Init() override; void Init() override;
private: private:
...@@ -106,9 +112,6 @@ class BookmarkBubbleView : public LocationBarBubbleDelegateView, ...@@ -106,9 +112,6 @@ class BookmarkBubbleView : public LocationBarBubbleDelegateView,
// Returns the name of the bookmark. // Returns the name of the bookmark.
base::string16 GetBookmarkName(); base::string16 GetBookmarkName();
// Closes the bubble, opens the edit dialog, or shows the iOS promo.
void HandleButtonPressed(views::Button* sender);
// Shows the BookmarkEditor. // Shows the BookmarkEditor.
void ShowEditor(); void ShowEditor();
...@@ -144,40 +147,34 @@ class BookmarkBubbleView : public LocationBarBubbleDelegateView, ...@@ -144,40 +147,34 @@ class BookmarkBubbleView : public LocationBarBubbleDelegateView,
RecentlyUsedFoldersComboModel parent_model_; RecentlyUsedFoldersComboModel parent_model_;
// Button for removing the bookmark.
views::LabelButton* remove_button_;
// Button to bring up the editor. // Button to bring up the editor.
views::LabelButton* edit_button_; views::LabelButton* edit_button_ = nullptr;
// Button to save the bookmark.
views::LabelButton* save_button_;
// Textfield showing the name of the bookmark. // Textfield showing the name of the bookmark.
views::Textfield* name_field_; views::Textfield* name_field_ = nullptr;
// Combobox showing a handful of folders the user can choose from, including // Combobox showing a handful of folders the user can choose from, including
// the current parent. // the current parent.
views::Combobox* parent_combobox_; views::Combobox* parent_combobox_ = nullptr;
// The regular bookmark bubble contents, with all the edit fields and dialog // The regular bookmark bubble contents, with all the edit fields and dialog
// buttons. TODO(tapted): Move the buttons to the DialogClientView. // buttons. TODO(tapted): Move the buttons to the DialogClientView.
views::View* bookmark_contents_view_; views::View* bookmark_contents_view_ = nullptr;
// iOS promotion view. // iOS promotion view.
DesktopIOSPromotionBubbleView* ios_promo_view_; DesktopIOSPromotionBubbleView* ios_promo_view_ = nullptr;
// Footnote view. // Footnote view.
views::View* footnote_view_; views::View* footnote_view_ = nullptr;
// When the destructor is invoked should the bookmark be removed? // When the destructor is invoked should the bookmark be removed?
bool remove_bookmark_; bool remove_bookmark_ = false;
// When the destructor is invoked should edits be applied? // When the destructor is invoked should edits be applied?
bool apply_edits_; bool apply_edits_ = true;
// Whether the Windows to iOS promotion is shown to the user. // Whether the Windows to iOS promotion is shown to the user.
bool is_showing_ios_promotion_; bool is_showing_ios_promotion_ = false;
DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleView); DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleView);
}; };
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "components/bookmarks/browser/bookmark_model.h" #include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/browser/bookmark_utils.h" #include "components/bookmarks/browser/bookmark_utils.h"
#include "components/bookmarks/test/bookmark_test_helpers.h" #include "components/bookmarks/test/bookmark_test_helpers.h"
#include "ui/views/window/dialog_client_view.h"
namespace { namespace {
...@@ -68,8 +69,11 @@ class BookmarkBubbleViewBrowserTest : public DialogBrowserTest { ...@@ -68,8 +69,11 @@ class BookmarkBubbleViewBrowserTest : public DialogBrowserTest {
nullptr, nullptr, nullptr, profile_.get(), GURL(kTestBookmarkURL), nullptr, nullptr, nullptr, profile_.get(), GURL(kTestBookmarkURL),
true); true);
if (name == "ios_promotion") { if (name == "ios_promotion") {
BookmarkBubbleView::bookmark_bubble()->HandleButtonPressed( BookmarkBubbleView::bookmark_bubble()
BookmarkBubbleView::bookmark_bubble()->save_button_); ->GetWidget()
->client_view()
->AsDialogClientView()
->AcceptWindow();
} }
} }
......
...@@ -96,19 +96,16 @@ void DesktopIOSPromotionBubbleView::ButtonPressed(views::Button* sender, ...@@ -96,19 +96,16 @@ void DesktopIOSPromotionBubbleView::ButtonPressed(views::Button* sender,
GetWidget()->Close(); GetWidget()->Close();
} }
void DesktopIOSPromotionBubbleView::UpdateBubbleHeight() {
gfx::Rect old_bounds = GetWidget()->GetWindowBoundsInScreen();
old_bounds.set_height(
GetWidget()->GetRootView()->GetHeightForWidth(old_bounds.width()));
GetWidget()->SetBounds(old_bounds);
}
void DesktopIOSPromotionBubbleView::UpdateRecoveryPhoneLabel() { void DesktopIOSPromotionBubbleView::UpdateRecoveryPhoneLabel() {
std::string number = promotion_controller_->GetUsersRecoveryPhoneNumber(); std::string number = promotion_controller_->GetUsersRecoveryPhoneNumber();
if (!number.empty()) { if (!number.empty()) {
promotion_text_label_->SetText(desktop_ios_promotion::GetPromoText( promotion_text_label_->SetText(desktop_ios_promotion::GetPromoText(
promotion_controller_->entry_point(), number)); promotion_controller_->entry_point(), number));
Layout(); Layout();
UpdateBubbleHeight(); views::Widget* widget = GetWidget();
gfx::Rect old_bounds = widget->GetWindowBoundsInScreen();
old_bounds.set_height(
widget->GetRootView()->GetHeightForWidth(old_bounds.width()));
widget->SetBounds(old_bounds);
} }
} }
...@@ -28,9 +28,6 @@ class DesktopIOSPromotionBubbleView : public DesktopIOSPromotionView, ...@@ -28,9 +28,6 @@ class DesktopIOSPromotionBubbleView : public DesktopIOSPromotionView,
desktop_ios_promotion::PromotionEntryPoint entry_point); desktop_ios_promotion::PromotionEntryPoint entry_point);
~DesktopIOSPromotionBubbleView() override; ~DesktopIOSPromotionBubbleView() override;
// Update Bubble Height to fit the content.
void UpdateBubbleHeight();
// DesktopIOSPromotionView: // DesktopIOSPromotionView:
void UpdateRecoveryPhoneLabel() override; void UpdateRecoveryPhoneLabel() override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment