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