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

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

Issue 1858773006: [Extensions UI] Use the ExtensionMessageBubbleBridge for Views platforms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/grit/locale_settings.h" 9 #include "chrome/grit/locale_settings.h"
9 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
10 #include "ui/views/controls/button/label_button.h" 11 #include "ui/views/controls/button/label_button.h"
11 #include "ui/views/controls/label.h" 12 #include "ui/views/controls/label.h"
12 #include "ui/views/layout/grid_layout.h" 13 #include "ui/views/layout/grid_layout.h"
13 #include "ui/views/layout/layout_constants.h" 14 #include "ui/views/layout/layout_constants.h"
14 15
15 ToolbarActionsBarBubbleViews::ToolbarActionsBarBubbleViews( 16 ToolbarActionsBarBubbleViews::ToolbarActionsBarBubbleViews(
16 views::View* anchor_view, 17 views::View* anchor_view,
17 std::unique_ptr<ToolbarActionsBarBubbleDelegate> delegate) 18 std::unique_ptr<ToolbarActionsBarBubbleDelegate> delegate)
18 : views::BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), 19 : views::BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT),
20 anchor_view_(anchor_view),
19 delegate_(std::move(delegate)), 21 delegate_(std::move(delegate)),
20 heading_label_(nullptr), 22 heading_label_(nullptr),
21 content_label_(nullptr), 23 content_label_(nullptr),
22 dismiss_button_(nullptr), 24 dismiss_button_(nullptr),
23 action_button_(nullptr), 25 action_button_(nullptr),
24 acknowledged_(false) {} 26 acknowledged_(false) {
27 set_close_on_deactivate(delegate_->ShouldCloseOnDeactivate());
28 }
25 29
26 ToolbarActionsBarBubbleViews::~ToolbarActionsBarBubbleViews() {} 30 ToolbarActionsBarBubbleViews::~ToolbarActionsBarBubbleViews() {}
27 31
28 void ToolbarActionsBarBubbleViews::Show() { 32 void ToolbarActionsBarBubbleViews::Show() {
29 delegate_->OnBubbleShown(); 33 delegate_->OnBubbleShown();
30 GetWidget()->Show(); 34 GetWidget()->Show();
31 } 35 }
32 36
33 void ToolbarActionsBarBubbleViews::Init() { 37 void ToolbarActionsBarBubbleViews::Init() {
34 views::GridLayout* layout = new views::GridLayout(this); 38 views::GridLayout* layout = new views::GridLayout(this);
(...skipping 26 matching lines...) Expand all
61 ui::ResourceBundle::GetSharedInstance().GetFontList( 65 ui::ResourceBundle::GetSharedInstance().GetFontList(
62 ui::ResourceBundle::MediumFont)); 66 ui::ResourceBundle::MediumFont));
63 heading_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 67 heading_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
64 layout->AddView(heading_label_); 68 layout->AddView(heading_label_);
65 layout->AddPaddingRow(0, views::kLabelToControlVerticalSpacing); 69 layout->AddPaddingRow(0, views::kLabelToControlVerticalSpacing);
66 int width = views::Widget::GetLocalizedContentsWidth( 70 int width = views::Widget::GetLocalizedContentsWidth(
67 IDS_EXTENSION_TOOLBAR_REDESIGN_NOTIFICATION_BUBBLE_WIDTH_CHARS); 71 IDS_EXTENSION_TOOLBAR_REDESIGN_NOTIFICATION_BUBBLE_WIDTH_CHARS);
68 72
69 // Add the content string. 73 // Add the content string.
70 layout->StartRow(0, HEADER_AND_BODY_COLUMN_SET); 74 layout->StartRow(0, HEADER_AND_BODY_COLUMN_SET);
71 content_label_ = new views::Label(delegate_->GetBodyText()); 75 content_label_ = new views::Label(
76 delegate_->GetBodyText(anchor_view_->id() == VIEW_ID_BROWSER_ACTION));
72 content_label_->SetMultiLine(true); 77 content_label_->SetMultiLine(true);
73 content_label_->SizeToFit(width); 78 content_label_->SizeToFit(width);
74 content_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 79 content_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
75 layout->AddView(content_label_); 80 layout->AddView(content_label_);
76 layout->AddPaddingRow(0, views::kLabelToControlVerticalSpacing); 81 layout->AddPaddingRow(0, views::kLabelToControlVerticalSpacing);
77 82
78 layout->StartRow(0, BUTTON_STRIP_COLUMN_SET); 83 layout->StartRow(0, BUTTON_STRIP_COLUMN_SET);
79 base::string16 dismiss_button_text = delegate_->GetDismissButtonText(); 84 base::string16 dismiss_button_text = delegate_->GetDismissButtonText();
80 if (!dismiss_button_text.empty()) { 85 if (!dismiss_button_text.empty()) {
81 dismiss_button_ = new views::LabelButton(this, dismiss_button_text); 86 dismiss_button_ = new views::LabelButton(this, dismiss_button_text);
(...skipping 22 matching lines...) Expand all
104 acknowledged_ = true; 109 acknowledged_ = true;
105 } 110 }
106 } 111 }
107 112
108 void ToolbarActionsBarBubbleViews::ButtonPressed(views::Button* sender, 113 void ToolbarActionsBarBubbleViews::ButtonPressed(views::Button* sender,
109 const ui::Event& event) { 114 const ui::Event& event) {
110 delegate_->OnBubbleClosed(ToolbarActionsBarBubbleDelegate::CLOSE_EXECUTE); 115 delegate_->OnBubbleClosed(ToolbarActionsBarBubbleDelegate::CLOSE_EXECUTE);
111 acknowledged_ = true; 116 acknowledged_ = true;
112 GetWidget()->Close(); 117 GetWidget()->Close();
113 } 118 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698