Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_ | |
| 6 #define CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_ | |
| 7 | |
| 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" | |
| 12 | |
| 13 class Browser; | |
| 14 | |
| 15 namespace extensions { | |
| 16 class Extension; | |
| 17 } | |
| 18 | |
| 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. | |
| 28 // | |
| 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 | |
| 38 }; | |
| 39 | |
| 40 // Implements the UI for showing the bubble. Owns us. | |
| 41 class View { | |
|
tfarina
2013/08/29 22:19:54
why this is an inner class? can you move it into i
Yoyo Zhou
2013/09/03 19:34:36
There's no benefit, since everyone who implements
tfarina
2013/09/03 19:49:13
they need because they are referring to BubbleType
Yoyo Zhou
2013/09/03 22:15:55
As per the other comment, if I declare an Extensio
| |
| 42 public: | |
|
tfarina
2013/09/03 19:49:13
virtual destructor?
Yoyo Zhou
2013/09/03 22:15:55
Done.
| |
| 43 // Shows the bubble. Called internally via PostTask. | |
| 44 virtual void ShowInternal() = 0; | |
| 45 | |
| 46 // Informs the view that our browser is closing, so it should | |
| 47 // delete itself. | |
| 48 virtual void OnBrowserClosing() = 0; | |
| 49 }; | |
| 50 | |
| 51 ExtensionInstalledBubble(View* view, | |
| 52 const extensions::Extension* extension, | |
| 53 Browser *browser, | |
| 54 const SkBitmap& icon); | |
| 55 | |
| 56 virtual ~ExtensionInstalledBubble(); | |
| 57 | |
| 58 const extensions::Extension* extension() { return extension_; } | |
| 59 Browser* browser() { return browser_; } | |
| 60 const SkBitmap& icon() { return icon_; } | |
| 61 BubbleType type() { return type_; } | |
| 62 content::NotificationRegistrar* registrar() { return ®istrar_; } | |
| 63 | |
| 64 // When showing the bubble for a new browser action, we may have to wait for | |
| 65 // the toolbar to finish animating to know where the item's final position | |
| 66 // will be. | |
| 67 void MaybeShowLater(); | |
| 68 | |
| 69 // Stop listening to NOTIFICATION_BROWSER_CLOSING. | |
| 70 void IgnoreBrowserClosing(); | |
| 71 | |
| 72 private: | |
| 73 // Delegates showing the view to our |view_|. | |
| 74 void ShowInternal(); | |
| 75 | |
| 76 // content::NotificationObserver: | |
| 77 virtual void Observe(int type, | |
| 78 const content::NotificationSource& source, | |
| 79 const content::NotificationDetails& details) OVERRIDE; | |
| 80 | |
| 81 // The view delegate that shows the bubble. Owns us. | |
| 82 View* view_; | |
| 83 | |
| 84 const extensions::Extension* extension_; | |
| 85 Browser* browser_; | |
| 86 const SkBitmap icon_; | |
| 87 BubbleType type_; | |
| 88 content::NotificationRegistrar registrar_; | |
| 89 | |
| 90 // The number of times to retry showing the bubble if the browser action | |
| 91 // toolbar is animating. | |
| 92 int animation_wait_retries_; | |
| 93 | |
| 94 base::WeakPtrFactory<ExtensionInstalledBubble> weak_factory_; | |
| 95 | |
| 96 DISALLOW_COPY_AND_ASSIGN(ExtensionInstalledBubble); | |
| 97 }; | |
| 98 | |
| 99 #endif // CHROME_BROWSER_UI_EXTENSIONS_EXTENSION_INSTALLED_BUBBLE_H_ | |
| OLD | NEW |