OLD | NEW |
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 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_VIEW_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "chrome/browser/ui/extensions/extension_installed_bubble.h" | 9 #include "chrome/browser/ui/extensions/extension_installed_bubble.h" |
| 10 #include "chrome/browser/ui/sync/bubble_sync_promo_delegate.h" |
10 #include "components/bubble/bubble_reference.h" | 11 #include "components/bubble/bubble_reference.h" |
11 #include "ui/views/bubble/bubble_delegate.h" | 12 #include "ui/views/bubble/bubble_delegate.h" |
| 13 #include "ui/views/controls/button/button.h" |
| 14 #include "ui/views/controls/link_listener.h" |
12 | 15 |
13 class Browser; | 16 class Browser; |
| 17 class BubbleSyncPromoView; |
14 | 18 |
15 namespace extensions { | 19 namespace extensions { |
16 class Extension; | 20 class Extension; |
17 } | 21 } |
18 | 22 |
| 23 namespace views { |
| 24 class LabelButton; |
| 25 class Link; |
| 26 } |
| 27 |
19 // Provides feedback to the user upon successful installation of an | 28 // Provides feedback to the user upon successful installation of an |
20 // extension. Depending on the type of extension, the Bubble will | 29 // extension. Depending on the type of extension, the Bubble will |
21 // point to: | 30 // point to: |
22 // OMNIBOX_KEYWORD-> The omnibox. | 31 // OMNIBOX_KEYWORD-> The omnibox. |
23 // BROWSER_ACTION -> The browserAction icon in the toolbar. | 32 // BROWSER_ACTION -> The browserAction icon in the toolbar. |
24 // PAGE_ACTION -> A preview of the pageAction icon in the location | 33 // PAGE_ACTION -> A preview of the pageAction icon in the location |
25 // bar which is shown while the Bubble is shown. | 34 // bar which is shown while the Bubble is shown. |
26 // GENERIC -> The app menu. This case includes pageActions that don't | 35 // GENERIC -> The app menu. This case includes pageActions that don't |
27 // specify a default icon. | 36 // specify a default icon. |
28 class ExtensionInstalledBubbleView : public views::BubbleDelegateView { | 37 class ExtensionInstalledBubbleView : public BubbleSyncPromoDelegate, |
| 38 public views::BubbleDelegateView, |
| 39 public views::ButtonListener, |
| 40 public views::LinkListener { |
29 public: | 41 public: |
30 ExtensionInstalledBubbleView(ExtensionInstalledBubble* bubble, | 42 ExtensionInstalledBubbleView(ExtensionInstalledBubble* bubble, |
31 BubbleReference bubble_reference); | 43 BubbleReference bubble_reference); |
32 ~ExtensionInstalledBubbleView() override; | 44 ~ExtensionInstalledBubbleView() override; |
33 | 45 |
34 // Recalculate the anchor position for this bubble. | 46 // Recalculate the anchor position for this bubble. |
35 void UpdateAnchorView(); | 47 void UpdateAnchorView(); |
36 | 48 |
| 49 void InitLayout(const ExtensionInstalledBubble& bubble); |
| 50 |
| 51 private: |
| 52 // The different options to show in the installed bubble. |
| 53 enum Options { |
| 54 NONE = 0, |
| 55 HOW_TO_USE = 1 << 0, |
| 56 HOW_TO_MANAGE = 1 << 1, |
| 57 SHOW_KEYBINDING = 1 << 2, |
| 58 SIGN_IN_PROMO = 1 << 3, |
| 59 }; |
| 60 |
37 // views::BubbleDelegateView: | 61 // views::BubbleDelegateView: |
38 void WindowClosing() override; | 62 void WindowClosing() override; |
39 gfx::Rect GetAnchorRect() const override; | 63 gfx::Rect GetAnchorRect() const override; |
40 void OnWidgetClosing(views::Widget* widget) override; | 64 void OnWidgetClosing(views::Widget* widget) override; |
41 void OnWidgetActivationChanged(views::Widget* widget, bool active) override; | 65 void OnWidgetActivationChanged(views::Widget* widget, bool active) override; |
42 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 66 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
43 | 67 |
44 private: | 68 // BubbleSyncPromoDelegate: |
| 69 void OnSignInLinkClicked() override; |
| 70 |
| 71 // views::LinkListener: |
| 72 void LinkClicked(views::Link* source, int event_flags) override; |
| 73 |
| 74 // views::ButtonListener: |
| 75 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 76 |
45 BubbleReference bubble_reference_; | 77 BubbleReference bubble_reference_; |
46 const extensions::Extension* extension_; | 78 const extensions::Extension* extension_; |
47 Browser* browser_; | 79 Browser* browser_; |
48 ExtensionInstalledBubble::BubbleType type_; | 80 ExtensionInstalledBubble::BubbleType type_; |
49 | 81 |
| 82 // A bitmask containing the various options of bubble sections to show. |
| 83 int options_; |
| 84 |
| 85 // The sync promo section of the bubble. |
| 86 BubbleSyncPromoView* sync_promo_; |
| 87 |
| 88 // The button to close the bubble. |
| 89 views::LabelButton* close_; |
| 90 |
| 91 // The shortcut to open the manage shortcuts page. |
| 92 views::Link* manage_shortcut_; |
| 93 |
50 DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubbleView); | 94 DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubbleView); |
51 }; | 95 }; |
52 | 96 |
53 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_VIEW_H_ | 97 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_VIEW_H_ |
OLD | NEW |