| OLD | NEW |
| 1 // Copyright (c) 2010 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_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/browser/tab_contents/infobar_delegate.h" | 9 #include "chrome/browser/tab_contents/infobar_delegate.h" |
| 10 | 10 |
| 11 class Browser; | 11 class Browser; |
| 12 class Extension; | 12 class Extension; |
| 13 class ExtensionHost; | 13 class ExtensionHost; |
| 14 class TabContents; | 14 class TabContents; |
| 15 | 15 |
| 16 // The InfobarDelegate for creating and managing state for the ExtensionInfobar | 16 // The InfobarDelegate for creating and managing state for the ExtensionInfobar |
| 17 // plus monitor when the extension goes away. | 17 // plus monitor when the extension goes away. |
| 18 class ExtensionInfoBarDelegate : public InfoBarDelegate, | 18 class ExtensionInfoBarDelegate : public InfoBarDelegate, |
| 19 public NotificationObserver { | 19 public NotificationObserver { |
| 20 public: | 20 public: |
| 21 // The observer for when the delegate dies. | 21 // The observer for when the delegate dies. |
| 22 class DelegateObserver { | 22 class DelegateObserver { |
| 23 public: | 23 public: |
| 24 virtual void OnDelegateDeleted() = 0; | 24 virtual void OnDelegateDeleted() = 0; |
| 25 | 25 |
| 26 protected: | 26 protected: |
| 27 virtual ~DelegateObserver() {} | 27 virtual ~DelegateObserver() {} |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 ExtensionInfoBarDelegate(Browser* browser, TabContents* contents, | 30 ExtensionInfoBarDelegate(Browser* browser, |
| 31 const Extension* extension, const GURL& url); | 31 TabContents* contents, |
| 32 ~ExtensionInfoBarDelegate(); | 32 const Extension* extension, |
| 33 | 33 const GURL& url); |
| 34 const Extension* extension() { return extension_; } | 34 const Extension* extension() { return extension_; } |
| 35 ExtensionHost* extension_host() { return extension_host_.get(); } | 35 ExtensionHost* extension_host() { return extension_host_.get(); } |
| 36 | 36 |
| 37 void set_observer(DelegateObserver* observer) { observer_ = observer; } | 37 void set_observer(DelegateObserver* observer) { observer_ = observer; } |
| 38 | 38 |
| 39 // Overridden from InfoBarDelegate: | 39 bool closing() { return closing_; } |
| 40 |
| 41 private: |
| 42 virtual ~ExtensionInfoBarDelegate(); |
| 43 |
| 44 // InfoBarDelegate: |
| 45 virtual InfoBar* CreateInfoBar(); |
| 46 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; |
| 40 virtual void InfoBarDismissed(); | 47 virtual void InfoBarDismissed(); |
| 41 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; | |
| 42 virtual void InfoBarClosed(); | 48 virtual void InfoBarClosed(); |
| 43 virtual InfoBar* CreateInfoBar(); | 49 virtual Type GetInfoBarType() const; |
| 44 virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate(); | 50 virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate(); |
| 45 virtual Type GetInfoBarType(); | |
| 46 | 51 |
| 47 // Overridden from NotificationObserver: | 52 // NotificationObserver: |
| 48 virtual void Observe(NotificationType type, | 53 virtual void Observe(NotificationType type, |
| 49 const NotificationSource& source, | 54 const NotificationSource& source, |
| 50 const NotificationDetails& details); | 55 const NotificationDetails& details); |
| 51 | 56 |
| 52 bool closing() { return closing_; } | |
| 53 private: | |
| 54 // The extension host we are showing the InfoBar for. The delegate needs to | 57 // The extension host we are showing the InfoBar for. The delegate needs to |
| 55 // own this since the InfoBar gets deleted and recreated when you switch tabs | 58 // own this since the InfoBar gets deleted and recreated when you switch tabs |
| 56 // and come back (and we don't want the user's interaction with the InfoBar to | 59 // and come back (and we don't want the user's interaction with the InfoBar to |
| 57 // get lost at that point). | 60 // get lost at that point). |
| 58 scoped_ptr<ExtensionHost> extension_host_; | 61 scoped_ptr<ExtensionHost> extension_host_; |
| 59 | 62 |
| 60 // The observer monitoring when the delegate dies. | 63 // The observer monitoring when the delegate dies. |
| 61 DelegateObserver* observer_; | 64 DelegateObserver* observer_; |
| 62 | 65 |
| 63 const Extension* extension_; | 66 const Extension* extension_; |
| 64 | |
| 65 TabContents* tab_contents_; | 67 TabContents* tab_contents_; |
| 66 | |
| 67 NotificationRegistrar registrar_; | 68 NotificationRegistrar registrar_; |
| 68 | 69 |
| 69 // Whether we are currently animating to close. This is used to ignore | 70 // Whether we are currently animating to close. This is used to ignore |
| 70 // ExtensionView::PreferredSizeChanged notifications. | 71 // ExtensionView::PreferredSizeChanged notifications. |
| 71 bool closing_; | 72 bool closing_; |
| 72 | 73 |
| 73 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBarDelegate); | 74 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBarDelegate); |
| 74 }; | 75 }; |
| 75 | 76 |
| 76 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_ | 77 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_ |
| OLD | NEW |