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 117058 92f99fc77dbcb6d91688ee4bef3724bdf67fe76a
parent 117057 e0d2cead16d00fe3a16bd5b20bf3893f2883ea7d
child 117059 a05896ac7000443c147534844983bb883d47b296
push id1732
push userryanvm@gmail.com
push dateWed, 21 Nov 2012 23:58:59 +0000
treeherdermozilla-beta@3ec692d51952 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmounir, akeybl
bugs805292
milestone18.0
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;