Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / extensions / extension_installed_bubble.h
blob0ead95b108a35d4a74fb36f2d5a2f034c7486578
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"
13 class Browser;
15 namespace extensions {
16 class Extension;
19 // Provides feedback to the user upon successful installation of an
20 // extension. Depending on the type of extension, the Bubble will
21 // point to:
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 {
31 public:
32 // The behavior and content of this Bubble comes in these varieties:
33 enum BubbleType {
34 OMNIBOX_KEYWORD,
35 BROWSER_ACTION,
36 PAGE_ACTION,
37 GENERIC
40 // Implements the UI for showing the bubble. Owns us.
41 class Delegate {
42 public:
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,
53 Browser *browser,
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();
66 private:
67 // Delegates showing the view to our |view_|. Called internally via PostTask.
68 void ShowInternal();
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.
76 Delegate* delegate_;
78 // |extension_| is NULL when we are deleted.
79 const extensions::Extension* extension_;
80 Browser* browser_;
81 const SkBitmap icon_;
82 BubbleType type_;
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_