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" |
11 #include "ui/base/resource/resource_bundle.h" | 11 #include "ui/base/resource/resource_bundle.h" |
12 #include "ui/gfx/color_palette.h" | 12 #include "ui/gfx/color_palette.h" |
13 #include "ui/gfx/paint_vector_icon.h" | 13 #include "ui/gfx/paint_vector_icon.h" |
14 #include "ui/gfx/vector_icons_public.h" | |
15 #include "ui/views/controls/button/label_button.h" | 14 #include "ui/views/controls/button/label_button.h" |
16 #include "ui/views/controls/image_view.h" | 15 #include "ui/views/controls/image_view.h" |
17 #include "ui/views/controls/label.h" | 16 #include "ui/views/controls/label.h" |
18 #include "ui/views/controls/link.h" | 17 #include "ui/views/controls/link.h" |
19 #include "ui/views/layout/box_layout.h" | 18 #include "ui/views/layout/box_layout.h" |
20 | 19 |
21 namespace { | 20 namespace { |
22 const int kIconSize = 16; | 21 const int kIconSize = 16; |
23 } | 22 } |
24 | 23 |
(...skipping 15 matching lines...) Expand all Loading... |
40 GetWidget()->Show(); | 39 GetWidget()->Show(); |
41 } | 40 } |
42 | 41 |
43 views::View* ToolbarActionsBarBubbleViews::CreateExtraView() { | 42 views::View* ToolbarActionsBarBubbleViews::CreateExtraView() { |
44 std::unique_ptr<ToolbarActionsBarBubbleDelegate::ExtraViewInfo> | 43 std::unique_ptr<ToolbarActionsBarBubbleDelegate::ExtraViewInfo> |
45 extra_view_info = delegate_->GetExtraViewInfo(); | 44 extra_view_info = delegate_->GetExtraViewInfo(); |
46 | 45 |
47 if (!extra_view_info) | 46 if (!extra_view_info) |
48 return nullptr; | 47 return nullptr; |
49 | 48 |
50 gfx::VectorIconId resource_id = extra_view_info->resource_id; | |
51 std::unique_ptr<views::ImageView> icon; | 49 std::unique_ptr<views::ImageView> icon; |
52 if (resource_id != gfx::VectorIconId::VECTOR_ICON_NONE) { | 50 if (extra_view_info->resource) { |
53 icon.reset(new views::ImageView); | 51 icon.reset(new views::ImageView); |
54 icon->SetImage( | 52 icon->SetImage(gfx::CreateVectorIcon(*extra_view_info->resource, kIconSize, |
55 gfx::CreateVectorIcon(resource_id, kIconSize, gfx::kChromeIconGrey)); | 53 gfx::kChromeIconGrey)); |
56 } | 54 } |
57 | 55 |
58 std::unique_ptr<views::Label> label; | 56 std::unique_ptr<views::Label> label; |
59 const base::string16& text = extra_view_info->text; | 57 const base::string16& text = extra_view_info->text; |
60 if (!text.empty()) { | 58 if (!text.empty()) { |
61 if (extra_view_info->is_text_linked) { | 59 if (extra_view_info->is_text_linked) { |
62 link_ = new views::Link(text); | 60 link_ = new views::Link(text); |
63 link_->set_listener(this); | 61 link_->set_listener(this); |
64 label.reset(link_); | 62 label.reset(link_); |
65 } else { | 63 } else { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 : delegate_->GetDismissButtonText(); | 157 : delegate_->GetDismissButtonText(); |
160 } | 158 } |
161 | 159 |
162 void ToolbarActionsBarBubbleViews::LinkClicked(views::Link* link, | 160 void ToolbarActionsBarBubbleViews::LinkClicked(views::Link* link, |
163 int event_flags) { | 161 int event_flags) { |
164 delegate_->OnBubbleClosed(ToolbarActionsBarBubbleDelegate::CLOSE_LEARN_MORE); | 162 delegate_->OnBubbleClosed(ToolbarActionsBarBubbleDelegate::CLOSE_LEARN_MORE); |
165 // Reset delegate so we don't send extra OnBubbleClosed()s. | 163 // Reset delegate so we don't send extra OnBubbleClosed()s. |
166 delegate_.reset(); | 164 delegate_.reset(); |
167 GetWidget()->Close(); | 165 GetWidget()->Close(); |
168 } | 166 } |
OLD | NEW |