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

Unified Diff: chrome/renderer/resources/extensions/browser_action_custom_bindings.js

Issue 25305002: Implement initial chrome.browserAction.openPopup API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/renderer/resources/extensions/browser_action_custom_bindings.js
diff --git a/chrome/renderer/resources/extensions/browser_action_custom_bindings.js b/chrome/renderer/resources/extensions/browser_action_custom_bindings.js
index d90ab18235c3e7ac53f9429e0b8c9edc1c44ffa8..0a57c0b2e7ce522c85829b1d16d2501ed606078e 100644
--- a/chrome/renderer/resources/extensions/browser_action_custom_bindings.js
+++ b/chrome/renderer/resources/extensions/browser_action_custom_bindings.js
@@ -7,6 +7,7 @@
var binding = require('binding').Binding.create('browserAction');
var setIcon = require('setIcon').setIcon;
+var getExtensionViews = requireNative('extension').GetExtensionViews;
binding.registerCustomHook(function(bindingsAPI) {
var apiFunctions = bindingsAPI.apiFunctions;
@@ -15,6 +16,22 @@ binding.registerCustomHook(function(bindingsAPI) {
setIcon(details, callback, this.name, this.definition.parameters,
'browser action');
});
+
+ apiFunctions.setCustomCallback('openPopup',
+ function(name, request, response) {
+ if (response && request.callback) {
+ var callback = request.callback;
+ // TODO(justinlin): Figure out how to ensure the popup is already open
+ // before calling this.
+ setTimeout(function() {
+ var views = getExtensionViews(-1, 'POPUP');
+ callback(views.length > 0 ? views[0] : null);
+ }, 50);
+ } else {
+ request.callback(null);
+ }
+ request.callback = null;
+ });
Finnur 2013/10/15 10:44:21 I've not been doing many custom bindings (that I c
Matt Perry 2013/10/15 21:29:41 Yep, already commented on this. The custom binding
justinlin 2013/10/16 07:06:48 I fixed the setTimeout hack. I think custom bindin
});
exports.binding = binding.generate();

Powered by Google App Engine
This is Rietveld 408576698