Update broken references to image assets
[chromium-blink-merge.git] / remoting / webapp / base / js / experiments.js
blobb6228c47cbd7ab9fba8963cc7c01695870e9ed51
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 /**
6 * @fileoverview
7 * Class for enabling experimental features.
8 */
10 'use strict';
12 /** @suppress {duplicate} */
13 var remoting = remoting || {};
15 (function () {
17 var kExperimentsStorageName = 'remoting-experiments';
19 /**
20 * @param {Array.<string>} list
22 function save(list) {
23 var storageMap = {};
24 storageMap[kExperimentsStorageName] = list;
25 chrome.storage.local.set(storageMap);
28 /** @type {Object} */
29 remoting.experiments = {};
31 /**
32 * Enables an experiment.
34 * @param {string} experiment to enable.
36 remoting.experiments.enable = function(experiment) {
37 remoting.experiments.get().then(function(/** Array.<string> */list) {
38 if (list.indexOf(experiment) == -1) {
39 list.push(experiment);
40 save(list);
42 });
45 /**
46 * Disables an experiment.
48 * @param {string} experiment to disable.
50 remoting.experiments.disable = function(experiment) {
51 remoting.experiments.get().then(function(/** Array.<string> */list) {
52 list = list.filter(function(e) { return e !== experiment; });
53 save(list);
54 });
57 /**
58 * Returns list of all enabled experiments.
59 * @return {Promise}
61 remoting.experiments.get = function() {
62 return new Promise(function(resolve, reject) {
63 chrome.storage.local.get(kExperimentsStorageName, function(items) {
64 if (items.hasOwnProperty(kExperimentsStorageName)) {
65 resolve(items[kExperimentsStorageName]);
67 resolve([]);
68 });
69 });
72 })();