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

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: remove a couple more includes 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/gfx/image/image_skia_operations.h"
36 #include "ui/gfx/render_text.h"
37 #include "ui/gfx/text_elider.h"
38 #include "ui/resources/grit/ui_resources.h"
39 #include "ui/views/bubble/bubble_dialog_delegate.h" 34 #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" 35 #include "ui/views/controls/label.h"
45 #include "ui/views/controls/link.h" 36 #include "ui/views/controls/link.h"
46 #include "ui/views/controls/link_listener.h" 37 #include "ui/views/controls/link_listener.h"
47 #include "ui/views/layout/box_layout.h" 38 #include "ui/views/layout/box_layout.h"
48 #include "ui/views/layout/grid_layout.h"
49 #include "ui/views/layout/layout_constants.h" 39 #include "ui/views/layout/layout_constants.h"
50 40
51 using extensions::Extension; 41 using extensions::Extension;
52 42
53 namespace { 43 namespace {
54 44
55 const int kIconSize = 43; 45 const int kIconSize = 43;
56 46
57 const int kRightColumnWidth = 285; 47 const int kRightColumnWidth = 285;
58 48
59 views::Label* CreateLabel(const base::string16& text, 49 views::Label* CreateLabel(const base::string16& text) {
60 const gfx::FontList& font) { 50 views::Label* label = new views::Label(text);
61 views::Label* label = new views::Label(text, font);
62 label->SetMultiLine(true); 51 label->SetMultiLine(true);
63 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 52 label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
53 label->SizeToFit(kRightColumnWidth);
64 return label; 54 return label;
65 } 55 }
66 56
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 57 // Provides feedback to the user upon successful installation of an
117 // extension. Depending on the type of extension, the Bubble will 58 // extension. Depending on the type of extension, the Bubble will
118 // point to: 59 // point to:
119 // OMNIBOX_KEYWORD-> The omnibox. 60 // OMNIBOX_KEYWORD-> The omnibox.
120 // BROWSER_ACTION -> The browserAction icon in the toolbar. 61 // BROWSER_ACTION -> The browserAction icon in the toolbar.
121 // PAGE_ACTION -> A preview of the pageAction icon in the location 62 // PAGE_ACTION -> A preview of the pageAction icon in the location
122 // bar which is shown while the Bubble is shown. 63 // bar which is shown while the Bubble is shown.
123 // GENERIC -> The app menu. This case includes pageActions that don't 64 // GENERIC -> The app menu. This case includes pageActions that don't
124 // specify a default icon. 65 // specify a default icon.
125 class ExtensionInstalledBubbleView : public BubbleSyncPromoDelegate, 66 class ExtensionInstalledBubbleView : public BubbleSyncPromoDelegate,
126 public views::BubbleDialogDelegateView, 67 public views::BubbleDialogDelegateView,
127 public views::ButtonListener,
128 public views::LinkListener { 68 public views::LinkListener {
129 public: 69 public:
130 explicit ExtensionInstalledBubbleView(ExtensionInstalledBubble* bubble); 70 explicit ExtensionInstalledBubbleView(ExtensionInstalledBubble* bubble);
131 ~ExtensionInstalledBubbleView() override; 71 ~ExtensionInstalledBubbleView() override;
132 72
133 // Recalculate the anchor position for this bubble. 73 // Recalculate the anchor position for this bubble.
134 void UpdateAnchorView(); 74 void UpdateAnchorView();
135 75
136 void CloseBubble(); 76 void CloseBubble();
137 77
138 private: 78 private:
139 Browser* browser() { return controller_->browser(); } 79 Browser* browser() { return controller_->browser(); }
140 80
141 // views::BubbleDialogDelegateView: 81 // views::BubbleDialogDelegateView:
142 void Init() override; 82 base::string16 GetWindowTitle() const override;
83 gfx::ImageSkia GetWindowIcon() override;
84 bool ShouldShowWindowIcon() const override;
85 bool ShouldShowCloseButton() const override;
143 View* CreateFootnoteView() override; 86 View* CreateFootnoteView() override;
144 int GetDialogButtons() const override; 87 int GetDialogButtons() const override;
88 void Init() override;
145 89
146 // BubbleSyncPromoDelegate: 90 // BubbleSyncPromoDelegate:
147 void OnSignInLinkClicked() override; 91 void OnSignInLinkClicked() override;
148 92
149 // views::LinkListener: 93 // views::LinkListener:
150 void LinkClicked(views::Link* source, int event_flags) override; 94 void LinkClicked(views::Link* source, int event_flags) override;
151 95
152 // views::ButtonListener: 96 // Gets the size of the icon, capped at kIconSize.
153 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 97 gfx::Size GetIconSize() const;
154 98
155 ExtensionInstalledBubble* controller_; 99 ExtensionInstalledBubble* controller_;
156 ExtensionInstalledBubble::BubbleType type_; 100 ExtensionInstalledBubble::BubbleType type_;
157 ExtensionInstalledBubble::AnchorPosition anchor_position_; 101 ExtensionInstalledBubble::AnchorPosition anchor_position_;
158 102
159 // The button to close the bubble.
160 views::LabelButton* close_;
161
162 // The shortcut to open the manage shortcuts page. 103 // The shortcut to open the manage shortcuts page.
163 views::Link* manage_shortcut_; 104 views::Link* manage_shortcut_;
164 105
165 DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubbleView); 106 DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubbleView);
166 }; 107 };
167 108
168 ExtensionInstalledBubbleView::ExtensionInstalledBubbleView( 109 ExtensionInstalledBubbleView::ExtensionInstalledBubbleView(
169 ExtensionInstalledBubble* controller) 110 ExtensionInstalledBubble* controller)
170 : BubbleDialogDelegateView(nullptr, 111 : BubbleDialogDelegateView(nullptr,
171 controller->anchor_position() == 112 controller->anchor_position() ==
172 ExtensionInstalledBubble::ANCHOR_OMNIBOX 113 ExtensionInstalledBubble::ANCHOR_OMNIBOX
173 ? views::BubbleBorder::TOP_LEFT 114 ? views::BubbleBorder::TOP_LEFT
174 : views::BubbleBorder::TOP_RIGHT), 115 : views::BubbleBorder::TOP_RIGHT),
175 controller_(controller), 116 controller_(controller),
176 close_(nullptr),
177 manage_shortcut_(nullptr) {} 117 manage_shortcut_(nullptr) {}
178 118
179 ExtensionInstalledBubbleView::~ExtensionInstalledBubbleView() {} 119 ExtensionInstalledBubbleView::~ExtensionInstalledBubbleView() {}
180 120
181 void ExtensionInstalledBubbleView::UpdateAnchorView() { 121 void ExtensionInstalledBubbleView::UpdateAnchorView() {
182 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser()); 122 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
183 123
184 views::View* reference_view = nullptr; 124 views::View* reference_view = nullptr;
185 switch (controller_->anchor_position()) { 125 switch (controller_->anchor_position()) {
186 case ExtensionInstalledBubble::ANCHOR_BROWSER_ACTION: { 126 case ExtensionInstalledBubble::ANCHOR_BROWSER_ACTION: {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 BrowserView::GetBrowserViewForBrowser(browser()); 173 BrowserView::GetBrowserViewForBrowser(browser());
234 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( 174 browser_view->GetLocationBarView()->SetPreviewEnabledPageAction(
235 extensions::ExtensionActionManager::Get(browser()->profile()) 175 extensions::ExtensionActionManager::Get(browser()->profile())
236 ->GetPageAction(*controller_->extension()), 176 ->GetPageAction(*controller_->extension()),
237 false); // preview_enabled 177 false); // preview_enabled
238 } 178 }
239 controller_ = nullptr; 179 controller_ = nullptr;
240 GetWidget()->Close(); 180 GetWidget()->Close();
241 } 181 }
242 182
183 base::string16 ExtensionInstalledBubbleView::GetWindowTitle() const {
184 // Add the heading (for all options).
185 base::string16 extension_name =
186 base::UTF8ToUTF16(controller_->extension()->name());
187 base::i18n::AdjustStringForLocaleDirection(&extension_name);
188 return l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALLED_HEADING,
189 extension_name);
190 }
191
192 gfx::ImageSkia ExtensionInstalledBubbleView::GetWindowIcon() {
193 const SkBitmap& bitmap = controller_->icon();
194 return gfx::ImageSkiaOperations::CreateResizedImage(
195 gfx::ImageSkia::CreateFrom1xBitmap(bitmap),
196 skia::ImageOperations::RESIZE_BEST, GetIconSize());
197 }
198
199 bool ExtensionInstalledBubbleView::ShouldShowWindowIcon() const {
200 return true;
201 }
202
243 views::View* ExtensionInstalledBubbleView::CreateFootnoteView() { 203 views::View* ExtensionInstalledBubbleView::CreateFootnoteView() {
244 if (!(controller_->options() & ExtensionInstalledBubble::SIGN_IN_PROMO)) 204 if (!(controller_->options() & ExtensionInstalledBubble::SIGN_IN_PROMO))
245 return nullptr; 205 return nullptr;
246 206
247 return new BubbleSyncPromoView(this, 207 return new BubbleSyncPromoView(this,
248 IDS_EXTENSION_INSTALLED_SYNC_PROMO_LINK_NEW, 208 IDS_EXTENSION_INSTALLED_SYNC_PROMO_LINK_NEW,
249 IDS_EXTENSION_INSTALLED_SYNC_PROMO_NEW); 209 IDS_EXTENSION_INSTALLED_SYNC_PROMO_NEW);
250 } 210 }
251 211
252 int ExtensionInstalledBubbleView::GetDialogButtons() const { 212 int ExtensionInstalledBubbleView::GetDialogButtons() const {
253 return ui::DIALOG_BUTTON_NONE; 213 return ui::DIALOG_BUTTON_NONE;
254 } 214 }
255 215
256 void ExtensionInstalledBubbleView::OnSignInLinkClicked() { 216 bool ExtensionInstalledBubbleView::ShouldShowCloseButton() const {
257 chrome::ShowBrowserSignin( 217 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 } 218 }
280 219
281 void ExtensionInstalledBubbleView::Init() { 220 void ExtensionInstalledBubbleView::Init() {
221 gfx::Insets insets = margins();
282 UpdateAnchorView(); 222 UpdateAnchorView();
283 223
284 // The Extension Installed bubble takes on various forms, depending on the 224 // The Extension Installed bubble takes on various forms, depending on the
285 // type of extension installed. In general, though, they are all similar: 225 // type of extension installed. In general, though, they are all similar:
286 // 226 //
287 // ------------------------- 227 // -------------------------
288 // | | Heading [X] | 228 // | Icon | Title (x) |
289 // | Icon | Info | 229 // | Info |
290 // | | Extra info | 230 // | Extra info |
291 // ------------------------- 231 // -------------------------
292 // 232 //
293 // Icon and Heading are always shown (as well as the close button). 233 // Icon and Title are always shown (as well as the close button).
294 // Info is shown for browser actions, page actions and Omnibox keyword 234 // Info is shown for browser actions, page actions and Omnibox keyword
295 // extensions and might list keyboard shorcut for the former two types. 235 // extensions and might list keyboard shorcut for the former two types.
296 // Extra info is... 236 // Extra info is...
297 // ... for other types, either a description of how to manage the extension 237 // ... for other types, either a description of how to manage the extension
298 // or a link to configure the keybinding shortcut (if one exists). 238 // or a link to configure the keybinding shortcut (if one exists).
299 // Extra info can include a promo for signing into sync. 239 // Extra info can include a promo for signing into sync.
300 240
301 // The number of rows in the content section of the bubble. 241 // Move explanatory text closer to the title.
302 int main_content_row_count = 1; 242 set_margins(gfx::Insets(0, insets.left(), insets.bottom(), insets.right()));
243
244 std::unique_ptr<views::BoxLayout> layout(
245 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0,
246 views::kRelatedControlVerticalSpacing));
247 // Indent by the size of the icon.
248 layout->set_inside_border_insets(gfx::Insets(
249 0, GetIconSize().width() + views::kUnrelatedControlHorizontalSpacing, 0,
250 0));
251 SetLayoutManager(layout.release());
252
303 if (controller_->options() & ExtensionInstalledBubble::HOW_TO_USE) 253 if (controller_->options() & ExtensionInstalledBubble::HOW_TO_USE)
304 ++main_content_row_count; 254 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 255
370 if (controller_->options() & ExtensionInstalledBubble::SHOW_KEYBINDING) { 256 if (controller_->options() & ExtensionInstalledBubble::SHOW_KEYBINDING) {
371 manage_shortcut_ = new views::Link( 257 manage_shortcut_ = new views::Link(
372 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_SHORTCUTS)); 258 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_SHORTCUTS));
373 manage_shortcut_->set_listener(this); 259 manage_shortcut_->set_listener(this);
374 manage_shortcut_->SetUnderline(false); 260 manage_shortcut_->SetUnderline(false);
375 add_content_view(manage_shortcut_); 261 AddChildView(manage_shortcut_);
376 } 262 }
377 263
378 if (controller_->options() & ExtensionInstalledBubble::HOW_TO_MANAGE) { 264 if (controller_->options() & ExtensionInstalledBubble::HOW_TO_MANAGE) {
379 add_content_view(CreateLabel( 265 AddChildView(CreateLabel(
380 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO), 266 l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO)));
381 font_list));
382 } 267 }
383 } 268 }
384 269
270 void ExtensionInstalledBubbleView::OnSignInLinkClicked() {
271 chrome::ShowBrowserSignin(
272 browser(),
273 signin_metrics::AccessPoint::ACCESS_POINT_EXTENSION_INSTALL_BUBBLE);
274 CloseBubble();
275 }
276
277 void ExtensionInstalledBubbleView::LinkClicked(views::Link* source,
278 int event_flags) {
279 DCHECK_EQ(manage_shortcut_, source);
280
281 std::string configure_url = chrome::kChromeUIExtensionsURL;
282 configure_url += chrome::kExtensionConfigureCommandsSubPage;
283 chrome::NavigateParams params(
284 chrome::GetSingletonTabNavigateParams(browser(), GURL(configure_url)));
285 chrome::Navigate(&params);
286 CloseBubble();
287 }
288
289 gfx::Size ExtensionInstalledBubbleView::GetIconSize() const {
290 const SkBitmap& bitmap = controller_->icon();
291 // Scale down to 43x43, but allow smaller icons (don't scale up).
292 gfx::Size size(bitmap.width(), bitmap.height());
293 return size.width() > kIconSize || size.height() > kIconSize
294 ? gfx::Size(kIconSize, kIconSize)
295 : size;
296 }
297
385 // NB: This bubble is using the temporarily-deprecated bubble manager interface 298 // NB: This bubble is using the temporarily-deprecated bubble manager interface
386 // BubbleUi. Do not copy this pattern. 299 // BubbleUi. Do not copy this pattern.
387 class ExtensionInstalledBubbleUi : public BubbleUi, 300 class ExtensionInstalledBubbleUi : public BubbleUi,
388 public views::WidgetObserver { 301 public views::WidgetObserver {
389 public: 302 public:
390 explicit ExtensionInstalledBubbleUi(ExtensionInstalledBubble* bubble); 303 explicit ExtensionInstalledBubbleUi(ExtensionInstalledBubble* bubble);
391 ~ExtensionInstalledBubbleUi() override; 304 ~ExtensionInstalledBubbleUi() override;
392 305
393 // BubbleUi: 306 // BubbleUi:
394 void Show(BubbleReference bubble_reference) override; 307 void Show(BubbleReference bubble_reference) override;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 ->browser_actions(); 364 ->browser_actions();
452 return !container->animating(); 365 return !container->animating();
453 } 366 }
454 return true; 367 return true;
455 } 368 }
456 369
457 // Implemented here to create the platform specific instance of the BubbleUi. 370 // Implemented here to create the platform specific instance of the BubbleUi.
458 std::unique_ptr<BubbleUi> ExtensionInstalledBubble::BuildBubbleUi() { 371 std::unique_ptr<BubbleUi> ExtensionInstalledBubble::BuildBubbleUi() {
459 return base::WrapUnique(new ExtensionInstalledBubbleUi(this)); 372 return base::WrapUnique(new ExtensionInstalledBubbleUi(this));
460 } 373 }
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