Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / extensions / extension_infobar_delegate.h
blobb9a337f7401e894867c89bd8db152edfc316a85f
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
10 #include "content/public/browser/notification_observer.h"
11 #include "content/public/browser/notification_registrar.h"
13 class Browser;
14 class GURL;
16 namespace extensions {
17 class Extension;
18 class ExtensionViewHost;
21 // The InfobarDelegate for creating and managing state for the ExtensionInfobar
22 // plus monitor when the extension goes away.
23 class ExtensionInfoBarDelegate : public InfoBarDelegate,
24 public content::NotificationObserver {
25 public:
26 virtual ~ExtensionInfoBarDelegate();
28 // Creates an extension infobar and delegate and adds the infobar to the
29 // infobar service for |web_contents|.
30 static void Create(content::WebContents* web_contents,
31 Browser* browser,
32 const extensions::Extension* extension,
33 const GURL& url,
34 int height);
36 const extensions::Extension* extension() { return extension_; }
37 extensions::ExtensionViewHost* extension_view_host() {
38 return extension_view_host_.get();
40 int height() { return height_; }
42 bool closing() const { return closing_; }
44 private:
45 ExtensionInfoBarDelegate(Browser* browser,
46 const extensions::Extension* extension,
47 const GURL& url,
48 content::WebContents* web_contents,
49 int height);
51 // Returns an extension infobar that owns |delegate|.
52 static scoped_ptr<InfoBar> CreateInfoBar(
53 scoped_ptr<ExtensionInfoBarDelegate> delegate);
55 // InfoBarDelegate:
56 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const OVERRIDE;
57 virtual void InfoBarDismissed() OVERRIDE;
58 virtual Type GetInfoBarType() const OVERRIDE;
59 virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate() OVERRIDE;
61 // content::NotificationObserver:
62 virtual void Observe(int type,
63 const content::NotificationSource& source,
64 const content::NotificationDetails& details) OVERRIDE;
66 #if defined(TOOLKIT_VIEWS)
67 Browser* browser_; // We pass this to the ExtensionInfoBar.
68 #endif
70 // The extension host we are showing the InfoBar for.
71 // TODO(pkasting): Should this live on the InfoBar instead?
72 scoped_ptr<extensions::ExtensionViewHost> extension_view_host_;
74 const extensions::Extension* extension_;
75 content::NotificationRegistrar registrar_;
77 // The requested height of the infobar (in pixels).
78 int height_;
80 // Whether we are currently animating to close. This is used to ignore
81 // ExtensionView::PreferredSizeChanged notifications.
82 bool closing_;
84 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBarDelegate);
87 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_