Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: safari/ext/popup.js

Issue 5703008528629760: Issue 2071 - Fixed issues when sending messages from the popup to the background page (Closed)
Patch Set: Addressed comment Created March 2, 2015, 7:42 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « safari/ext/background.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: safari/ext/popup.js
===================================================================
--- a/safari/ext/popup.js
+++ b/safari/ext/popup.js
@@ -73,10 +73,29 @@
// import ext into the javascript context of the popover. This code might fail,
// when the background page isn't ready yet. So it is important to put it below
// the reloading code above.
- window.ext = Object.create(safari.extension.globalPage.contentWindow.ext);
+ var backgroundPage = safari.extension.globalPage.contentWindow;
+ window.ext = Object.create(backgroundPage.ext);
ext.closePopup = function()
{
safari.self.hide();
};
+
+ ext.backgroundPage = {
+ getWindow: function()
+ {
+ return backgroundPage;
+ },
+
+ // On Safari, you can't send messages from the popup to the
+ // background page. So we call the message listeners directly.
+ sendMessage: function(message, responseCallback)
+ {
+ if (!responseCallback)
+ responseCallback = function () {};
+
+ backgroundPage.ext.onMessage._dispatch(message, {}, responseCallback);
+ }
+ };
+
})();
« no previous file with comments | « safari/ext/background.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld