OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_GTK_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_GTK_H_ |
6 #define CHROME_BROWSER_UI_GTK_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_GTK_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "chrome/browser/ui/extensions/extension_installed_bubble.h" |
11 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" | 11 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" |
12 #include "chrome/browser/ui/gtk/custom_button.h" | 12 #include "chrome/browser/ui/gtk/custom_button.h" |
13 #include "content/public/browser/notification_observer.h" | |
14 #include "content/public/browser/notification_registrar.h" | |
15 #include "third_party/skia/include/core/SkBitmap.h" | |
16 | 13 |
17 class Browser; | 14 class Browser; |
18 class SkBitmap; | 15 class SkBitmap; |
19 | 16 |
20 namespace extensions { | 17 namespace extensions { |
21 class Extension; | 18 class Extension; |
22 } | 19 } |
23 | 20 |
24 // Provides feedback to the user upon successful installation of an | 21 // Provides feedback to the user upon successful installation of an |
25 // extension. Depending on the type of extension, the BubbleGtk will | 22 // extension. Depending on the type of extension, the BubbleGtk will |
26 // point to: | 23 // point to: |
27 // OMNIBOX_KEYWORD-> The omnibox. | 24 // OMNIBOX_KEYWORD-> The omnibox. |
28 // BROWSER_ACTION -> The browserAction icon in the toolbar. | 25 // BROWSER_ACTION -> The browserAction icon in the toolbar. |
29 // PAGE_ACTION -> A preview of the page action icon in the location | 26 // PAGE_ACTION -> A preview of the page action icon in the location |
30 // bar which is shown while the BubbleGtk is shown. | 27 // bar which is shown while the BubbleGtk is shown. |
31 // GENERIC -> The wrench menu. This case includes page actions that | 28 // GENERIC -> The wrench menu. This case includes page actions that |
32 // don't specify a default icon. | 29 // don't specify a default icon. |
33 // | 30 // |
34 // ExtensionInstallBubble manages its own lifetime. | 31 // ExtensionInstallBubble manages its own lifetime. |
35 class ExtensionInstalledBubbleGtk | 32 class ExtensionInstalledBubbleGtk |
36 : public BubbleDelegateGtk, | 33 : public ExtensionInstalledBubble::View, |
37 public content::NotificationObserver { | 34 public BubbleDelegateGtk { |
38 public: | 35 public: |
39 virtual ~ExtensionInstalledBubbleGtk(); | 36 virtual ~ExtensionInstalledBubbleGtk(); |
40 | 37 |
41 // The behavior and content of this BubbleGtk comes in three varieties. | |
42 enum BubbleType { | |
43 OMNIBOX_KEYWORD, | |
44 BROWSER_ACTION, | |
45 PAGE_ACTION, | |
46 GENERIC | |
47 }; | |
48 | |
49 // Creates the ExtensionInstalledBubble and schedules it to be shown once | 38 // Creates the ExtensionInstalledBubble and schedules it to be shown once |
50 // the extension has loaded. |extension| is the installed extension. |browser| | 39 // the extension has loaded. |extension| is the installed extension. |browser| |
51 // is the browser window which will host the bubble. |icon| is the install | 40 // is the browser window which will host the bubble. |icon| is the install |
52 // icon of the extension. | 41 // icon of the extension. |
53 static void Show(const extensions::Extension* extension, | 42 static void Show(const extensions::Extension* extension, |
54 Browser *browser, | 43 Browser* browser, |
55 const SkBitmap& icon); | 44 const SkBitmap& icon); |
56 | 45 |
57 private: | 46 private: |
58 // Private ctor. Registers a listener for EXTENSION_LOADED. | |
59 ExtensionInstalledBubbleGtk(const extensions::Extension* extension, | 47 ExtensionInstalledBubbleGtk(const extensions::Extension* extension, |
60 Browser *browser, | 48 Browser* browser, |
61 const SkBitmap& icon); | 49 const SkBitmap& icon); |
62 | 50 |
63 // Notified when the bubble gets destroyed so we can delete our instance. | 51 // Notified when the bubble gets destroyed so we can delete our instance. |
64 CHROMEGTK_CALLBACK_0(ExtensionInstalledBubbleGtk, void, OnDestroy); | 52 CHROMEGTK_CALLBACK_0(ExtensionInstalledBubbleGtk, void, OnDestroy); |
65 | 53 |
66 // Shows the bubble. Called internally via PostTask. | 54 // ExtensionInstalledBubble::View: |
67 void ShowInternal(); | 55 virtual void ShowInternal() OVERRIDE; |
68 | 56 virtual void OnBrowserClosing() OVERRIDE; |
69 // content::NotificationObserver: | |
70 virtual void Observe(int type, | |
71 const content::NotificationSource& source, | |
72 const content::NotificationDetails& details) OVERRIDE; | |
73 | 57 |
74 // BubbleDelegateGtk: | 58 // BubbleDelegateGtk: |
75 virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE; | 59 virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE; |
76 | 60 |
77 static void OnButtonClick(GtkWidget* button, | 61 static void OnButtonClick(GtkWidget* button, |
78 ExtensionInstalledBubbleGtk* toolbar); | 62 ExtensionInstalledBubbleGtk* toolbar); |
79 | 63 |
80 // Link button callbacks. | 64 // Link button callbacks. |
81 CHROMEGTK_CALLBACK_0(ExtensionInstalledBubbleGtk, void, OnLinkClicked); | 65 CHROMEGTK_CALLBACK_0(ExtensionInstalledBubbleGtk, void, OnLinkClicked); |
82 | 66 |
83 const extensions::Extension* extension_; | |
84 Browser* browser_; | |
85 SkBitmap icon_; | |
86 content::NotificationRegistrar registrar_; | |
87 BubbleType type_; | |
88 | |
89 // The number of times to retry showing the bubble if the browser action | |
90 // toolbar is animating. | |
91 int animation_wait_retries_; | |
92 | |
93 // The 'x' that the user can press to hide the bubble shelf. | 67 // The 'x' that the user can press to hide the bubble shelf. |
94 scoped_ptr<CustomDrawButton> close_button_; | 68 scoped_ptr<CustomDrawButton> close_button_; |
95 | 69 |
96 BubbleGtk* bubble_; | 70 ExtensionInstalledBubble bubble_; |
97 | 71 BubbleGtk* gtk_bubble_; |
98 base::WeakPtrFactory<ExtensionInstalledBubbleGtk> weak_factory_; | |
99 | 72 |
100 DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubbleGtk); | 73 DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubbleGtk); |
101 }; | 74 }; |
102 | 75 |
103 #endif // CHROME_BROWSER_UI_GTK_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_GTK_H_ | 76 #endif // CHROME_BROWSER_UI_GTK_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_GTK_H_ |
OLD | NEW |