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

Side by Side Diff: chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.cc

Issue 2558483002: views: convert ToolbarActionsBarBubble to Harmony (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.h" 5 #include "chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.h"
6 6
7 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_bubble_delegate.h" 7 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_bubble_delegate.h"
8 #include "chrome/browser/ui/view_ids.h" 8 #include "chrome/browser/ui/view_ids.h"
9 #include "chrome/browser/ui/views/harmony/layout_delegate.h"
9 #include "chrome/grit/locale_settings.h" 10 #include "chrome/grit/locale_settings.h"
10 #include "ui/base/resource/resource_bundle.h" 11 #include "ui/base/resource/resource_bundle.h"
11 #include "ui/gfx/color_palette.h" 12 #include "ui/gfx/color_palette.h"
12 #include "ui/gfx/paint_vector_icon.h" 13 #include "ui/gfx/paint_vector_icon.h"
13 #include "ui/gfx/vector_icons_public.h" 14 #include "ui/gfx/vector_icons_public.h"
14 #include "ui/views/controls/button/label_button.h" 15 #include "ui/views/controls/button/label_button.h"
15 #include "ui/views/controls/image_view.h" 16 #include "ui/views/controls/image_view.h"
16 #include "ui/views/controls/label.h" 17 #include "ui/views/controls/label.h"
17 #include "ui/views/controls/link.h" 18 #include "ui/views/controls/link.h"
18 #include "ui/views/layout/box_layout.h" 19 #include "ui/views/layout/box_layout.h"
19 #include "ui/views/layout/layout_constants.h"
20 20
21 namespace { 21 namespace {
22 const int kListPadding = 10;
23 const int kIconSize = 16; 22 const int kIconSize = 16;
24 } 23 }
25 24
26 ToolbarActionsBarBubbleViews::ToolbarActionsBarBubbleViews( 25 ToolbarActionsBarBubbleViews::ToolbarActionsBarBubbleViews(
27 views::View* anchor_view, 26 views::View* anchor_view,
28 std::unique_ptr<ToolbarActionsBarBubbleDelegate> delegate) 27 std::unique_ptr<ToolbarActionsBarBubbleDelegate> delegate)
29 : views::BubbleDialogDelegateView(anchor_view, 28 : views::BubbleDialogDelegateView(anchor_view,
30 views::BubbleBorder::TOP_RIGHT), 29 views::BubbleBorder::TOP_RIGHT),
31 delegate_(std::move(delegate)), 30 delegate_(std::move(delegate)),
32 item_list_(nullptr), 31 item_list_(nullptr),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 label.reset(link_); 64 label.reset(link_);
66 } else { 65 } else {
67 label.reset(new views::Label(text)); 66 label.reset(new views::Label(text));
68 } 67 }
69 } 68 }
70 69
71 if (icon && label) { 70 if (icon && label) {
72 views::View* parent = new views::View(); 71 views::View* parent = new views::View();
73 parent->SetLayoutManager( 72 parent->SetLayoutManager(
74 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 73 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
75 views::kRelatedControlVerticalSpacing)); 74 LayoutDelegate::Get()->GetLayoutDistance(
75 LayoutDelegate::LayoutDistanceType::
76 RELATED_CONTROL_VERTICAL_SPACING)));
76 parent->AddChildView(icon.release()); 77 parent->AddChildView(icon.release());
77 parent->AddChildView(label.release()); 78 parent->AddChildView(label.release());
78 return parent; 79 return parent;
79 } 80 }
80 81
81 return icon ? static_cast<views::View*>(icon.release()) 82 return icon ? static_cast<views::View*>(icon.release())
82 : static_cast<views::View*>(label.release()); 83 : static_cast<views::View*>(label.release());
83 } 84 }
84 85
85 base::string16 ToolbarActionsBarBubbleViews::GetWindowTitle() const { 86 base::string16 ToolbarActionsBarBubbleViews::GetWindowTitle() const {
(...skipping 13 matching lines...) Expand all
99 100
100 bool ToolbarActionsBarBubbleViews::Close() { 101 bool ToolbarActionsBarBubbleViews::Close() {
101 if (delegate_) { 102 if (delegate_) {
102 delegate_->OnBubbleClosed( 103 delegate_->OnBubbleClosed(
103 ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_DEACTIVATION); 104 ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_DEACTIVATION);
104 } 105 }
105 return true; 106 return true;
106 } 107 }
107 108
108 void ToolbarActionsBarBubbleViews::Init() { 109 void ToolbarActionsBarBubbleViews::Init() {
109 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 110 LayoutDelegate* delegate = LayoutDelegate::Get();
110 views::kRelatedControlVerticalSpacing)); 111 SetLayoutManager(new views::BoxLayout(
112 views::BoxLayout::kVertical, 0, 0,
113 delegate->GetLayoutDistance(LayoutDelegate::LayoutDistanceType::
114 RELATED_CONTROL_VERTICAL_SPACING)));
111 115
112 // Add the content string. 116 // Add the content string.
113 views::Label* content_label = new views::Label( 117 views::Label* content_label = new views::Label(
114 delegate_->GetBodyText(GetAnchorView()->id() == VIEW_ID_BROWSER_ACTION)); 118 delegate_->GetBodyText(GetAnchorView()->id() == VIEW_ID_BROWSER_ACTION));
115 content_label->SetMultiLine(true); 119 content_label->SetMultiLine(true);
116 int width = views::Widget::GetLocalizedContentsWidth( 120 int width = views::Widget::GetLocalizedContentsWidth(
117 IDS_EXTENSION_TOOLBAR_REDESIGN_NOTIFICATION_BUBBLE_WIDTH_CHARS); 121 IDS_EXTENSION_TOOLBAR_REDESIGN_NOTIFICATION_BUBBLE_WIDTH_CHARS);
118 content_label->SizeToFit(width); 122 content_label->SizeToFit(width);
119 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 123 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
120 AddChildView(content_label); 124 AddChildView(content_label);
121 125
122 base::string16 item_list = delegate_->GetItemListText(); 126 base::string16 item_list = delegate_->GetItemListText();
127
123 if (!item_list.empty()) { 128 if (!item_list.empty()) {
124 item_list_ = new views::Label(item_list); 129 item_list_ = new views::Label(item_list);
125 item_list_->SetBorder(views::CreateEmptyBorder(0, kListPadding, 0, 0)); 130 item_list_->SetBorder(views::CreateEmptyBorder(
131 0, delegate->GetLayoutDistance(LayoutDelegate::LayoutDistanceType::
132 RELATED_CONTROL_HORIZONTAL_SPACING),
133 0, 0));
126 item_list_->SetMultiLine(true); 134 item_list_->SetMultiLine(true);
127 item_list_->SizeToFit(width); 135 item_list_->SizeToFit(width);
128 item_list_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 136 item_list_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
129 AddChildView(item_list_); 137 AddChildView(item_list_);
130 } 138 }
131 } 139 }
132 140
133 int ToolbarActionsBarBubbleViews::GetDialogButtons() const { 141 int ToolbarActionsBarBubbleViews::GetDialogButtons() const {
134 int buttons = ui::DIALOG_BUTTON_NONE; 142 int buttons = ui::DIALOG_BUTTON_NONE;
135 if (!delegate_->GetActionButtonText().empty()) 143 if (!delegate_->GetActionButtonText().empty())
(...skipping 15 matching lines...) Expand all
151 : delegate_->GetDismissButtonText(); 159 : delegate_->GetDismissButtonText();
152 } 160 }
153 161
154 void ToolbarActionsBarBubbleViews::LinkClicked(views::Link* link, 162 void ToolbarActionsBarBubbleViews::LinkClicked(views::Link* link,
155 int event_flags) { 163 int event_flags) {
156 delegate_->OnBubbleClosed(ToolbarActionsBarBubbleDelegate::CLOSE_LEARN_MORE); 164 delegate_->OnBubbleClosed(ToolbarActionsBarBubbleDelegate::CLOSE_LEARN_MORE);
157 // Reset delegate so we don't send extra OnBubbleClosed()s. 165 // Reset delegate so we don't send extra OnBubbleClosed()s.
158 delegate_.reset(); 166 delegate_.reset();
159 GetWidget()->Close(); 167 GetWidget()->Close();
160 } 168 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698