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 @@
<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
</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:
</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
</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:
</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
</message>
<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 @@
<textField verticalHuggingPriority="750" id="10">
<rect key="frame" x="17" y="6" width="65" height="14"/>
<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"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
......@@ -96,7 +96,7 @@
<textField verticalHuggingPriority="750" id="8">
<rect key="frame" x="17" y="31" width="65" height="14"/>
<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"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
......
......@@ -66,16 +66,22 @@ class BookmarkBubbleView : public LocationBarBubbleDelegateView,
~BookmarkBubbleView() override;
// views::LocationBarBubbleDelegateView:
// LocationBarBubbleDelegateView:
int GetDialogButtons() const override;
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
View* GetInitiallyFocusedView() override;
base::string16 GetWindowTitle() const override;
gfx::ImageSkia GetWindowIcon() override;
bool ShouldShowWindowIcon() const 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;
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
// views::ButtonListener:
......@@ -88,7 +94,7 @@ class BookmarkBubbleView : public LocationBarBubbleDelegateView,
void OnIOSPromotionFootnoteLinkClicked() override;
protected:
// views::LocationBarBubbleDelegateView:
// LocationBarBubbleDelegateView:
void Init() override;
private:
......@@ -106,9 +112,6 @@ class BookmarkBubbleView : public LocationBarBubbleDelegateView,
// Returns the name of the bookmark.
base::string16 GetBookmarkName();
// Closes the bubble, opens the edit dialog, or shows the iOS promo.
void HandleButtonPressed(views::Button* sender);
// Shows the BookmarkEditor.
void ShowEditor();
......@@ -144,40 +147,34 @@ class BookmarkBubbleView : public LocationBarBubbleDelegateView,
RecentlyUsedFoldersComboModel parent_model_;
// Button for removing the bookmark.
views::LabelButton* remove_button_;
// Button to bring up the editor.
views::LabelButton* edit_button_;
// Button to save the bookmark.
views::LabelButton* save_button_;
views::LabelButton* edit_button_ = nullptr;
// 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
// the current parent.
views::Combobox* parent_combobox_;
views::Combobox* parent_combobox_ = nullptr;
// The regular bookmark bubble contents, with all the edit fields and dialog
// buttons. TODO(tapted): Move the buttons to the DialogClientView.
views::View* bookmark_contents_view_;
views::View* bookmark_contents_view_ = nullptr;
// iOS promotion view.
DesktopIOSPromotionBubbleView* ios_promo_view_;
DesktopIOSPromotionBubbleView* ios_promo_view_ = nullptr;
// Footnote view.
views::View* footnote_view_;
views::View* footnote_view_ = nullptr;
// 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?
bool apply_edits_;
bool apply_edits_ = true;
// 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);
};
......
......@@ -17,6 +17,7 @@
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/browser/bookmark_utils.h"
#include "components/bookmarks/test/bookmark_test_helpers.h"
#include "ui/views/window/dialog_client_view.h"
namespace {
......@@ -68,8 +69,11 @@ class BookmarkBubbleViewBrowserTest : public DialogBrowserTest {
nullptr, nullptr, nullptr, profile_.get(), GURL(kTestBookmarkURL),
true);
if (name == "ios_promotion") {
BookmarkBubbleView::bookmark_bubble()->HandleButtonPressed(
BookmarkBubbleView::bookmark_bubble()->save_button_);
BookmarkBubbleView::bookmark_bubble()
->GetWidget()
->client_view()
->AsDialogClientView()
->AcceptWindow();
}
}
......
......@@ -96,19 +96,16 @@ void DesktopIOSPromotionBubbleView::ButtonPressed(views::Button* sender,
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() {
std::string number = promotion_controller_->GetUsersRecoveryPhoneNumber();
if (!number.empty()) {
promotion_text_label_->SetText(desktop_ios_promotion::GetPromoText(
promotion_controller_->entry_point(), number));
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,
desktop_ios_promotion::PromotionEntryPoint entry_point);
~DesktopIOSPromotionBubbleView() override;
// Update Bubble Height to fit the content.
void UpdateBubbleHeight();
// DesktopIOSPromotionView:
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