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_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 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 9 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
10 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
11 #include "content/public/browser/notification_registrar.h" | 11 #include "content/public/browser/notification_registrar.h" |
12 | 12 |
13 class Browser; | 13 class Browser; |
14 class ExtensionHost; | |
15 class GURL; | 14 class GURL; |
16 | 15 |
17 namespace extensions { | 16 namespace extensions { |
18 class Extension; | 17 class Extension; |
| 18 class ExtensionHost; |
19 } | 19 } |
20 | 20 |
21 // The InfobarDelegate for creating and managing state for the ExtensionInfobar | 21 // The InfobarDelegate for creating and managing state for the ExtensionInfobar |
22 // plus monitor when the extension goes away. | 22 // plus monitor when the extension goes away. |
23 class ExtensionInfoBarDelegate : public InfoBarDelegate, | 23 class ExtensionInfoBarDelegate : public InfoBarDelegate, |
24 public content::NotificationObserver { | 24 public content::NotificationObserver { |
25 public: | 25 public: |
26 // The observer for when the delegate dies. | 26 // The observer for when the delegate dies. |
27 class DelegateObserver { | 27 class DelegateObserver { |
28 public: | 28 public: |
29 virtual void OnDelegateDeleted() = 0; | 29 virtual void OnDelegateDeleted() = 0; |
30 | 30 |
31 protected: | 31 protected: |
32 virtual ~DelegateObserver() {} | 32 virtual ~DelegateObserver() {} |
33 }; | 33 }; |
34 | 34 |
35 ExtensionInfoBarDelegate(Browser* browser, | 35 ExtensionInfoBarDelegate(Browser* browser, |
36 InfoBarTabHelper* infobar_helper, | 36 InfoBarTabHelper* infobar_helper, |
37 const extensions::Extension* extension, | 37 const extensions::Extension* extension, |
38 const GURL& url, | 38 const GURL& url, |
39 int height); | 39 int height); |
40 | 40 |
41 const extensions::Extension* extension() { return extension_; } | 41 const extensions::Extension* extension() { return extension_; } |
42 ExtensionHost* extension_host() { return extension_host_.get(); } | 42 extensions::ExtensionHost* extension_host() { return extension_host_.get(); } |
43 int height() { return height_; } | 43 int height() { return height_; } |
44 | 44 |
45 void set_observer(DelegateObserver* observer) { observer_ = observer; } | 45 void set_observer(DelegateObserver* observer) { observer_ = observer; } |
46 | 46 |
47 bool closing() const { return closing_; } | 47 bool closing() const { return closing_; } |
48 | 48 |
49 private: | 49 private: |
50 virtual ~ExtensionInfoBarDelegate(); | 50 virtual ~ExtensionInfoBarDelegate(); |
51 | 51 |
52 // InfoBarDelegate: | 52 // InfoBarDelegate: |
53 virtual InfoBar* CreateInfoBar(InfoBarTabHelper* owner) OVERRIDE; | 53 virtual InfoBar* CreateInfoBar(InfoBarTabHelper* owner) OVERRIDE; |
54 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const OVERRIDE; | 54 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const OVERRIDE; |
55 virtual void InfoBarDismissed() OVERRIDE; | 55 virtual void InfoBarDismissed() OVERRIDE; |
56 virtual Type GetInfoBarType() const OVERRIDE; | 56 virtual Type GetInfoBarType() const OVERRIDE; |
57 virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate() OVERRIDE; | 57 virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate() OVERRIDE; |
58 | 58 |
59 // content::NotificationObserver: | 59 // content::NotificationObserver: |
60 virtual void Observe(int type, | 60 virtual void Observe(int type, |
61 const content::NotificationSource& source, | 61 const content::NotificationSource& source, |
62 const content::NotificationDetails& details) OVERRIDE; | 62 const content::NotificationDetails& details) OVERRIDE; |
63 | 63 |
64 Browser* browser_; | 64 Browser* browser_; |
65 | 65 |
66 // The extension host we are showing the InfoBar for. The delegate needs to | 66 // The extension host we are showing the InfoBar for. The delegate needs to |
67 // own this since the InfoBar gets deleted and recreated when you switch tabs | 67 // own this since the InfoBar gets deleted and recreated when you switch tabs |
68 // and come back (and we don't want the user's interaction with the InfoBar to | 68 // and come back (and we don't want the user's interaction with the InfoBar to |
69 // get lost at that point). | 69 // get lost at that point). |
70 scoped_ptr<ExtensionHost> extension_host_; | 70 scoped_ptr<extensions::ExtensionHost> extension_host_; |
71 | 71 |
72 // The observer monitoring when the delegate dies. | 72 // The observer monitoring when the delegate dies. |
73 DelegateObserver* observer_; | 73 DelegateObserver* observer_; |
74 | 74 |
75 const extensions::Extension* extension_; | 75 const extensions::Extension* extension_; |
76 content::NotificationRegistrar registrar_; | 76 content::NotificationRegistrar registrar_; |
77 | 77 |
78 // The requested height of the infobar (in pixels). | 78 // The requested height of the infobar (in pixels). |
79 int height_; | 79 int height_; |
80 | 80 |
81 // Whether we are currently animating to close. This is used to ignore | 81 // Whether we are currently animating to close. This is used to ignore |
82 // ExtensionView::PreferredSizeChanged notifications. | 82 // ExtensionView::PreferredSizeChanged notifications. |
83 bool closing_; | 83 bool closing_; |
84 | 84 |
85 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBarDelegate); | 85 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBarDelegate); |
86 }; | 86 }; |
87 | 87 |
88 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_ | 88 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_ |
OLD | NEW |