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