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

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

Issue 4767001: Make TabContents own its infobar delegates.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #pragma once 7 #pragma once
8 8
9 #include "chrome/browser/tab_contents/infobar_delegate.h" 9 #include "chrome/browser/tab_contents/infobar_delegate.h"
10 10
11 class Browser; 11 class Browser;
12 class Extension; 12 class Extension;
13 class ExtensionHost; 13 class ExtensionHost;
14 class TabContents; 14 class TabContents;
15 15
16 // The InfobarDelegate for creating and managing state for the ExtensionInfobar 16 // The InfobarDelegate for creating and managing state for the ExtensionInfobar
17 // plus monitor when the extension goes away. 17 // plus monitor when the extension goes away.
18 class ExtensionInfoBarDelegate : public InfoBarDelegate, 18 class ExtensionInfoBarDelegate : public InfoBarDelegate,
19 public NotificationObserver { 19 public NotificationObserver {
20 public: 20 public:
21 // The observer for when the delegate dies. 21 ExtensionInfoBarDelegate(Browser* browser,
22 class DelegateObserver { 22 TabContents* contents,
23 public: 23 const Extension* extension,
24 virtual void OnDelegateDeleted() = 0; 24 const GURL& url);
25
26 protected:
27 virtual ~DelegateObserver() {}
28 };
29
30 ExtensionInfoBarDelegate(Browser* browser, TabContents* contents,
31 const Extension* extension, const GURL& url);
32 ~ExtensionInfoBarDelegate(); 25 ~ExtensionInfoBarDelegate();
33 26
34 const Extension* extension() { return extension_; } 27 const Extension* extension() { return extension_; }
35 ExtensionHost* extension_host() { return extension_host_.get(); } 28 ExtensionHost* extension_host() { return extension_host_.get(); }
36 29
37 void set_observer(DelegateObserver* observer) { observer_ = observer; }
38
39 // Overridden from InfoBarDelegate: 30 // Overridden from InfoBarDelegate:
40 virtual void InfoBarDismissed() { closing_ = true; }
41 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const; 31 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const;
42 virtual void InfoBarClosed(); 32 virtual void InfoBarClosed();
43 virtual InfoBar* CreateInfoBar(); 33 virtual InfoBar* CreateInfoBar();
44 virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate(); 34 virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate();
45 virtual Type GetInfoBarType(); 35 virtual Type GetInfoBarType();
46 36
47 // Overridden from NotificationObserver: 37 // Overridden from NotificationObserver:
48 virtual void Observe(NotificationType type, 38 virtual void Observe(NotificationType type,
49 const NotificationSource& source, 39 const NotificationSource& source,
50 const NotificationDetails& details); 40 const NotificationDetails& details);
51 41
52 bool closing() { return closing_; }
53 private: 42 private:
54 // The extension host we are showing the InfoBar for. The delegate needs to 43 // The extension host we are showing the InfoBar for. The delegate needs to
55 // own this since the InfoBar gets deleted and recreated when you switch tabs 44 // own this since the InfoBar gets deleted and recreated when you switch tabs
56 // and come back (and we don't want the user's interaction with the InfoBar to 45 // and come back (and we don't want the user's interaction with the InfoBar to
57 // get lost at that point. 46 // get lost at that point.
58 scoped_ptr<ExtensionHost> extension_host_; 47 scoped_ptr<ExtensionHost> extension_host_;
59 48
60 // The observer monitoring when the delegate dies.
61 DelegateObserver* observer_;
62
63 const Extension* extension_; 49 const Extension* extension_;
64 50
65 TabContents* tab_contents_; 51 TabContents* tab_contents_;
66 52
67 NotificationRegistrar registrar_; 53 NotificationRegistrar registrar_;
68 54
69 // Whether we are currently animating to close. This is used to ignore
70 // ExtensionView::PreferredSizeChanged notifications.
71 bool closing_;
72
73 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBarDelegate); 55 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBarDelegate);
74 }; 56 };
75 57
76 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_ 58 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698