Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: chrome/browser/extensions/extension_infobar_delegate.h

Issue 190063006: Infobar Componentization Proof of Concept (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor fixes Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/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 content::WebContents* web_contents() { return web_contents_; }
49
44 private: 50 private:
45 ExtensionInfoBarDelegate(Browser* browser, 51 ExtensionInfoBarDelegate(Browser* browser,
46 const extensions::Extension* extension, 52 const extensions::Extension* extension,
47 const GURL& url, 53 const GURL& url,
48 content::WebContents* web_contents, 54 content::WebContents* web_contents,
49 int height); 55 int height);
50 56
51 // Returns an extension infobar that owns |delegate|. 57 // Returns an extension infobar that owns |delegate|.
52 static scoped_ptr<InfoBar> CreateInfoBar( 58 static scoped_ptr<InfoBar> CreateInfoBar(
53 scoped_ptr<ExtensionInfoBarDelegate> delegate); 59 scoped_ptr<ExtensionInfoBarDelegate> delegate);
54 60
55 // InfoBarDelegate: 61 // InfoBarDelegate:
56 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const OVERRIDE; 62 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const OVERRIDE;
57 virtual void InfoBarDismissed() OVERRIDE; 63 virtual void InfoBarDismissed() OVERRIDE;
58 virtual Type GetInfoBarType() const OVERRIDE; 64 virtual Type GetInfoBarType() const OVERRIDE;
59 virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate() OVERRIDE; 65 virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate() OVERRIDE;
66 virtual void CleanUp() OVERRIDE;
60 67
61 // content::NotificationObserver: 68 // content::NotificationObserver:
62 virtual void Observe(int type, 69 virtual void Observe(int type,
63 const content::NotificationSource& source, 70 const content::NotificationSource& source,
64 const content::NotificationDetails& details) OVERRIDE; 71 const content::NotificationDetails& details) OVERRIDE;
65 72
66 #if defined(TOOLKIT_VIEWS) 73 #if defined(TOOLKIT_VIEWS)
67 Browser* browser_; // We pass this to the ExtensionInfoBar. 74 Browser* browser_; // We pass this to the ExtensionInfoBar.
68 #endif 75 #endif
69 76
77 content::WebContents* web_contents_;
78
70 // The extension host we are showing the InfoBar for. 79 // The extension host we are showing the InfoBar for.
71 // TODO(pkasting): Should this live on the InfoBar instead? 80 // TODO(pkasting): Should this live on the InfoBar instead?
72 scoped_ptr<extensions::ExtensionViewHost> extension_view_host_; 81 scoped_ptr<extensions::ExtensionViewHost> extension_view_host_;
73 82
74 const extensions::Extension* extension_; 83 const extensions::Extension* extension_;
75 content::NotificationRegistrar registrar_; 84 content::NotificationRegistrar registrar_;
76 85
77 // The requested height of the infobar (in pixels). 86 // The requested height of the infobar (in pixels).
78 int height_; 87 int height_;
79 88
80 // Whether we are currently animating to close. This is used to ignore 89 // Whether we are currently animating to close. This is used to ignore
81 // ExtensionView::PreferredSizeChanged notifications. 90 // ExtensionView::PreferredSizeChanged notifications.
82 bool closing_; 91 bool closing_;
83 92
84 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBarDelegate); 93 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBarDelegate);
85 }; 94 };
86 95
87 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_ 96 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698