summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_infobar_delegate.h
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-17 02:34:08 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-17 02:34:08 +0000
commitf34e7963c796bda1eb7fd35f5eda0d878c2df4e6 (patch)
tree1c67e594a5d25adb0b842858f622e3038146b8b7 /chrome/browser/extensions/extension_infobar_delegate.h
parentb304b6162c3a78063f1ed775e33995d8f2205ed4 (diff)
downloadchromium_src-f34e7963c796bda1eb7fd35f5eda0d878c2df4e6.zip
chromium_src-f34e7963c796bda1eb7fd35f5eda0d878c2df4e6.tar.gz
chromium_src-f34e7963c796bda1eb7fd35f5eda0d878c2df4e6.tar.bz2
First cut at adding Extension Infobars to the experimental API.
Originally described here: http://code.google.com/p/chromium/wiki/InfoBarExtensionAPI The API is simple: chrome.experimental.infoBar.show( {"htmlPath": "infobar.html"}, function(window) { // |window| is where the infobar was shown. }); To close it, you can simply call window.close() from within the InfoBar (infoBar.hide is not provided). The api is privileged (not available to content scripts directly). The minimum height for the infobar is regular height for our infobars (32 pixels), maximum is twice that and the actual size is determined by the content (within these constraints mentioned). See screenshot in bug. The icon on the far left is an extension icon with a dropdown menu showing the menu that shows when you right-click on the extension icon in the Omnibox/browser action container. BUG=26463 TEST=None (for now). Review URL: http://codereview.chromium.org/1049001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41806 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_infobar_delegate.h')
-rw-r--r--chrome/browser/extensions/extension_infobar_delegate.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_infobar_delegate.h b/chrome/browser/extensions/extension_infobar_delegate.h
new file mode 100644
index 0000000..485b288
--- /dev/null
+++ b/chrome/browser/extensions/extension_infobar_delegate.h
@@ -0,0 +1,59 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_
+
+#include "chrome/browser/tab_contents/infobar_delegate.h"
+
+class Browser;
+class Extension;
+class ExtensionHost;
+class TabContents;
+
+// An interface derived from InfoBarDelegate to form the base interface for
+// extension InfoBars.
+class ExtensionInfoBarDelegate : public InfoBarDelegate,
+ public NotificationObserver {
+ public:
+ ExtensionInfoBarDelegate(Browser* browser, TabContents* contents,
+ Extension* extension, const GURL& url);
+ ~ExtensionInfoBarDelegate();
+
+ Extension* extension() { return extension_; }
+ ExtensionHost* extension_host() { return extension_host_.get(); }
+
+ // Overridden from InfoBarDelegate:
+ virtual bool EqualsDelegate(InfoBarDelegate* delegate) const;
+ virtual void InfoBarClosed();
+ virtual InfoBar* CreateInfoBar();
+ virtual ExtensionInfoBarDelegate* AsExtensionInfoBarDelegate() {
+ return this;
+ }
+ virtual Type GetInfoBarType() {
+ return PAGE_ACTION_TYPE;
+ }
+
+ // Overridden from NotificationObserver:
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
+ private:
+ // The extension host we are showing the InfoBar for. The delegate needs to
+ // own this since the InfoBar gets deleted and recreated when you switch tabs
+ // and come back (and we don't want the user's interaction with the InfoBar to
+ // get lost at that point.
+ scoped_ptr<ExtensionHost> extension_host_;
+
+ Extension* extension_;
+
+ TabContents* tab_contents_;
+
+ NotificationRegistrar registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionInfoBarDelegate);
+};
+
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFOBAR_DELEGATE_H_