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

Side by Side Diff: chrome/browser/ui/views/extensions/extension_installed_bubble_view.cc

Issue 1915123005: Use normal bubble header components in ExtensionInstalledBubbleView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: msw review Created 4 years, 7 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
« 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/metrics/user_metrics_action.h" 10 #include "base/metrics/user_metrics_action.h"
11 #include "chrome/browser/extensions/extension_action_manager.h" 11 #include "chrome/browser/extensions/extension_action_manager.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_window.h"
15 #include "chrome/browser/ui/chrome_pages.h" 13 #include "chrome/browser/ui/chrome_pages.h"
16 #include "chrome/browser/ui/extensions/extension_installed_bubble.h" 14 #include "chrome/browser/ui/extensions/extension_installed_bubble.h"
17 #include "chrome/browser/ui/singleton_tabs.h" 15 #include "chrome/browser/ui/singleton_tabs.h"
18 #include "chrome/browser/ui/sync/bubble_sync_promo_delegate.h" 16 #include "chrome/browser/ui/sync/bubble_sync_promo_delegate.h"
19 #include "chrome/browser/ui/views/frame/browser_view.h" 17 #include "chrome/browser/ui/views/frame/browser_view.h"
20 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 18 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
21 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" 19 #include "chrome/browser/ui/views/location_bar/location_icon_view.h"
22 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" 20 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h"
23 #include "chrome/browser/ui/views/sync/bubble_sync_promo_view.h" 21 #include "chrome/browser/ui/views/sync/bubble_sync_promo_view.h"
24 #include "chrome/browser/ui/views/toolbar/app_menu_button.h" 22 #include "chrome/browser/ui/views/toolbar/app_menu_button.h"
25 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" 23 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
26 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 24 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
27 #include "chrome/common/url_constants.h" 25 #include "chrome/common/url_constants.h"
28 #include "chrome/grit/chromium_strings.h" 26 #include "chrome/grit/chromium_strings.h"
29 #include "chrome/grit/generated_resources.h" 27 #include "chrome/grit/generated_resources.h"
30 #include "components/bubble/bubble_controller.h" 28 #include "components/bubble/bubble_controller.h"
31 #include "components/bubble/bubble_ui.h" 29 #include "components/bubble/bubble_ui.h"
32 #include "content/public/browser/user_metrics.h" 30 #include "content/public/browser/user_metrics.h"
33 #include "extensions/common/extension.h" 31 #include "extensions/common/extension.h"
34 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
35 #include "ui/base/resource/resource_bundle.h" 33 #include "ui/base/resource/resource_bundle.h"
msw 2016/04/27 17:29:19 nit: remove
Evan Stade 2016/04/28 00:00:35 Done.
36 #include "ui/gfx/render_text.h" 34 #include "ui/gfx/image/image_skia_operations.h"
37 #include "ui/gfx/text_elider.h"
38 #include "ui/resources/grit/ui_resources.h" 35 #include "ui/resources/grit/ui_resources.h"
39 #include "ui/views/bubble/bubble_dialog_delegate.h" 36 #include "ui/views/bubble/bubble_dialog_delegate.h"
40 #include "ui/views/bubble/bubble_frame_view.h"
41 #include "ui/views/controls/button/button.h"
42 #include "ui/views/controls/button/image_button.h"
43 #include "ui/views/controls/image_view.h"
44 #include "ui/views/controls/label.h" 37 #include "ui/views/controls/label.h"
45 #include "ui/views/controls/link.h" 38 #include "ui/views/controls/link.h"
46 #include "ui/views/controls/link_listener.h" 39 #include "ui/views/controls/link_listener.h"
47 #include "ui/views/layout/box_layout.h" 40 #include "ui/views/layout/box_layout.h"
48 #include "ui/views/layout/grid_layout.h"
49 #include "ui/views/layout/layout_constants.h" 41 #include "ui/views/layout/layout_constants.h"
50 42
51 using extensions::Extension; 43 using extensions::Extension;
52 44
53 namespace { 45 namespace {
54 46
55 const int kIconSize = 43; 47 const int kIconSize = 43;
56 48
57 const int kRightColumnWidth = 285; 49 const int kRightColumnWidth = 285;
58 50
59 views::Label* CreateLabel(const base::string16& text, 51 views::Label* CreateLabel(const base::string16& text) {
60 const gfx::FontList& font) { 52 views::Label* label = new views::Label(text);
61 views::Label* label = new views::Label(text, font);
62 label->SetMultiLine(true); 53 label->SetMultiLine(true);
63 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 54 label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
55 label->SizeToFit(kRightColumnWidth);
64 return label; 56 return label;
65 } 57 }
66 58
67 class HeadingAndCloseButtonView : public views::View {
68 public:
69 HeadingAndCloseButtonView(views::Label* heading, views::LabelButton* close)
70 : heading_(heading), close_(close) {
71 AddChildView(heading_);
72 AddChildView(close_);
73 }
74 ~HeadingAndCloseButtonView() override {}
75
76 void Layout() override {
77 gfx::Size close_size = close_->GetPreferredSize();
78 gfx::Size view_size = size();
79
80 // Close button is in the upper right and always gets its full desired size.
81 close_->SetBounds(view_size.width() - close_size.width(),
82 0,
83 close_size.width(),
84 close_size.height());
85 // The heading takes up the remaining room (modulo padding).
86 heading_->SetBounds(
87 0,
88 0,
89 view_size.width() - close_size.width() -
90 views::kUnrelatedControlHorizontalSpacing,
91 view_size.height());
92 }
93
94 gfx::Size GetPreferredSize() const override {
95 gfx::Size heading_size = heading_->GetPreferredSize();
96 gfx::Size close_size = close_->GetPreferredSize();
97 return gfx::Size(kRightColumnWidth,
98 std::max(heading_size.height(), close_size.height()));
99 }
100
101 int GetHeightForWidth(int width) const override {
102 gfx::Size close_size = close_->GetPreferredSize();
103 int heading_width = width - views::kUnrelatedControlHorizontalSpacing -
104 close_size.width();
105 return std::max(heading_->GetHeightForWidth(heading_width),
106 close_size.height());
107 }
108
109 private:
110 views::Label* heading_;
111 views::LabelButton* close_;
112
113 DISALLOW_COPY_AND_ASSIGN(HeadingAndCloseButtonView);
114 };
115
116 // Provides feedback to the user upon successful installation of an 59 // Provides feedback to the user upon successful installation of an
117 // extension. Depending on the type of extension, the Bubble will 60 // extension. Depending on the type of extension, the Bubble will
118 // point to: 61 // point to:
119 // OMNIBOX_KEYWORD-> The omnibox. 62 // OMNIBOX_KEYWORD-> The omnibox.
120 // BROWSER_ACTION -> The browserAction icon in the toolbar. 63 // BROWSER_ACTION -> The browserAction icon in the toolbar.
121 // PAGE_ACTION -> A preview of the pageAction icon in the location 64 // PAGE_ACTION -> A preview of the pageAction icon in the location
122 // bar which is shown while the Bubble is shown. 65 // bar which is shown while the Bubble is shown.
123 // GENERIC -> The app menu. This case includes pageActions that don't 66 // GENERIC -> The app menu. This case includes pageActions that don't
124 // specify a default icon. 67 // specify a default icon.
125 class ExtensionInstalledBubbleView : public BubbleSyncPromoDelegate, 68 class ExtensionInstalledBubbleView : public BubbleSyncPromoDelegate,
126 public views::BubbleDialogDelegateView, 69 public views::BubbleDialogDelegateView,
127 public views::ButtonListener,
128 public views::LinkListener { 70 public views::LinkListener {
129 public: 71 public:
130 explicit ExtensionInstalledBubbleView(ExtensionInstalledBubble* bubble); 72 explicit ExtensionInstalledBubbleView(ExtensionInstalledBubble* bubble);
131 ~ExtensionInstalledBubbleView() override; 73 ~ExtensionInstalledBubbleView() override;
132 74
133 // Recalculate the anchor position for this bubble. 75 // Recalculate the anchor position for this bubble.
134 void UpdateAnchorView(); 76 void UpdateAnchorView();
135 77
136 void CloseBubble(); 78 void CloseBubble();
137 79
138 private: 80 private:
139 Browser* browser() { return controller_->browser(); } 81 Browser* browser() { return controller_->browser(); }
140 82
141 // views::BubbleDialogDelegateView: 83 // views::BubbleDialogDelegateView:
142 void Init() override; 84 base::string16 GetWindowTitle() const override;
85 gfx::ImageSkia GetWindowIcon() override;
86 bool ShouldShowWindowIcon() const override;
87 bool ShouldShowCloseButton() const override;
143 View* CreateFootnoteView() override; 88 View* CreateFootnoteView() override;
144 int GetDialogButtons() const override; 89 int GetDialogButtons() const override;
90 void Init() override;
145 91
146 // BubbleSyncPromoDelegate: 92 // BubbleSyncPromoDelegate:
147 void OnSignInLinkClicked() override; 93 void OnSignInLinkClicked() override;
148 94
149 // views::LinkListener: 95 // views::LinkListener:
150 void LinkClicked(views::Link* source, int event_flags) override; 96 void LinkClicked(views::Link* source, int event_flags) override;
151 97
152 // views::ButtonListener: 98 // Gets the size of the icon, capped at kIconSize.
153 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 99 gfx::Size GetIconSize() const;
154 100
155 ExtensionInstalledBubble* controller_; 101 ExtensionInstalledBubble* controller_;
156 ExtensionInstalledBubble::BubbleType type_; 102 ExtensionInstalledBubble::BubbleType type_;
157 ExtensionInstalledBubble::AnchorPosition anchor_position_; 103 ExtensionInstalledBubble::AnchorPosition anchor_position_;
158 104
159 // The button to close the bubble.
160 views::LabelButton* close_;
161
162 // The shortcut to open the manage shortcuts page. 105 // The shortcut to open the manage shortcuts page.
163 views::Link* manage_shortcut_; 106 views::Link* manage_shortcut_;
164 107
165 DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubbleView); 108 DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubbleView);
166 }; 109 };
167 110
168 ExtensionInstalledBubbleView::ExtensionInstalledBubbleView( 111 ExtensionInstalledBubbleView::ExtensionInstalledBubbleView(
169 ExtensionInstalledBubble* controller) 112 ExtensionInstalledBubble* controller)
170 : BubbleDialogDelegateView(nullptr, 113 : BubbleDialogDelegateView(nullptr,
171 controller->anchor_position() == 114 controller->anchor_position() ==
172 ExtensionInstalledBubble::ANCHOR_OMNIBOX 115 ExtensionInstalledBubble::ANCHOR_OMNIBOX
173 ? views::BubbleBorder::TOP_LEFT 116 ? views::BubbleBorder::TOP_LEFT
174 : views::BubbleBorder::TOP_RIGHT), 117 : views::BubbleBorder::TOP_RIGHT),
175 controller_(controller), 118 controller_(controller),
176 close_(nullptr),
177 manage_shortcut_(nullptr) {} 119 manage_shortcut_(nullptr) {}
178 120
179 ExtensionInstalledBubbleView::~ExtensionInstalledBubbleView() {} 121 ExtensionInstalledBubbleView::~ExtensionInstalledBubbleView() {}
180 122
181 void ExtensionInstalledBubbleView::UpdateAnchorView() { 123 void ExtensionInstalledBubbleView::UpdateAnchorView() {
182 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser()); 124 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
183 125
184 views::View* reference_view = nullptr; 126 views::View* reference_view = nullptr;
185 switch (controller_->anchor_position()) { 127 switch (controller_->anchor_position()) {
186 case ExtensionInstalledBubble::ANCHOR_BROWSER_ACTION: { 128 case ExtensionInstalledBubble::ANCHOR_BROWSER_ACTION: {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 BrowserView::GetBrowserViewForBrowser(browser()); 175 BrowserView::GetBrowserViewForBrowser(browser());
234 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( 176 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction(
235 extensions::ExtensionActionManager::Get(browser()->profile()) 177 extensions::ExtensionActionManager::Get(browser()->profile())
236 ->GetPageAction(*controller_->extension()), 178 ->GetPageAction(*controller_->extension()),
237 false); // preview_enabled 179 false); // preview_enabled
238 } 180 }
239 controller_ = nullptr; 181 controller_ = nullptr;
240 GetWidget()->Close(); 182 GetWidget()->Close();
241 } 183 }
242 184
185 base::string16 ExtensionInstalledBubbleView::GetWindowTitle() const {
186 // Add the heading (for all options).
187 base::string16 extension_name =
188 base::UTF8ToUTF16(controller_->extension()->name());
189 base::i18n::AdjustStringForLocaleDirection(&extension_name);
190 return l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALLED_HEADING,
191 extension_name);
192 }
193
194 gfx::ImageSkia ExtensionInstalledBubbleView::GetWindowIcon() {
195 const SkBitmap& bitmap = controller_->icon();
196 return gfx::ImageSkiaOperations::CreateResizedImage(
197 gfx::ImageSkia::CreateFrom1xBitmap(bitmap),
198 skia::ImageOperations::RESIZE_BEST, GetIconSize());
199 }
200
201 bool ExtensionInstalledBubbleView::ShouldShowWindowIcon() const {
202 return true;
203 }
204
243 views::View* ExtensionInstalledBubbleView::CreateFootnoteView() { 205 views::View* ExtensionInstalledBubbleView::CreateFootnoteView() {
244 if (!(controller_->options() & ExtensionInstalledBubble::SIGN_IN_PROMO)) 206 if (!(controller_->options() & ExtensionInstalledBubble::SIGN_IN_PROMO))
245 return nullptr; 207 return nullptr;
246 208
247 return new BubbleSyncPromoView(this, 209 return new BubbleSyncPromoView(this,
248 IDS_EXTENSION_INSTALLED_SYNC_PROMO_LINK_NEW, 210 IDS_EXTENSION_INSTALLED_SYNC_PROMO_LINK_NEW,
249 IDS_EXTENSION_INSTALLED_SYNC_PROMO_NEW); 211 IDS_EXTENSION_INSTALLED_SYNC_PROMO_NEW);
250 } 212 }
251 213
252 int ExtensionInstalledBubbleView::GetDialogButtons() const { 214 int ExtensionInstalledBubbleView::GetDialogButtons() const {
253 return ui::DIALOG_BUTTON_NONE; 215 return ui::DIALOG_BUTTON_NONE;
254 } 216 }
255 217
256 void ExtensionInstalledBubbleView::OnSignInLinkClicked() { 218 bool ExtensionInstalledBubbleView::ShouldShowCloseButton() const {
257 chrome::ShowBrowserSignin( 219 return true;
258 browser(),
259 signin_metrics::AccessPoint::ACCESS_POINT_EXTENSION_INSTALL_BUBBLE);
260 CloseBubble();
261 }
262
263 void ExtensionInstalledBubbleView::ButtonPressed(views::Button* sender,
264 const ui::Event& event) {
265 DCHECK_EQ(sender, close_);
266 CloseBubble();
267 }
268
269 void ExtensionInstalledBubbleView::LinkClicked(views::Link* source,
270 int event_flags) {
271 DCHECK_EQ(manage_shortcut_, source);
272
273 std::string configure_url = chrome::kChromeUIExtensionsURL;
274 configure_url += chrome::kExtensionConfigureCommandsSubPage;
275 chrome::NavigateParams params(
276 chrome::GetSingletonTabNavigateParams(browser(), GURL(configure_url)));
277 chrome::Navigate(&params);
278 CloseBubble();
279 } 220 }
280 221
281 void ExtensionInstalledBubbleView::Init() { 222 void ExtensionInstalledBubbleView::Init() {
223 gfx::Insets insets = margins();
282 UpdateAnchorView(); 224 UpdateAnchorView();
283 225
284 // The Extension Installed bubble takes on various forms, depending on the 226 // The Extension Installed bubble takes on various forms, depending on the
285 // type of extension installed. In general, though, they are all similar: 227 // type of extension installed. In general, though, they are all similar:
286 // 228 //
287 // ------------------------- 229 // -------------------------
288 // | | Heading [X] | 230 // | Icon | Title (x) |
289 // | Icon | Info | 231 // | Info |
290 // | | Extra info | 232 // | Extra info |
291 // ------------------------- 233 // -------------------------
292 // 234 //
293 // Icon and Heading are always shown (as well as the close button). 235 // Icon and Title are always shown (as well as the close button).
294 // Info is shown for browser actions, page actions and Omnibox keyword 236 // Info is shown for browser actions, page actions and Omnibox keyword
295 // extensions and might list keyboard shorcut for the former two types. 237 // extensions and might list keyboard shorcut for the former two types.
296 // Extra info is... 238 // Extra info is...
297 // ... for other types, either a description of how to manage the extension 239 // ... for other types, either a description of how to manage the extension
298 // or a link to configure the keybinding shortcut (if one exists). 240 // or a link to configure the keybinding shortcut (if one exists).
299 // Extra info can include a promo for signing into sync. 241 // Extra info can include a promo for signing into sync.
300 242
301 // The number of rows in the content section of the bubble. 243 // Move explanatory text closer to the title.
302 int main_content_row_count = 1; 244 set_margins(gfx::Insets(0, insets.left(), insets.bottom(), insets.right()));
245
246 std::unique_ptr<views::BoxLayout> layout(
247 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0,
248 views::kRelatedControlVerticalSpacing));
249 // Indent by the size of the icon.
250 layout->set_inside_border_insets(gfx::Insets(
251 0, GetIconSize().width() + views::kUnrelatedControlHorizontalSpacing, 0,
252 0));
253 SetLayoutManager(layout.release());
254
303 if (controller_->options() & ExtensionInstalledBubble::HOW_TO_USE) 255 if (controller_->options() & ExtensionInstalledBubble::HOW_TO_USE)
304 ++main_content_row_count; 256 AddChildView(CreateLabel(controller_->GetHowToUseDescription()));
305 if (controller_->options() & ExtensionInstalledBubble::SHOW_KEYBINDING)
306 ++main_content_row_count;
307 if (controller_->options() & ExtensionInstalledBubble::HOW_TO_MANAGE)
308 ++main_content_row_count;
309
310 views::GridLayout* layout = new views::GridLayout(this);
311 SetLayoutManager(layout);
312
313 const int cs_id = 0;
314
315 views::ColumnSet* main_cs = layout->AddColumnSet(cs_id);
316 // Icon column.
317 main_cs->AddColumn(views::GridLayout::CENTER, views::GridLayout::LEADING, 0,
318 views::GridLayout::USE_PREF, 0, 0);
319 main_cs->AddPaddingColumn(0, views::kUnrelatedControlHorizontalSpacing);
320 // Heading column.
321 main_cs->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING, 0,
322 views::GridLayout::FIXED, kRightColumnWidth, 0);
323
324 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
325 const gfx::FontList& font_list = rb.GetFontList(ui::ResourceBundle::BaseFont);
326
327 const SkBitmap& bitmap = controller_->icon();
328 // Add the icon (for all options).
329 // Scale down to 43x43, but allow smaller icons (don't scale up).
330 gfx::Size size(bitmap.width(), bitmap.height());
331 if (size.width() > kIconSize || size.height() > kIconSize)
332 size = gfx::Size(kIconSize, kIconSize);
333 views::ImageView* icon = new views::ImageView();
334 icon->SetImageSize(size);
335 icon->SetImage(gfx::ImageSkia::CreateFrom1xBitmap(bitmap));
336
337 layout->StartRow(0, cs_id);
338 layout->AddView(icon, 1, main_content_row_count);
339
340 // Add the heading (for all options).
341 base::string16 extension_name =
342 base::UTF8ToUTF16(controller_->extension()->name());
343 base::i18n::AdjustStringForLocaleDirection(&extension_name);
344 views::Label* heading =
345 CreateLabel(l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALLED_HEADING,
346 extension_name),
347 rb.GetFontList(ui::ResourceBundle::MediumFont));
348
349 close_ = views::BubbleFrameView::CreateCloseButton(this);
350
351 HeadingAndCloseButtonView* heading_and_close =
352 new HeadingAndCloseButtonView(heading, close_);
353
354 layout->AddView(heading_and_close);
355 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
356
357 auto add_content_view = [&layout, &cs_id](views::View* view) {
358 layout->StartRow(0, cs_id);
359 // Skip the icon column.
360 layout->SkipColumns(1);
361 layout->AddView(view);
362 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
363 };
364
365 if (controller_->options() & ExtensionInstalledBubble::HOW_TO_USE) {
366 add_content_view(
367 CreateLabel(controller_->GetHowToUseDescription(), font_list));
368 }
369 257
370 if (controller_->options() & ExtensionInstalledBubble::SHOW_KEYBINDING) { 258 if (controller_->options() & ExtensionInstalledBubble::SHOW_KEYBINDING) {
371 manage_shortcut_ = new views::Link( 259 manage_shortcut_ = new views::Link(
372 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_SHORTCUTS)); 260 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_SHORTCUTS));
373 manage_shortcut_->set_listener(this); 261 manage_shortcut_->set_listener(this);
374 manage_shortcut_->SetUnderline(false); 262 manage_shortcut_->SetUnderline(false);
375 add_content_view(manage_shortcut_); 263 AddChildView(manage_shortcut_);
376 } 264 }
377 265
378 if (controller_->options() & ExtensionInstalledBubble::HOW_TO_MANAGE) { 266 if (controller_->options() & ExtensionInstalledBubble::HOW_TO_MANAGE) {
379 add_content_view(CreateLabel( 267 AddChildView(CreateLabel(
380 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO), 268 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO)));
381 font_list));
382 } 269 }
383 } 270 }
384 271
272 void ExtensionInstalledBubbleView::OnSignInLinkClicked() {
273 chrome::ShowBrowserSignin(
274 browser(),
275 signin_metrics::AccessPoint::ACCESS_POINT_EXTENSION_INSTALL_BUBBLE);
276 CloseBubble();
277 }
278
279 void ExtensionInstalledBubbleView::LinkClicked(views::Link* source,
280 int event_flags) {
281 DCHECK_EQ(manage_shortcut_, source);
282
283 std::string configure_url = chrome::kChromeUIExtensionsURL;
284 configure_url += chrome::kExtensionConfigureCommandsSubPage;
285 chrome::NavigateParams params(
286 chrome::GetSingletonTabNavigateParams(browser(), GURL(configure_url)));
287 chrome::Navigate(&params);
288 CloseBubble();
289 }
290
291 gfx::Size ExtensionInstalledBubbleView::GetIconSize() const {
292 const SkBitmap& bitmap = controller_->icon();
293 // Scale down to 43x43, but allow smaller icons (don't scale up).
294 gfx::Size size(bitmap.width(), bitmap.height());
295 return size.width() > kIconSize || size.height() > kIconSize
296 ? gfx::Size(kIconSize, kIconSize)
297 : size;
298 }
299
385 // NB: This bubble is using the temporarily-deprecated bubble manager interface 300 // NB: This bubble is using the temporarily-deprecated bubble manager interface
386 // BubbleUi. Do not copy this pattern. 301 // BubbleUi. Do not copy this pattern.
387 class ExtensionInstalledBubbleUi : public BubbleUi, 302 class ExtensionInstalledBubbleUi : public BubbleUi,
388 public views::WidgetObserver { 303 public views::WidgetObserver {
389 public: 304 public:
390 explicit ExtensionInstalledBubbleUi(ExtensionInstalledBubble* bubble); 305 explicit ExtensionInstalledBubbleUi(ExtensionInstalledBubble* bubble);
391 ~ExtensionInstalledBubbleUi() override; 306 ~ExtensionInstalledBubbleUi() override;
392 307
393 // BubbleUi: 308 // BubbleUi:
394 void Show(BubbleReference bubble_reference) override; 309 void Show(BubbleReference bubble_reference) override;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 ->browser_actions(); 366 ->browser_actions();
452 return !container->animating(); 367 return !container->animating();
453 } 368 }
454 return true; 369 return true;
455 } 370 }
456 371
457 // Implemented here to create the platform specific instance of the BubbleUi. 372 // Implemented here to create the platform specific instance of the BubbleUi.
458 std::unique_ptr<BubbleUi> ExtensionInstalledBubble::BuildBubbleUi() { 373 std::unique_ptr<BubbleUi> ExtensionInstalledBubble::BuildBubbleUi() {
459 return base::WrapUnique(new ExtensionInstalledBubbleUi(this)); 374 return base::WrapUnique(new ExtensionInstalledBubbleUi(this));
460 } 375 }
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