Bug 805292 - Make a 'pick' activity without a type to work, r=mounir
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 20 Nov 2012 15:43:10 +0000
changeset 113782 3ec8fba88e7ba66972fa5517729927f483b999fb
parent 113781 eaa18c12cba75d9e602bceb0ae891d13b82a6a26
child 113783 e68e9dcdaaeba5817541bee93492e355a39e2ff1
push id18382
push usermlamouri@mozilla.com
push dateTue, 20 Nov 2012 15:43:28 +0000
treeherdermozilla-inbound@3ec8fba88e7b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmounir
bugs805292
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 805292 - Make a 'pick' activity without a type to work, r=mounir
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;