| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_ | 5 #ifndef CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_ |
| 6 #define CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_ | 6 #define CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/scoped_observer.h" |
| 9 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
| 10 #include "content/public/browser/notification_registrar.h" | 11 #include "content/public/browser/notification_registrar.h" |
| 12 #include "extensions/browser/extension_registry_observer.h" |
| 11 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
| 12 | 14 |
| 13 class Browser; | 15 class Browser; |
| 14 | 16 |
| 15 namespace extensions { | 17 namespace extensions { |
| 16 class Extension; | 18 class Extension; |
| 19 class ExtensionRegistry; |
| 17 } | 20 } |
| 18 | 21 |
| 19 // Provides feedback to the user upon successful installation of an | 22 // Provides feedback to the user upon successful installation of an |
| 20 // extension. Depending on the type of extension, the Bubble will | 23 // extension. Depending on the type of extension, the Bubble will |
| 21 // point to: | 24 // point to: |
| 22 // OMNIBOX_KEYWORD-> The omnibox. | 25 // OMNIBOX_KEYWORD-> The omnibox. |
| 23 // BROWSER_ACTION -> The browser action icon in the toolbar. | 26 // BROWSER_ACTION -> The browser action icon in the toolbar. |
| 24 // PAGE_ACTION -> A preview of the page action icon in the location | 27 // PAGE_ACTION -> A preview of the page action icon in the location |
| 25 // bar which is shown while the Bubble is shown. | 28 // bar which is shown while the Bubble is shown. |
| 26 // GENERIC -> The wrench menu. This case includes page actions that | 29 // GENERIC -> The wrench menu. This case includes page actions that |
| 27 // don't specify a default icon. | 30 // don't specify a default icon. |
| 28 // | 31 // |
| 29 // ExtensionInstallBubble manages its own lifetime. | 32 // ExtensionInstallBubble manages its own lifetime. |
| 30 class ExtensionInstalledBubble : public content::NotificationObserver { | 33 class ExtensionInstalledBubble : public content::NotificationObserver, |
| 34 public extensions::ExtensionRegistryObserver { |
| 31 public: | 35 public: |
| 32 // The behavior and content of this Bubble comes in these varieties: | 36 // The behavior and content of this Bubble comes in these varieties: |
| 33 enum BubbleType { | 37 enum BubbleType { |
| 34 OMNIBOX_KEYWORD, | 38 OMNIBOX_KEYWORD, |
| 35 BROWSER_ACTION, | 39 BROWSER_ACTION, |
| 36 PAGE_ACTION, | 40 PAGE_ACTION, |
| 37 GENERIC | 41 GENERIC |
| 38 }; | 42 }; |
| 39 | 43 |
| 40 // Implements the UI for showing the bubble. Owns us. | 44 // Implements the UI for showing the bubble. Owns us. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 65 | 69 |
| 66 private: | 70 private: |
| 67 // Delegates showing the view to our |view_|. Called internally via PostTask. | 71 // Delegates showing the view to our |view_|. Called internally via PostTask. |
| 68 void ShowInternal(); | 72 void ShowInternal(); |
| 69 | 73 |
| 70 // content::NotificationObserver: | 74 // content::NotificationObserver: |
| 71 virtual void Observe(int type, | 75 virtual void Observe(int type, |
| 72 const content::NotificationSource& source, | 76 const content::NotificationSource& source, |
| 73 const content::NotificationDetails& details) OVERRIDE; | 77 const content::NotificationDetails& details) OVERRIDE; |
| 74 | 78 |
| 79 // extensions::ExtensionRegistryObserver: |
| 80 virtual void OnExtensionLoaded( |
| 81 content::BrowserContext* browser_context, |
| 82 const extensions::Extension* extension) OVERRIDE; |
| 83 virtual void OnExtensionUnloaded( |
| 84 content::BrowserContext* browser_context, |
| 85 const extensions::Extension* extension, |
| 86 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; |
| 87 |
| 75 // The view delegate that shows the bubble. Owns us. | 88 // The view delegate that shows the bubble. Owns us. |
| 76 Delegate* delegate_; | 89 Delegate* delegate_; |
| 77 | 90 |
| 78 // |extension_| is NULL when we are deleted. | 91 // |extension_| is NULL when we are deleted. |
| 79 const extensions::Extension* extension_; | 92 const extensions::Extension* extension_; |
| 80 Browser* browser_; | 93 Browser* browser_; |
| 81 const SkBitmap icon_; | 94 const SkBitmap icon_; |
| 82 BubbleType type_; | 95 BubbleType type_; |
| 83 content::NotificationRegistrar registrar_; | 96 content::NotificationRegistrar registrar_; |
| 84 | 97 |
| 98 // Listen to extension load, unloaded notifications. |
| 99 ScopedObserver<extensions::ExtensionRegistry, |
| 100 extensions::ExtensionRegistryObserver> |
| 101 extension_registry_observer_; |
| 102 |
| 85 // The number of times to retry showing the bubble if the browser action | 103 // The number of times to retry showing the bubble if the browser action |
| 86 // toolbar is animating. | 104 // toolbar is animating. |
| 87 int animation_wait_retries_; | 105 int animation_wait_retries_; |
| 88 | 106 |
| 89 base::WeakPtrFactory<ExtensionInstalledBubble> weak_factory_; | 107 base::WeakPtrFactory<ExtensionInstalledBubble> weak_factory_; |
| 90 | 108 |
| 91 DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubble); | 109 DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubble); |
| 92 }; | 110 }; |
| 93 | 111 |
| 94 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_ | 112 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_ |
| OLD | NEW |