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

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

Issue 2206693002: Improve settings override bubble to indicate policy installed extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Non-Mac implementation of badge/extra view, that is, admin icon and text Created 4 years, 4 months 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
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/grit/locale_settings.h" 9 #include "chrome/grit/locale_settings.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
11 #include "ui/views/controls/button/label_button.h" 11 #include "ui/views/controls/button/label_button.h"
12 #include "ui/views/controls/image_view.h"
12 #include "ui/views/controls/label.h" 13 #include "ui/views/controls/label.h"
13 #include "ui/views/controls/link.h" 14 #include "ui/views/controls/link.h"
14 #include "ui/views/layout/box_layout.h" 15 #include "ui/views/layout/box_layout.h"
15 #include "ui/views/layout/layout_constants.h" 16 #include "ui/views/layout/layout_constants.h"
16 17
17 namespace { 18 namespace {
18 const int kListPadding = 10; 19 const int kListPadding = 10;
19 } 20 }
20 21
21 ToolbarActionsBarBubbleViews::ToolbarActionsBarBubbleViews( 22 ToolbarActionsBarBubbleViews::ToolbarActionsBarBubbleViews(
22 views::View* anchor_view, 23 views::View* anchor_view,
23 std::unique_ptr<ToolbarActionsBarBubbleDelegate> delegate) 24 std::unique_ptr<ToolbarActionsBarBubbleDelegate> delegate)
24 : views::BubbleDialogDelegateView(anchor_view, 25 : views::BubbleDialogDelegateView(anchor_view,
25 views::BubbleBorder::TOP_RIGHT), 26 views::BubbleBorder::TOP_RIGHT),
26 delegate_(std::move(delegate)), 27 delegate_(std::move(delegate)),
27 item_list_(nullptr), 28 item_list_(nullptr),
28 learn_more_button_(nullptr) { 29 learn_more_button_(nullptr) {
29 set_close_on_deactivate(delegate_->ShouldCloseOnDeactivate()); 30 set_close_on_deactivate(delegate_->ShouldCloseOnDeactivate());
30 } 31 }
31 32
32 ToolbarActionsBarBubbleViews::~ToolbarActionsBarBubbleViews() {} 33 ToolbarActionsBarBubbleViews::~ToolbarActionsBarBubbleViews() {}
33 34
34 void ToolbarActionsBarBubbleViews::Show() { 35 void ToolbarActionsBarBubbleViews::Show() {
35 delegate_->OnBubbleShown(); 36 delegate_->OnBubbleShown();
36 GetWidget()->Show(); 37 GetWidget()->Show();
37 } 38 }
38 39
39 views::View* ToolbarActionsBarBubbleViews::CreateExtraView() { 40 views::View* ToolbarActionsBarBubbleViews::CreateExtraView() {
40 base::string16 text = delegate_->GetLearnMoreButtonText(); 41 std::unique_ptr<ToolbarActionsBarBubbleDelegate::ExtraViewInfo>
41 if (text.empty()) 42 extra_view_info = delegate_->GetExtraViewInfo();
43
44 base::string16 text = extra_view_info->text;
45
46 if (text.empty()) {
42 return nullptr; 47 return nullptr;
Devlin 2016/08/02 20:34:06 What if we wanted to *just* show an icon, with no
catmullings 2016/08/13 00:35:52 Done.
48 }
43 49
44 learn_more_button_ = new views::Link(text); 50 if (extra_view_info->is_clickable) {
45 learn_more_button_->set_listener(this); 51 views::Link* button = new views::Link(text);
46 return learn_more_button_; 52 button->set_listener(this);
53
54 // TODO: Should I expect the text to always be the learn_more_button_?
55 // If not, should I still instantiate the learn_more_button_?
Devlin 2016/08/02 20:34:06 right now, it would be, and keeping it like this i
catmullings 2016/08/13 00:35:52 Done.
56 learn_more_button_ = new views::Link(text);
57 learn_more_button_->set_listener(this);
58
59 return button;
Devlin 2016/08/02 20:34:06 What about the case of a link + an icon?
catmullings 2016/08/13 00:35:52 Done.
60 }
61
62 views::View* parent = new views::View();
63 views::ImageView* icon = extra_view_info->icon;
64 parent->AddChildView(icon);
65 views::Label* label = new views::Label(text);
66 parent->AddChildView(label);
67 return parent;
47 } 68 }
48 69
49 base::string16 ToolbarActionsBarBubbleViews::GetWindowTitle() const { 70 base::string16 ToolbarActionsBarBubbleViews::GetWindowTitle() const {
50 return delegate_->GetHeadingText(); 71 return delegate_->GetHeadingText();
51 } 72 }
52 73
53 bool ToolbarActionsBarBubbleViews::Cancel() { 74 bool ToolbarActionsBarBubbleViews::Cancel() {
54 delegate_->OnBubbleClosed( 75 delegate_->OnBubbleClosed(
55 ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_USER_ACTION); 76 ToolbarActionsBarBubbleDelegate::CLOSE_DISMISS_USER_ACTION);
56 return true; 77 return true;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 : delegate_->GetDismissButtonText(); 135 : delegate_->GetDismissButtonText();
115 } 136 }
116 137
117 void ToolbarActionsBarBubbleViews::LinkClicked(views::Link* link, 138 void ToolbarActionsBarBubbleViews::LinkClicked(views::Link* link,
118 int event_flags) { 139 int event_flags) {
119 delegate_->OnBubbleClosed(ToolbarActionsBarBubbleDelegate::CLOSE_LEARN_MORE); 140 delegate_->OnBubbleClosed(ToolbarActionsBarBubbleDelegate::CLOSE_LEARN_MORE);
120 // Reset delegate so we don't send extra OnBubbleClosed()s. 141 // Reset delegate so we don't send extra OnBubbleClosed()s.
121 delegate_.reset(); 142 delegate_.reset();
122 GetWidget()->Close(); 143 GetWidget()->Close();
123 } 144 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698