OLD | NEW |
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/browser/ui/views/harmony/layout_delegate.h" |
10 #include "chrome/grit/locale_settings.h" | 10 #include "chrome/grit/locale_settings.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 link_ = new views::Link(text); | 62 link_ = new views::Link(text); |
63 link_->set_listener(this); | 63 link_->set_listener(this); |
64 label.reset(link_); | 64 label.reset(link_); |
65 } else { | 65 } else { |
66 label.reset(new views::Label(text)); | 66 label.reset(new views::Label(text)); |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 if (icon && label) { | 70 if (icon && label) { |
71 views::View* parent = new views::View(); | 71 views::View* parent = new views::View(); |
72 parent->SetLayoutManager( | 72 parent->SetLayoutManager(new views::BoxLayout( |
73 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, | 73 views::BoxLayout::kHorizontal, 0, 0, |
74 LayoutDelegate::Get()->GetLayoutDistance( | 74 LayoutDelegate::Get()->GetMetric( |
75 LayoutDelegate::LayoutDistanceType:: | 75 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING))); |
76 RELATED_CONTROL_VERTICAL_SPACING))); | |
77 parent->AddChildView(icon.release()); | 76 parent->AddChildView(icon.release()); |
78 parent->AddChildView(label.release()); | 77 parent->AddChildView(label.release()); |
79 return parent; | 78 return parent; |
80 } | 79 } |
81 | 80 |
82 return icon ? static_cast<views::View*>(icon.release()) | 81 return icon ? static_cast<views::View*>(icon.release()) |
83 : static_cast<views::View*>(label.release()); | 82 : static_cast<views::View*>(label.release()); |
84 } | 83 } |
85 | 84 |
86 base::string16 ToolbarActionsBarBubbleViews::GetWindowTitle() const { | 85 base::string16 ToolbarActionsBarBubbleViews::GetWindowTitle() const { |
(...skipping 16 matching lines...) Expand all Loading... |
103 delegate_->OnBubbleClosed( | 102 delegate_->OnBubbleClosed( |
104 ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_DEACTIVATION); | 103 ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_DEACTIVATION); |
105 } | 104 } |
106 return true; | 105 return true; |
107 } | 106 } |
108 | 107 |
109 void ToolbarActionsBarBubbleViews::Init() { | 108 void ToolbarActionsBarBubbleViews::Init() { |
110 LayoutDelegate* delegate = LayoutDelegate::Get(); | 109 LayoutDelegate* delegate = LayoutDelegate::Get(); |
111 SetLayoutManager(new views::BoxLayout( | 110 SetLayoutManager(new views::BoxLayout( |
112 views::BoxLayout::kVertical, 0, 0, | 111 views::BoxLayout::kVertical, 0, 0, |
113 delegate->GetLayoutDistance(LayoutDelegate::LayoutDistanceType:: | 112 delegate->GetMetric( |
114 RELATED_CONTROL_VERTICAL_SPACING))); | 113 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING))); |
115 | 114 |
116 // Add the content string. | 115 // Add the content string. |
117 views::Label* content_label = new views::Label( | 116 views::Label* content_label = new views::Label( |
118 delegate_->GetBodyText(GetAnchorView()->id() == VIEW_ID_BROWSER_ACTION)); | 117 delegate_->GetBodyText(GetAnchorView()->id() == VIEW_ID_BROWSER_ACTION)); |
119 content_label->SetMultiLine(true); | 118 content_label->SetMultiLine(true); |
120 int width = views::Widget::GetLocalizedContentsWidth( | 119 int width = views::Widget::GetLocalizedContentsWidth( |
121 IDS_EXTENSION_TOOLBAR_REDESIGN_NOTIFICATION_BUBBLE_WIDTH_CHARS); | 120 IDS_EXTENSION_TOOLBAR_REDESIGN_NOTIFICATION_BUBBLE_WIDTH_CHARS); |
122 content_label->SizeToFit(width); | 121 content_label->SizeToFit(width); |
123 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 122 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
124 AddChildView(content_label); | 123 AddChildView(content_label); |
125 | 124 |
126 base::string16 item_list = delegate_->GetItemListText(); | 125 base::string16 item_list = delegate_->GetItemListText(); |
127 | 126 |
128 if (!item_list.empty()) { | 127 if (!item_list.empty()) { |
129 item_list_ = new views::Label(item_list); | 128 item_list_ = new views::Label(item_list); |
130 item_list_->SetBorder(views::CreateEmptyBorder( | 129 item_list_->SetBorder(views::CreateEmptyBorder( |
131 0, delegate->GetLayoutDistance(LayoutDelegate::LayoutDistanceType:: | 130 0, |
132 RELATED_CONTROL_HORIZONTAL_SPACING), | 131 delegate->GetMetric( |
| 132 LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING), |
133 0, 0)); | 133 0, 0)); |
134 item_list_->SetMultiLine(true); | 134 item_list_->SetMultiLine(true); |
135 item_list_->SizeToFit(width); | 135 item_list_->SizeToFit(width); |
136 item_list_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 136 item_list_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
137 AddChildView(item_list_); | 137 AddChildView(item_list_); |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 int ToolbarActionsBarBubbleViews::GetDialogButtons() const { | 141 int ToolbarActionsBarBubbleViews::GetDialogButtons() const { |
142 int buttons = ui::DIALOG_BUTTON_NONE; | 142 int buttons = ui::DIALOG_BUTTON_NONE; |
(...skipping 16 matching lines...) Expand all Loading... |
159 : delegate_->GetDismissButtonText(); | 159 : delegate_->GetDismissButtonText(); |
160 } | 160 } |
161 | 161 |
162 void ToolbarActionsBarBubbleViews::LinkClicked(views::Link* link, | 162 void ToolbarActionsBarBubbleViews::LinkClicked(views::Link* link, |
163 int event_flags) { | 163 int event_flags) { |
164 delegate_->OnBubbleClosed(ToolbarActionsBarBubbleDelegate::CLOSE_LEARN_MORE); | 164 delegate_->OnBubbleClosed(ToolbarActionsBarBubbleDelegate::CLOSE_LEARN_MORE); |
165 // Reset delegate so we don't send extra OnBubbleClosed()s. | 165 // Reset delegate so we don't send extra OnBubbleClosed()s. |
166 delegate_.reset(); | 166 delegate_.reset(); |
167 GetWidget()->Close(); | 167 GetWidget()->Close(); |
168 } | 168 } |
OLD | NEW |