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