Add support for Chrome-gesture experiment

Previously, Salsa only supported experiments that worked by changing the
xinput parameters using the commandline tool in Crosh.  I've added a
similar tool for chromeOS located within the browser at chrome://salsa
now and it takes in the same encoded strings, but changes the values of
Chrome Gesture Preferences instead.

This patch adds the UI for selecting which type of experiment you want
to create when you're making new experiments and changes the
participant's page depending on which type it is.

eg: if you selected chrome-gestures when you created an experiment, your
participants will be given slightly different instructions.

BUG=chromium:249762
TEST=manually run with dev server on my local machine at
cmooney.mtv:8081

Change-Id: I8aecc3499b13adf835d24f0dbb7820bbfc02f2b0
Signed-off-by: Charlie Mooney <charliemooney@chromium.org>
diff --git a/create.py b/create.py
index 16931ad..ae96cff 100644
--- a/create.py
+++ b/create.py
@@ -15,10 +15,12 @@
             'description': self.request.get('exp_description'),
             'instructions': self.request.get('exp_instructions'),
             'device': self.request.get('exp_device'),
-            'owner': users.get_current_user()
+            'owner': users.get_current_user(),
+            'experiment_type': self.request.get('exp_type')
         }
 
-        required_keys = ['name', 'owner', 'device', 'instructions']
+        required_keys = ['name', 'owner', 'device', 'instructions',
+                         'experiment_type']
         if not all(exp.get(key) for key in required_keys):
             return None
         return exp
@@ -99,6 +101,7 @@
             exp.instructions = experiment.get('instructions')
             exp.device = experiment.get('device')
             exp.owner = experiment.get('owner')
+            exp.experiment_type = experiment.get('experiment_type')
             exp.put()
 
             # Adding each treatment in turn
diff --git a/models.py b/models.py
index 9825e9b..63c7b3a 100644
--- a/models.py
+++ b/models.py
@@ -14,6 +14,7 @@
     created = db.DateTimeProperty(auto_now_add=True)
     participants = db.ListProperty(str)
     feedback = db.ListProperty(db.Text)
+    experiment_type = db.StringProperty()
 
 class Treatment(db.Model):
     """ Models a single treament for experimentation """
diff --git a/templates/index.html b/templates/index.html
index 555f73b..891fb5d 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -115,6 +115,15 @@
         <td>Device(s):</td>
         <td><input type="text" name="exp_device"></td>
       </tr>
+      <tr>
+        <td>Experiment Type:</td>
+        <td>
+         <input type="radio" name="exp_type" value="xinput">
+            Xinput Properties<br>
+         <input type="radio" name="exp_type" value="chrome-gestures">
+            Chrome Gestures<br>
+        </td>
+      </tr>
     </table>
 
     <h2> Treatments </h2>
diff --git a/templates/participate.html b/templates/participate.html
index eae3865..3e08f41 100644
--- a/templates/participate.html
+++ b/templates/participate.html
@@ -159,17 +159,29 @@
     {{ experiment.device }}</font> please do not participate.
   </div>
 
-  <p>
-    To try out this experiment, simply press Ctrl + Alt + t to open a terminal
-    and paste in the cryptic command below.  (Note that to paste into the
-    terminal you must either right click and press paste or use Ctrl + Shift
-    + v on your keyboard)
-  </p>
+  {% if experiment.experiment_type == "chrome-gestures" %}
+    <p>
+      To try out this experiment, simply Copy/Paste the following cryptic url
+      into your address bar.
+    </p>
 
-  <div class="command rectangle">
-    try_touch_experiment
-    {{ experiment|encode_experiment(treatments, properties) }}
-  </div>
+    <div class="command rectangle">
+      chrome://salsa/#
+      {{- experiment|encode_experiment(treatments, properties) }}
+    </div>
+  {% else %}
+    <p>
+      To try out this experiment, simply press Ctrl + Alt + t to open a terminal
+      and paste in the cryptic command below.  (Note that to paste into the
+      terminal you must either right click and press paste or use Ctrl + Shift
+      + v on your keyboard)
+    </p>
+
+    <div class="command rectangle">
+      try_touch_experiment
+      {{ experiment|encode_experiment(treatments, properties) }}
+    </div>
+  {% endif %}
 
   <p>
     This will allow you to switch between the treatments and see which you
diff --git a/templates/view.html b/templates/view.html
index cba7068..7410d25 100644
--- a/templates/view.html
+++ b/templates/view.html
@@ -12,6 +12,7 @@
       <li> Device: {{ experiment.device }}
       <li> Owner:
         <a href="mailto:{{ experiment.owner }}@google.com">{{ experiment.owner }}</a>
+      <li> Type: {{ experiment.experiment_type }}
       <li> Created: {{ experiment.created }}
       <li> Participant URL:
         <a href="{{ experiment_url }}"> {{ experiment_url }} </a>