Bug 805292 - Make a 'pick' activity without a type to work. r=mounir, a=akeybl
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 20 Nov 2012 15:43:10 +0000
changeset 118349 f719a9c96ea98a1ba4e6d83fc3d3ddd824c16cce
parent 118348 cf573f12023aa9156efe079b1e7636583dda5864
child 118350 e3f2f2c9f6adbff8d8a1ac9f990712601bd6e690
push id2758
push userryanvm@gmail.com
push dateWed, 21 Nov 2012 23:59:24 +0000
treeherdermozilla-aurora@c7cf5632c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmounir, akeybl
bugs805292
milestone19.0a2
Bug 805292 - Make a 'pick' activity without a type to work. r=mounir, a=akeybl
dom/activities/src/ActivitiesService.jsm
--- a/dom/activities/src/ActivitiesService.jsm
+++ b/dom/activities/src/ActivitiesService.jsm
@@ -253,26 +253,48 @@ let Activities = {
     };
 
     let errorCb = function errorCb(aError) {
       // Something unexpected happened. Should we send an error back?
       debug("Error in startActivity: " + aError + "\n");
     };
 
     let matchFunc = function matchFunc(aResult) {
-      // Bug 773383: arrays of strings / regexp.
-      for (let prop in aResult.description.filters) {
-        if (Array.isArray(aResult.description.filters[prop])) {
-          if (aResult.description.filters[prop].indexOf(aMsg.options.data[prop]) == -1) {
-            return false;
+
+      function matchFuncValue(aValue, aFilter) {
+        // Bug 805822 - Regexp support for MozActivity
+
+        let values = Array.isArray(aValue) ? aValue : [aValue];
+        let filters = Array.isArray(aFilter) ? aFilter : [aFilter];
+
+        // At least 1 value must match.
+        let ret = false;
+        values.forEach(function(value) {
+          if (filters.indexOf(value) != -1) {
+            ret = true;
           }
-        } else if (aResult.description.filters[prop] !== aMsg.options.data[prop] ) {
+        });
+
+        return ret;
+      }
+
+      // For any incoming property.
+      for (let prop in aMsg.options.data) {
+
+        // If this is unknown for the app, this app must be excluded.
+        if (!(prop in aResult.description.filters)) {
+          return false;
+        }
+
+        // Otherwise, let's check the value against the filter.
+        if (!matchFuncValue(aMsg.options.data[prop], aResult.description.filters[prop])) {
           return false;
         }
       }
+
       return true;
     };
 
     this.db.find(aMsg, successCb, errorCb, matchFunc);
   },
 
   receiveMessage: function activities_receiveMessage(aMessage) {
     let mm = aMessage.target;