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

Unified Diff: chrome/browser/extensions/extension_toolbar_model.h

Issue 25305002: Implement initial chrome.browserAction.openPopup API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move to interactive_ui_test Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_toolbar_model.h
diff --git a/chrome/browser/extensions/extension_toolbar_model.h b/chrome/browser/extensions/extension_toolbar_model.h
index df01de5d17281de69b7072048f8efca77b573e26..1d77d4ee81cd91f0b6ff2180fa9043e2821c4215 100644
--- a/chrome/browser/extensions/extension_toolbar_model.h
+++ b/chrome/browser/extensions/extension_toolbar_model.h
@@ -33,7 +33,7 @@ class ExtensionToolbarModel : public content::NotificationObserver {
};
// A class which is informed of changes to the model; represents the view of
- // MVC.
+ // MVC. Also used for signaling view changes such as showing extension popups.
class Observer {
public:
// An extension with a browser action button has been added, and should go
@@ -48,6 +48,10 @@ class ExtensionToolbarModel : public content::NotificationObserver {
virtual void BrowserActionMoved(const extensions::Extension* extension,
int index) {}
+ // Signal the |extension| to show the popup now in the active window.
+ // Returns true if a popup was slated to be shown.
+ virtual bool BrowserActionShowPopup(const extensions::Extension* extension);
+
// Called when the model has finished loading.
virtual void ModelLoaded() {}
@@ -62,10 +66,14 @@ class ExtensionToolbarModel : public content::NotificationObserver {
// Executes the browser action for an extension and returns the action that
// the UI should perform in response.
// |popup_url_out| will be set if the extension should show a popup, with
- // the URL that should be shown, if non-NULL.
+ // the URL that should be shown, if non-NULL. |should_grant| controls whether
+ // the extension should be granted page tab permissions, which is what happens
+ // when the user clicks the browser action, but not, for example, when the
+ // showPopup API is called.
Action ExecuteBrowserAction(const extensions::Extension* extension,
Browser* browser,
- GURL* popup_url_out);
+ GURL* popup_url_out,
+ bool should_grant);
// If count == size(), this will set the visible icon count to -1, meaning
// "show all actions".
void SetVisibleIconCount(int count);
@@ -85,6 +93,10 @@ class ExtensionToolbarModel : public content::NotificationObserver {
void OnExtensionToolbarPrefChange();
+ // Tells observers to display a popup without granting tab permissions and
+ // returns whether the popup was slated to be shown.
+ bool ShowBrowserActionPopup(const extensions::Extension* extension);
+
private:
// content::NotificationObserver implementation.
virtual void Observe(int type,

Powered by Google App Engine
This is Rietveld 408576698