Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / extensions / extension_installed_bubble.h
blobdddf22837ece8d1d0f5841b7c73069355da75a03
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 "base/scoped_observer.h"
10 #include "content/public/browser/notification_observer.h"
11 #include "content/public/browser/notification_registrar.h"
12 #include "extensions/browser/extension_registry_observer.h"
13 #include "third_party/skia/include/core/SkBitmap.h"
15 class Browser;
17 namespace extensions {
18 class Command;
19 class Extension;
20 class ExtensionRegistry;
23 // Provides feedback to the user upon successful installation of an
24 // extension. Depending on the type of extension, the Bubble will
25 // point to:
26 // OMNIBOX_KEYWORD-> The omnibox.
27 // BROWSER_ACTION -> The browser action icon in the toolbar.
28 // PAGE_ACTION -> A preview of the page action icon in the location
29 // bar which is shown while the Bubble is shown.
30 // GENERIC -> The wrench menu. This case includes page actions that
31 // don't specify a default icon.
33 // ExtensionInstallBubble manages its own lifetime.
34 class ExtensionInstalledBubble : public content::NotificationObserver,
35 public extensions::ExtensionRegistryObserver {
36 public:
37 // The behavior and content of this Bubble comes in these varieties:
38 enum BubbleType {
39 OMNIBOX_KEYWORD,
40 BROWSER_ACTION,
41 PAGE_ACTION,
42 GENERIC
45 // Implements the UI for showing the bubble. Owns us.
46 class Delegate {
47 public:
48 virtual ~Delegate() {}
50 // Attempts to show the bubble. Called from ShowInternal. Returns false
51 // if, because of animating (such as from adding a new browser action
52 // to the toolbar), the bubble could not be shown immediately.
53 virtual bool MaybeShowNow() = 0;
56 ExtensionInstalledBubble(Delegate* delegate,
57 const extensions::Extension* extension,
58 Browser *browser,
59 const SkBitmap& icon);
61 ~ExtensionInstalledBubble() override;
63 const extensions::Extension* extension() const { return extension_; }
64 Browser* browser() { return browser_; }
65 const Browser* browser() const { return browser_; }
66 const SkBitmap& icon() const { return icon_; }
67 BubbleType type() const { return type_; }
68 bool has_command_keybinding() const { return action_command_; }
70 // Stop listening to NOTIFICATION_BROWSER_CLOSING.
71 void IgnoreBrowserClosing();
73 // Returns the string describing how to use the new extension.
74 base::string16 GetHowToUseDescription() const;
76 private:
77 // Delegates showing the view to our |view_|. Called internally via PostTask.
78 void ShowInternal();
80 // content::NotificationObserver:
81 void Observe(int type,
82 const content::NotificationSource& source,
83 const content::NotificationDetails& details) override;
85 // extensions::ExtensionRegistryObserver:
86 void OnExtensionLoaded(content::BrowserContext* browser_context,
87 const extensions::Extension* extension) override;
88 void OnExtensionUnloaded(
89 content::BrowserContext* browser_context,
90 const extensions::Extension* extension,
91 extensions::UnloadedExtensionInfo::Reason reason) override;
93 // The view delegate that shows the bubble. Owns us.
94 Delegate* delegate_;
96 // |extension_| is NULL when we are deleted.
97 const extensions::Extension* extension_;
98 Browser* browser_;
99 const SkBitmap icon_;
100 BubbleType type_;
101 content::NotificationRegistrar registrar_;
103 // The command to execute the extension action, if one exists.
104 scoped_ptr<extensions::Command> action_command_;
106 // Listen to extension load, unloaded notifications.
107 ScopedObserver<extensions::ExtensionRegistry,
108 extensions::ExtensionRegistryObserver>
109 extension_registry_observer_;
111 // The number of times to retry showing the bubble if the browser action
112 // toolbar is animating.
113 int animation_wait_retries_;
115 base::WeakPtrFactory<ExtensionInstalledBubble> weak_factory_;
117 DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubble);
120 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_