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