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 "chrome/browser/infobars/confirm_infobar_delegate.h" | 9 #include "chrome/browser/infobars/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 GURL; | 14 class GURL; |
15 | 15 |
| 16 namespace content { |
| 17 class WebContents; |
| 18 } |
| 19 |
16 namespace extensions { | 20 namespace extensions { |
17 class Extension; | 21 class Extension; |
18 class ExtensionViewHost; | 22 class ExtensionViewHost; |
19 } | 23 } |
20 | 24 |
21 // The InfobarDelegate for creating and managing state for the ExtensionInfobar | 25 // The InfobarDelegate for creating and managing state for the ExtensionInfobar |
22 // plus monitor when the extension goes away. | 26 // plus monitor when the extension goes away. |
23 class ExtensionInfoBarDelegate : public InfoBarDelegate, | 27 class ExtensionInfoBarDelegate : public InfoBarDelegate, |
24 public content::NotificationObserver { | 28 public content::NotificationObserver { |
25 public: | 29 public: |
26 virtual ~ExtensionInfoBarDelegate(); | 30 virtual ~ExtensionInfoBarDelegate(); |
27 | 31 |
28 // Creates an extension infobar and delegate and adds the infobar to the | 32 // Creates an extension infobar and delegate and adds the infobar to the |
29 // infobar service for |web_contents|. | 33 // infobar service for |web_contents|. |
30 static void Create(content::WebContents* web_contents, | 34 static void Create(content::WebContents* web_contents, |
31 Browser* browser, | 35 Browser* browser, |
32 const extensions::Extension* extension, | 36 const extensions::Extension* extension, |
33 const GURL& url, | 37 const GURL& url, |
34 int height); | 38 int height); |
35 | 39 |
36 const extensions::Extension* extension() { return extension_; } | 40 const extensions::Extension* extension() { return extension_; } |
37 extensions::ExtensionViewHost* extension_view_host() { | 41 extensions::ExtensionViewHost* extension_view_host() { |
38 return extension_view_host_.get(); | 42 return extension_view_host_.get(); |
39 } | 43 } |
40 int height() { return height_; } | 44 int height() { return height_; } |
41 | 45 |
42 bool closing() const { return closing_; } | 46 bool closing() const { return closing_; } |
43 | 47 |
| 48 // Returns the WebContents associated with the ExtensionInfoBarDelegate. |
| 49 content::WebContents* GetWebContents(); |
| 50 |
44 private: | 51 private: |
45 ExtensionInfoBarDelegate(Browser* browser, | 52 ExtensionInfoBarDelegate(Browser* browser, |
46 const extensions::Extension* extension, | 53 const extensions::Extension* extension, |
47 const GURL& url, | 54 const GURL& url, |
48 content::WebContents* web_contents, | 55 content::WebContents* web_contents, |
49 int height); | 56 int height); |
50 | 57 |
51 // Returns an extension infobar that owns |delegate|. | 58 // Returns an extension infobar that owns |delegate|. |
52 static scoped_ptr<InfoBar> CreateInfoBar( | 59 static scoped_ptr<InfoBar> CreateInfoBar( |
53 scoped_ptr<ExtensionInfoBarDelegate> delegate); | 60 scoped_ptr<ExtensionInfoBarDelegate> delegate); |
(...skipping 24 matching lines...) Expand all Loading... |
78 int height_; | 85 int height_; |
79 | 86 |
80 // Whether we are currently animating to close. This is used to ignore | 87 // Whether we are currently animating to close. This is used to ignore |
81 // ExtensionView::PreferredSizeChanged notifications. | 88 // ExtensionView::PreferredSizeChanged notifications. |
82 bool closing_; | 89 bool closing_; |
83 | 90 |
84 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBarDelegate); | 91 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBarDelegate); |
85 }; | 92 }; |
86 | 93 |
87 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_ | 94 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_ |
OLD | NEW |