OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/scoped_observer.h" |
9 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 10 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
10 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
11 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
| 13 #include "extensions/browser/extension_registry_observer.h" |
12 | 14 |
13 class Browser; | 15 class Browser; |
14 class GURL; | 16 class GURL; |
15 | 17 |
16 namespace content { | 18 namespace content { |
17 class WebContents; | 19 class WebContents; |
18 } | 20 } |
19 | 21 |
20 namespace extensions { | 22 namespace extensions { |
21 class Extension; | 23 class Extension; |
| 24 class ExtensionRegistry; |
22 class ExtensionViewHost; | 25 class ExtensionViewHost; |
23 } | 26 } |
24 | 27 |
25 // The InfobarDelegate for creating and managing state for the ExtensionInfobar | 28 // The InfobarDelegate for creating and managing state for the ExtensionInfobar |
26 // plus monitor when the extension goes away. | 29 // plus monitor when the extension goes away. |
27 class ExtensionInfoBarDelegate : public infobars::InfoBarDelegate, | 30 class ExtensionInfoBarDelegate : public infobars::InfoBarDelegate, |
28 public content::NotificationObserver { | 31 public content::NotificationObserver, |
| 32 public extensions::ExtensionRegistryObserver { |
29 public: | 33 public: |
30 virtual ~ExtensionInfoBarDelegate(); | 34 virtual ~ExtensionInfoBarDelegate(); |
31 | 35 |
32 // Creates an extension infobar and delegate and adds the infobar to the | 36 // Creates an extension infobar and delegate and adds the infobar to the |
33 // infobar service for |web_contents|. | 37 // infobar service for |web_contents|. |
34 static void Create(content::WebContents* web_contents, | 38 static void Create(content::WebContents* web_contents, |
35 Browser* browser, | 39 Browser* browser, |
36 const extensions::Extension* extension, | 40 const extensions::Extension* extension, |
37 const GURL& url, | 41 const GURL& url, |
38 int height); | 42 int height); |
(...skipping 13 matching lines...) Expand all Loading... |
52 ExtensionInfoBarDelegate(Browser* browser, | 56 ExtensionInfoBarDelegate(Browser* browser, |
53 const extensions::Extension* extension, | 57 const extensions::Extension* extension, |
54 const GURL& url, | 58 const GURL& url, |
55 content::WebContents* web_contents, | 59 content::WebContents* web_contents, |
56 int height); | 60 int height); |
57 | 61 |
58 // Returns an extension infobar that owns |delegate|. | 62 // Returns an extension infobar that owns |delegate|. |
59 static scoped_ptr<infobars::InfoBar> CreateInfoBar( | 63 static scoped_ptr<infobars::InfoBar> CreateInfoBar( |
60 scoped_ptr<ExtensionInfoBarDelegate> delegate); | 64 scoped_ptr<ExtensionInfoBarDelegate> delegate); |
61 | 65 |
62 // InfoBarDelegate: | 66 // InfoBarDelegate. |
63 virtual bool EqualsDelegate( | 67 virtual bool EqualsDelegate( |
64 infobars::InfoBarDelegate* delegate) const OVERRIDE; | 68 infobars::InfoBarDelegate* delegate) const OVERRIDE; |
65 virtual void InfoBarDismissed() OVERRIDE; | 69 virtual void InfoBarDismissed() OVERRIDE; |
66 virtual Type GetInfoBarType() const OVERRIDE; | 70 virtual Type GetInfoBarType() const OVERRIDE; |
67 virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate() OVERRIDE; | 71 virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate() OVERRIDE; |
68 | 72 |
69 // content::NotificationObserver: | 73 // content::NotificationObserver. |
70 virtual void Observe(int type, | 74 virtual void Observe(int type, |
71 const content::NotificationSource& source, | 75 const content::NotificationSource& source, |
72 const content::NotificationDetails& details) OVERRIDE; | 76 const content::NotificationDetails& details) OVERRIDE; |
73 | 77 |
| 78 // extensions::ExtensionRegistryObserver. |
| 79 virtual void OnExtensionUnloaded( |
| 80 content::BrowserContext* browser_context, |
| 81 const extensions::Extension* extension, |
| 82 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; |
| 83 |
74 #if defined(TOOLKIT_VIEWS) | 84 #if defined(TOOLKIT_VIEWS) |
75 Browser* browser_; // We pass this to the ExtensionInfoBar. | 85 Browser* browser_; // We pass this to the ExtensionInfoBar. |
76 #endif | 86 #endif |
77 | 87 |
78 // The extension host we are showing the InfoBar for. | 88 // The extension host we are showing the InfoBar for. |
79 // TODO(pkasting): Should this live on the InfoBar instead? | 89 // TODO(pkasting): Should this live on the InfoBar instead? |
80 scoped_ptr<extensions::ExtensionViewHost> extension_view_host_; | 90 scoped_ptr<extensions::ExtensionViewHost> extension_view_host_; |
81 | 91 |
82 const extensions::Extension* extension_; | 92 const extensions::Extension* extension_; |
83 content::NotificationRegistrar registrar_; | 93 content::NotificationRegistrar registrar_; |
84 | 94 |
| 95 ScopedObserver<extensions::ExtensionRegistry, |
| 96 extensions::ExtensionRegistryObserver> |
| 97 extension_registry_observer_; |
| 98 |
85 // The requested height of the infobar (in pixels). | 99 // The requested height of the infobar (in pixels). |
86 int height_; | 100 int height_; |
87 | 101 |
88 // Whether we are currently animating to close. This is used to ignore | 102 // Whether we are currently animating to close. This is used to ignore |
89 // ExtensionView::PreferredSizeChanged notifications. | 103 // ExtensionView::PreferredSizeChanged notifications. |
90 bool closing_; | 104 bool closing_; |
91 | 105 |
92 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBarDelegate); | 106 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBarDelegate); |
93 }; | 107 }; |
94 | 108 |
95 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_ | 109 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_ |
OLD | NEW |