[chrome-gnome-shell] update-check: fixed in-frame communication



commit 091f1c5ce4667a503dbf07e5958a00ec2c0f5ecc
Author: Yuri Konotopov <ykonotopov gnome org>
Date:   Thu Mar 2 23:16:55 2017 +0400

    update-check: fixed in-frame communication
    
    For same reason as in abddd4bb we should use window.postMessage for
    in-frame communication.

 extension/extension.js      |    2 +-
 extension/include/update.js |   24 ++++++++++--------------
 2 files changed, 11 insertions(+), 15 deletions(-)
---
diff --git a/extension/extension.js b/extension/extension.js
index ec05739..83891a8 100644
--- a/extension/extension.js
+++ b/extension/extension.js
@@ -144,7 +144,7 @@ port.onMessage.addListener(function (message) {
                }
                else if([SIGNAL_NOTIFICATION_ACTION, SIGNAL_NOTIFICATION_CLICKED].indexOf(message.signal) != 
-1)
                {
-                       chrome.runtime.sendMessage(message);
+                       window.postMessage(message, "*");
                }
        }
 });
diff --git a/extension/include/update.js b/extension/include/update.js
index 1e6792e..92bf693 100644
--- a/extension/include/update.js
+++ b/extension/include/update.js
@@ -234,23 +234,19 @@ GSC.update = (function($) {
                        }
                        else
                        {
-                               chrome.runtime.onMessage.addListener(
-                                       function (request, sender, sendResponse) {
-                                               if(
-                                                       sender.id && sender.id === GS_CHROME_ID &&
-                                                       request && request.signal)
+                               window.addEventListener("message", function (event) {
+                                       if (event.source == window && event.data && event.data.signal)
+                                       {
+                                               if(event.data.signal == SIGNAL_NOTIFICATION_ACTION)
                                                {
-                                                       if(request.signal == SIGNAL_NOTIFICATION_ACTION)
-                                                       {
-                                                               onNotificationAction(request.name, 
request.button_id);
-                                                       }
-                                                       else if(request.signal == SIGNAL_NOTIFICATION_CLICKED)
-                                                       {
-                                                               onNotificationClicked(request.name);
-                                                       }
+                                                       onNotificationAction(event.data.name, 
event.data.button_id);
+                                               }
+                                               else if(event.data.signal == SIGNAL_NOTIFICATION_CLICKED)
+                                               {
+                                                       onNotificationClicked(event.data.name);
                                                }
                                        }
-                               );
+                               });
                        }
                });
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]