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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_
6 #define CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_
8 #include "base/memory/weak_ptr.h"
9 #include "content/public/browser/notification_observer.h"
10 #include "content/public/browser/notification_registrar.h"
11 #include "third_party/skia/include/core/SkBitmap.h"
15 namespace extensions
{
19 // Provides feedback to the user upon successful installation of an
20 // extension. Depending on the type of extension, the Bubble will
22 // OMNIBOX_KEYWORD-> The omnibox.
23 // BROWSER_ACTION -> The browser action icon in the toolbar.
24 // PAGE_ACTION -> A preview of the page action icon in the location
25 // bar which is shown while the Bubble is shown.
26 // GENERIC -> The wrench menu. This case includes page actions that
27 // don't specify a default icon.
29 // ExtensionInstallBubble manages its own lifetime.
30 class ExtensionInstalledBubble
: public content::NotificationObserver
{
32 // The behavior and content of this Bubble comes in these varieties:
40 // Implements the UI for showing the bubble. Owns us.
43 virtual ~Delegate() {}
45 // Attempts to show the bubble. Called from ShowInternal. Returns false
46 // if, because of animating (such as from adding a new browser action
47 // to the toolbar), the bubble could not be shown immediately.
48 virtual bool MaybeShowNow() = 0;
51 ExtensionInstalledBubble(Delegate
* delegate
,
52 const extensions::Extension
* extension
,
54 const SkBitmap
& icon
);
56 virtual ~ExtensionInstalledBubble();
58 const extensions::Extension
* extension() const { return extension_
; }
59 Browser
* browser() { return browser_
; }
60 const SkBitmap
& icon() const { return icon_
; }
61 BubbleType
type() const { return type_
; }
63 // Stop listening to NOTIFICATION_BROWSER_CLOSING.
64 void IgnoreBrowserClosing();
67 // Delegates showing the view to our |view_|. Called internally via PostTask.
70 // content::NotificationObserver:
71 virtual void Observe(int type
,
72 const content::NotificationSource
& source
,
73 const content::NotificationDetails
& details
) OVERRIDE
;
75 // The view delegate that shows the bubble. Owns us.
78 // |extension_| is NULL when we are deleted.
79 const extensions::Extension
* extension_
;
83 content::NotificationRegistrar registrar_
;
85 // The number of times to retry showing the bubble if the browser action
86 // toolbar is animating.
87 int animation_wait_retries_
;
89 base::WeakPtrFactory
<ExtensionInstalledBubble
> weak_factory_
;
91 DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubble
);
94 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_