| Index: chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
|
| diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
|
| index 3c2a17070d61bc074d6043d215b21dedc8c16e3c..bc25ff6bd7e5bffc551bd3790f69c5dce02ca76b 100644
|
| --- a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
|
| +++ b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
|
| @@ -22,6 +22,7 @@
|
| #include "ui/base/keycodes/keyboard_codes.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
| +#include "ui/views/bubble/bubble_frame_view.h"
|
| #include "ui/views/controls/button/label_button.h"
|
| #include "ui/views/controls/combobox/combobox.h"
|
| #include "ui/views/controls/label.h"
|
| @@ -37,14 +38,8 @@ using views::GridLayout;
|
|
|
| namespace {
|
|
|
| -// Padding between "Title:" and the actual title.
|
| -const int kTitlePadding = 4;
|
| -
|
| -// Minimum width for the fields - they will push out the size of the bubble if
|
| -// necessary. This should be big enough so that the field pushes the right side
|
| -// of the bubble far enough so that the edit button's left edge is to the right
|
| -// of the field's left edge.
|
| -const int kMinimumFieldSize = 180;
|
| +// Minimum width of the the bubble.
|
| +const int kMinBubbleWidth = 350;
|
|
|
| } // namespace
|
|
|
| @@ -89,6 +84,7 @@ void BookmarkBubbleView::ShowBubble(views::View* anchor_view,
|
| views::BubbleDelegateView::CreateBubble(bookmark_bubble_)->Show();
|
| // Select the entire title textfield contents when the bubble is first shown.
|
| bookmark_bubble_->title_tf_->SelectAll(true);
|
| + bookmark_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE);
|
|
|
| if (bookmark_bubble_->observer_)
|
| bookmark_bubble_->observer_->OnBookmarkBubbleShown(url);
|
| @@ -146,9 +142,16 @@ bool BookmarkBubbleView::AcceleratorPressed(
|
| }
|
|
|
| void BookmarkBubbleView::Init() {
|
| - remove_link_ = new views::Link(l10n_util::GetStringUTF16(
|
| + views::Label* title_label = new views::Label(
|
| + l10n_util::GetStringUTF16(
|
| + newly_bookmarked_ ? IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARKED :
|
| + IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARK));
|
| + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
|
| + title_label->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont));
|
| +
|
| + remove_button_ = new views::LabelButton(this, l10n_util::GetStringUTF16(
|
| IDS_BOOKMARK_BUBBLE_REMOVE_BOOKMARK));
|
| - remove_link_->set_listener(this);
|
| + remove_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
|
|
|
| edit_button_ = new views::LabelButton(
|
| this, l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_OPTIONS));
|
| @@ -166,66 +169,54 @@ void BookmarkBubbleView::Init() {
|
| parent_combobox_->set_listener(this);
|
| parent_combobox_->SetAccessibleName(combobox_label->text());
|
|
|
| - views::Label* title_label = new views::Label(
|
| - l10n_util::GetStringUTF16(
|
| - newly_bookmarked_ ? IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARKED :
|
| - IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARK));
|
| - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
|
| - title_label->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont));
|
| -
|
| GridLayout* layout = new GridLayout(this);
|
| SetLayoutManager(layout);
|
|
|
| - ColumnSet* cs = layout->AddColumnSet(0);
|
| -
|
| - // Top (title) row.
|
| - cs->AddColumn(GridLayout::CENTER, GridLayout::CENTER, 0, GridLayout::USE_PREF,
|
| - 0, 0);
|
| - cs->AddPaddingColumn(1, views::kUnrelatedControlHorizontalSpacing);
|
| + const int kTitleColumnSetID = 0;
|
| + ColumnSet* cs = layout->AddColumnSet(kTitleColumnSetID);
|
| cs->AddColumn(GridLayout::CENTER, GridLayout::CENTER, 0, GridLayout::USE_PREF,
|
| 0, 0);
|
|
|
| - // Middle (input field) rows.
|
| - cs = layout->AddColumnSet(2);
|
| + // The column layout used for middle and bottom rows.
|
| + const int kFirstColumnSetID = 1;
|
| + cs = layout->AddColumnSet(kFirstColumnSetID);
|
| cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
|
| GridLayout::USE_PREF, 0, 0);
|
| - cs->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing);
|
| - cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
|
| - GridLayout::USE_PREF, 0, kMinimumFieldSize);
|
| + cs->AddPaddingColumn(0, views::kUnrelatedControlHorizontalSpacing);
|
| +
|
| + cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0,
|
| + GridLayout::USE_PREF, 0, 0);
|
| + cs->AddPaddingColumn(1, views::kUnrelatedControlLargeHorizontalSpacing);
|
|
|
| - // Bottom (buttons) row.
|
| - cs = layout->AddColumnSet(3);
|
| - cs->AddPaddingColumn(1, views::kRelatedControlHorizontalSpacing);
|
| cs->AddColumn(GridLayout::LEADING, GridLayout::TRAILING, 0,
|
| GridLayout::USE_PREF, 0, 0);
|
| - // We subtract 2 to account for the natural button padding, and
|
| - // to bring the separation visually in line with the row separation
|
| - // height.
|
| - cs->AddPaddingColumn(0, views::kRelatedButtonHSpacing - 2);
|
| + cs->AddPaddingColumn(0, views::kRelatedButtonHSpacing);
|
| cs->AddColumn(GridLayout::LEADING, GridLayout::TRAILING, 0,
|
| GridLayout::USE_PREF, 0, 0);
|
|
|
| - layout->StartRow(0, 0);
|
| + layout->StartRow(0, kTitleColumnSetID);
|
| layout->AddView(title_label);
|
| - layout->AddView(remove_link_);
|
| + layout->AddPaddingRow(0, views::kUnrelatedControlHorizontalSpacing);
|
|
|
| - layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing);
|
| - layout->StartRow(0, 2);
|
| + layout->StartRow(0, kFirstColumnSetID);
|
| views::Label* label = new views::Label(
|
| l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_TITLE_TEXT));
|
| layout->AddView(label);
|
| title_tf_ = new views::Textfield();
|
| title_tf_->SetText(GetTitle());
|
| - layout->AddView(title_tf_);
|
| + layout->AddView(title_tf_, 5, 1);
|
|
|
| - layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing);
|
| + layout->AddPaddingRow(0, views::kUnrelatedControlHorizontalSpacing);
|
|
|
| - layout->StartRow(0, 2);
|
| + layout->StartRow(0, kFirstColumnSetID);
|
| layout->AddView(combobox_label);
|
| - layout->AddView(parent_combobox_);
|
| - layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing);
|
| + layout->AddView(parent_combobox_, 5, 1);
|
| +
|
| + layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
|
|
|
| - layout->StartRow(0, 3);
|
| + layout->StartRow(0, kFirstColumnSetID);
|
| + layout->SkipColumns(2);
|
| + layout->AddView(remove_button_);
|
| layout->AddView(edit_button_);
|
| layout->AddView(close_button_);
|
|
|
| @@ -246,15 +237,20 @@ BookmarkBubbleView::BookmarkBubbleView(views::View* anchor_view,
|
| BookmarkModelFactory::GetForProfile(profile_),
|
| BookmarkModelFactory::GetForProfile(profile_)->
|
| GetMostRecentlyAddedNodeForURL(url)),
|
| - remove_link_(NULL),
|
| + remove_button_(NULL),
|
| edit_button_(NULL),
|
| close_button_(NULL),
|
| title_tf_(NULL),
|
| parent_combobox_(NULL),
|
| remove_bookmark_(false),
|
| apply_edits_(true) {
|
| + const SkColor background_color = GetNativeTheme()->GetSystemColor(
|
| + ui::NativeTheme::kColorId_DialogBackground);
|
| + set_color(background_color);
|
| + set_background(views::Background::CreateSolidBackground(background_color));
|
| + set_margins(gfx::Insets(12, 19, 18, 18));
|
| // Compensate for built-in vertical padding in the anchor view's image.
|
| - set_anchor_view_insets(gfx::Insets(5, 0, 5, 0));
|
| + set_anchor_view_insets(gfx::Insets(7, 0, 7, 0));
|
| }
|
|
|
| string16 BookmarkBubbleView::GetTitle() {
|
| @@ -269,21 +265,17 @@ string16 BookmarkBubbleView::GetTitle() {
|
| return string16();
|
| }
|
|
|
| +gfx::Size BookmarkBubbleView::GetMinimumSize() {
|
| + gfx::Size size(views::BubbleDelegateView::GetPreferredSize());
|
| + size.SetToMax(gfx::Size(kMinBubbleWidth, 0));
|
| + return size;
|
| +}
|
| +
|
| void BookmarkBubbleView::ButtonPressed(views::Button* sender,
|
| const ui::Event& event) {
|
| HandleButtonPressed(sender);
|
| }
|
|
|
| -void BookmarkBubbleView::LinkClicked(views::Link* source, int event_flags) {
|
| - DCHECK_EQ(remove_link_, source);
|
| - content::RecordAction(UserMetricsAction("BookmarkBubble_Unstar"));
|
| -
|
| - // Set this so we remove the bookmark after the window closes.
|
| - remove_bookmark_ = true;
|
| - apply_edits_ = false;
|
| - StartFade(false);
|
| -}
|
| -
|
| void BookmarkBubbleView::OnSelectedIndexChanged(views::Combobox* combobox) {
|
| if (combobox->selected_index() + 1 == parent_model_.GetItemCount()) {
|
| content::RecordAction(UserMetricsAction("BookmarkBubble_EditFromCombobox"));
|
| @@ -292,7 +284,13 @@ void BookmarkBubbleView::OnSelectedIndexChanged(views::Combobox* combobox) {
|
| }
|
|
|
| void BookmarkBubbleView::HandleButtonPressed(views::Button* sender) {
|
| - if (sender == edit_button_) {
|
| + if (sender == remove_button_) {
|
| + content::RecordAction(UserMetricsAction("BookmarkBubble_Unstar"));
|
| + // Set this so we remove the bookmark after the window closes.
|
| + remove_bookmark_ = true;
|
| + apply_edits_ = false;
|
| + StartFade(false);
|
| + } else if (sender == edit_button_) {
|
| content::RecordAction(UserMetricsAction("BookmarkBubble_Edit"));
|
| ShowEditor();
|
| } else {
|
|
|