Chromium Code Reviews| Index: chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.cc |
| diff --git a/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.cc b/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.cc |
| index 6ab2dacebf97ebdb3cae5f686afb1a08fbb9aa18..17080bd29b7996d9dcc15e1eeabbe9046c7cbd5f 100644 |
| --- a/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.cc |
| +++ b/chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.cc |
| @@ -8,7 +8,11 @@ |
| #include "chrome/browser/ui/view_ids.h" |
| #include "chrome/grit/locale_settings.h" |
| #include "ui/base/resource/resource_bundle.h" |
| +#include "ui/gfx/color_palette.h" |
| +#include "ui/gfx/paint_vector_icon.h" |
| +#include "ui/gfx/vector_icons_public.h" |
| #include "ui/views/controls/button/label_button.h" |
| +#include "ui/views/controls/image_view.h" |
| #include "ui/views/controls/label.h" |
| #include "ui/views/controls/link.h" |
| #include "ui/views/layout/box_layout.h" |
| @@ -25,7 +29,7 @@ ToolbarActionsBarBubbleViews::ToolbarActionsBarBubbleViews( |
| views::BubbleBorder::TOP_RIGHT), |
| delegate_(std::move(delegate)), |
| item_list_(nullptr), |
| - learn_more_button_(nullptr) { |
| + link_(nullptr) { |
| set_close_on_deactivate(delegate_->ShouldCloseOnDeactivate()); |
| } |
| @@ -37,13 +41,44 @@ void ToolbarActionsBarBubbleViews::Show() { |
| } |
| views::View* ToolbarActionsBarBubbleViews::CreateExtraView() { |
| - base::string16 text = delegate_->GetLearnMoreButtonText(); |
| - if (text.empty()) |
| + std::unique_ptr<ToolbarActionsBarBubbleDelegate::ExtraViewInfo> |
| + extra_view_info = delegate_->GetExtraViewInfo(); |
| + |
| + if (!extra_view_info) |
| return nullptr; |
| - learn_more_button_ = new views::Link(text); |
| - learn_more_button_->set_listener(this); |
| - return learn_more_button_; |
| + gfx::VectorIconId resource_id = extra_view_info->resource_id; |
| + views::ImageView* icon = nullptr; |
| + if (resource_id != gfx::VectorIconId::VECTOR_ICON_NONE) { |
| + icon = new views::ImageView(); |
|
Devlin
2016/10/20 17:04:07
nit: I know this is all safe, but this method is l
catmullings
2016/10/21 03:49:29
Done.
|
| + icon->SetImage( |
| + gfx::CreateVectorIcon(resource_id, 16, gfx::kChromeIconGrey)); |
| + } |
| + |
| + views::Label* label = nullptr; |
| + const base::string16& text = extra_view_info->text; |
| + if (!text.empty()) { |
| + if (extra_view_info->is_text_linked) { |
| + link_ = new views::Link(text); |
| + link_->set_listener(this); |
| + label = link_; |
| + } else { |
| + label = new views::Label(text); |
| + } |
| + } |
| + |
| + if (icon && label) { |
| + views::View* parent = new views::View(); |
| + parent->SetLayoutManager( |
| + new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, |
| + views::kRelatedControlVerticalSpacing)); |
| + parent->AddChildView(icon); |
| + parent->AddChildView(label); |
| + return parent; |
| + } |
| + |
| + return icon ? static_cast<views::View*>(icon) |
| + : static_cast<views::View*>(label); |
| } |
| base::string16 ToolbarActionsBarBubbleViews::GetWindowTitle() const { |
| @@ -96,7 +131,9 @@ void ToolbarActionsBarBubbleViews::Init() { |
| } |
| int ToolbarActionsBarBubbleViews::GetDialogButtons() const { |
| - int buttons = ui::DIALOG_BUTTON_OK; |
| + int buttons = ui::DIALOG_BUTTON_NONE; |
| + if (!delegate_->GetActionButtonText().empty()) |
| + buttons |= ui::DIALOG_BUTTON_OK; |
| if (!delegate_->GetDismissButtonText().empty()) |
| buttons |= ui::DIALOG_BUTTON_CANCEL; |
| return buttons; |