blob: 9a3385d2718a7172d5f907155de8b20319d59db8 [file] [log] [blame]
[email protected]f4f50ef2011-01-21 19:01:191// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]f34e79632010-03-17 02:34:082// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_
6#define CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]f34e79632010-03-17 02:34:088
[email protected]7cceebac2011-03-03 00:32:219#include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
[email protected]f34e79632010-03-17 02:34:0810
11class Browser;
12class Extension;
13class ExtensionHost;
14class TabContents;
15
[email protected]df3bdcf2010-03-18 21:30:3216// The InfobarDelegate for creating and managing state for the ExtensionInfobar
17// plus monitor when the extension goes away.
[email protected]f34e79632010-03-17 02:34:0818class ExtensionInfoBarDelegate : public InfoBarDelegate,
19 public NotificationObserver {
20 public:
[email protected]fe098f72010-03-30 03:37:3321 // The observer for when the delegate dies.
22 class DelegateObserver {
23 public:
24 virtual void OnDelegateDeleted() = 0;
[email protected]46ebf0642010-07-24 02:47:4025
26 protected:
27 virtual ~DelegateObserver() {}
[email protected]fe098f72010-03-30 03:37:3328 };
29
[email protected]f4f50ef2011-01-21 19:01:1930 ExtensionInfoBarDelegate(Browser* browser,
31 TabContents* contents,
32 const Extension* extension,
33 const GURL& url);
[email protected]ec8f51162011-02-08 04:20:4034
[email protected]9adb9692010-10-29 23:14:0235 const Extension* extension() { return extension_; }
[email protected]f34e79632010-03-17 02:34:0836 ExtensionHost* extension_host() { return extension_host_.get(); }
37
[email protected]fe098f72010-03-30 03:37:3338 void set_observer(DelegateObserver* observer) { observer_ = observer; }
39
[email protected]ec8f51162011-02-08 04:20:4040 bool closing() const { return closing_; }
[email protected]f34e79632010-03-17 02:34:0841
[email protected]f4f50ef2011-01-21 19:01:1942 private:
43 virtual ~ExtensionInfoBarDelegate();
44
45 // InfoBarDelegate:
[email protected]e3c31d272011-05-05 02:12:1046 virtual InfoBar* CreateInfoBar() OVERRIDE;
47 virtual bool EqualsDelegate(InfoBarDelegate* delegate) const OVERRIDE;
48 virtual void InfoBarDismissed() OVERRIDE;
49 virtual Type GetInfoBarType() const OVERRIDE;
50 virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate() OVERRIDE;
[email protected]f4f50ef2011-01-21 19:01:1951
52 // NotificationObserver:
[email protected]f34e79632010-03-17 02:34:0853 virtual void Observe(NotificationType type,
54 const NotificationSource& source,
[email protected]e3c31d272011-05-05 02:12:1055 const NotificationDetails& details) OVERRIDE;
[email protected]f34e79632010-03-17 02:34:0856
[email protected]f34e79632010-03-17 02:34:0857 // The extension host we are showing the InfoBar for. The delegate needs to
58 // own this since the InfoBar gets deleted and recreated when you switch tabs
59 // and come back (and we don't want the user's interaction with the InfoBar to
[email protected]5dc35422010-11-10 22:20:3260 // get lost at that point).
[email protected]f34e79632010-03-17 02:34:0861 scoped_ptr<ExtensionHost> extension_host_;
62
[email protected]fe098f72010-03-30 03:37:3363 // The observer monitoring when the delegate dies.
64 DelegateObserver* observer_;
65
[email protected]9adb9692010-10-29 23:14:0266 const Extension* extension_;
[email protected]f34e79632010-03-17 02:34:0867 TabContents* tab_contents_;
[email protected]f34e79632010-03-17 02:34:0868 NotificationRegistrar registrar_;
69
[email protected]4a0429542010-06-28 20:34:4770 // Whether we are currently animating to close. This is used to ignore
71 // ExtensionView::PreferredSizeChanged notifications.
72 bool closing_;
73
[email protected]f34e79632010-03-17 02:34:0874 DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBarDelegate);
75};
76
77#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_