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_VIEWS_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "chrome/browser/ui/views/bubble/bubble.h" |
10 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
11 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
12 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
13 #include "ui/views/bubble/bubble_delegate.h" | |
14 | 14 |
15 class Browser; | 15 class Browser; |
16 class Extension; | 16 class Extension; |
| 17 class InstalledBubbleContent; |
| 18 class SkBitmap; |
17 | 19 |
18 // Provides feedback to the user upon successful installation of an | 20 // Provides feedback to the user upon successful installation of an |
19 // extension. Depending on the type of extension, the Bubble will | 21 // extension. Depending on the type of extension, the Bubble will |
20 // point to: | 22 // point to: |
21 // OMNIBOX_KEYWORD-> The omnibox. | 23 // OMNIBOX_KEYWORD-> The omnibox. |
22 // BROWSER_ACTION -> The browserAction icon in the toolbar. | 24 // BROWSER_ACTION -> The browserAction icon in the toolbar. |
23 // PAGE_ACTION -> A preview of the pageAction icon in the location | 25 // PAGE_ACTION -> A preview of the pageAction icon in the location |
24 // bar which is shown while the Bubble is shown. | 26 // bar which is shown while the Bubble is shown. |
25 // APP -> The plus button in the tabstrip (for the New Tab Page). | 27 // APP -> The plus button in the tabstrip (for the New Tab Page). |
26 // GENERIC -> The wrench menu. This case includes pageActions that | 28 // GENERIC -> The wrench menu. This case includes pageActions that |
27 // don't specify a default icon. | 29 // don't specify a default icon. |
28 // | 30 // |
29 // ExtensionInstallBubble manages its own lifetime. | 31 // ExtensionInstallBubble manages its own lifetime. |
30 class ExtensionInstalledBubble | 32 class ExtensionInstalledBubble |
31 : public views::BubbleDelegateView, | 33 : public BubbleDelegate, |
32 public content::NotificationObserver, | 34 public content::NotificationObserver, |
33 public base::RefCountedThreadSafe<ExtensionInstalledBubble> { | 35 public base::RefCountedThreadSafe<ExtensionInstalledBubble> { |
34 public: | 36 public: |
35 // The behavior and content of this Bubble comes in these varieties: | 37 // The behavior and content of this Bubble comes in these varieties: |
36 enum BubbleType { | 38 enum BubbleType { |
37 OMNIBOX_KEYWORD, | 39 OMNIBOX_KEYWORD, |
38 BROWSER_ACTION, | 40 BROWSER_ACTION, |
39 PAGE_ACTION, | 41 PAGE_ACTION, |
40 APP, | 42 APP, |
41 GENERIC | 43 GENERIC |
42 }; | 44 }; |
43 | 45 |
44 // Creates the ExtensionInstalledBubble and schedules it to be shown once | 46 // Creates the ExtensionInstalledBubble and schedules it to be shown once |
45 // the extension has loaded. |extension| is the installed extension. |browser| | 47 // the extension has loaded. |extension| is the installed extension. |browser| |
46 // is the browser window which will host the bubble. |icon| is the install | 48 // is the browser window which will host the bubble. |icon| is the install |
47 // icon of the extension. | 49 // icon of the extension. |
48 static void Show( | 50 static void Show( |
49 const Extension* extension, Browser *browser, const SkBitmap& icon); | 51 const Extension* extension, Browser *browser, const SkBitmap& icon); |
50 | 52 |
51 private: | 53 private: |
52 friend class base::RefCountedThreadSafe<ExtensionInstalledBubble>; | 54 friend class base::RefCountedThreadSafe<ExtensionInstalledBubble>; |
53 | 55 |
54 // Private ctor. Registers a listener for EXTENSION_LOADED. | 56 // Private ctor. Registers a listener for EXTENSION_LOADED. |
55 ExtensionInstalledBubble(const Extension* extension, | 57 ExtensionInstalledBubble( |
56 Browser *browser, | 58 const Extension* extension, Browser *browser, const SkBitmap& icon); |
57 const SkBitmap& icon); | |
58 | 59 |
59 virtual ~ExtensionInstalledBubble(); | 60 virtual ~ExtensionInstalledBubble(); |
60 | 61 |
61 // Shows the bubble. Called internally via PostTask. | 62 // Shows the bubble. Called internally via PostTask. |
62 void ShowInternal(); | 63 void ShowInternal(); |
63 | 64 |
64 // content::NotificationObserver | 65 // content::NotificationObserver |
65 virtual void Observe(int type, | 66 virtual void Observe(int type, |
66 const content::NotificationSource& source, | 67 const content::NotificationSource& source, |
67 const content::NotificationDetails& details) OVERRIDE; | 68 const content::NotificationDetails& details) OVERRIDE; |
68 | 69 |
69 // views::WidgetDelegate | 70 // BubbleDelegate |
70 virtual void WindowClosing() OVERRIDE; | 71 virtual void BubbleClosing(Bubble* bubble, bool closed_by_escape) OVERRIDE; |
71 | 72 virtual bool CloseOnEscape() OVERRIDE; |
72 // views::BubbleDelegate | 73 virtual bool FadeInOnShow() OVERRIDE; |
73 virtual gfx::Point GetAnchorPoint() OVERRIDE; | |
74 virtual views::BubbleBorder::ArrowLocation GetArrowLocation() const OVERRIDE; | |
75 | 74 |
76 const Extension* extension_; | 75 const Extension* extension_; |
77 Browser* browser_; | 76 Browser* browser_; |
78 SkBitmap icon_; | 77 SkBitmap icon_; |
79 content::NotificationRegistrar registrar_; | 78 content::NotificationRegistrar registrar_; |
| 79 InstalledBubbleContent* bubble_content_; |
80 BubbleType type_; | 80 BubbleType type_; |
81 | 81 |
82 // How many times we've deferred due to animations being in progress. | 82 // How many times we've deferred due to animations being in progress. |
83 int animation_wait_retries_; | 83 int animation_wait_retries_; |
84 | 84 |
85 DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubble); | 85 DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubble); |
86 }; | 86 }; |
87 | 87 |
88 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_ | 88 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_ |
OLD | NEW |