summaryrefslogtreecommitdiffstats
path: root/remoting/webapp
diff options
context:
space:
mode:
authorlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-19 00:17:55 +0000
committerlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-19 00:17:55 +0000
commitd91e66156860c4f4e3f3239483140b33a104c812 (patch)
treecc3ee44876a4720a53b82ee12044eed7aa2c93bf /remoting/webapp
parent6654875c8303499261f7724c57f2c2bae046bbd9 (diff)
downloadchromium_src-d91e66156860c4f4e3f3239483140b33a104c812.zip
chromium_src-d91e66156860c4f4e3f3239483140b33a104c812.tar.gz
chromium_src-d91e66156860c4f4e3f3239483140b33a104c812.tar.bz2
Remove storage.js from Chromoting webapp
References to remoting.storage have been updated to point to chrome.storage. BUG=222785 TEST=Verify webapp preferences persist, no jscompile errors. R=jamiewalch@chromium.org Review URL: https://codereview.chromium.org/17385017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207123 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/webapp')
-rw-r--r--remoting/webapp/all_js_load.gtestjs1
-rw-r--r--remoting/webapp/appsv2.patch9
-rw-r--r--remoting/webapp/host_list.js4
-rw-r--r--remoting/webapp/host_settings.js4
-rw-r--r--remoting/webapp/jscompiler_hacks.js38
-rw-r--r--remoting/webapp/main.html1
-rw-r--r--remoting/webapp/remoting.js7
-rw-r--r--remoting/webapp/storage.js138
-rw-r--r--remoting/webapp/ui_mode.js16
9 files changed, 49 insertions, 169 deletions
diff --git a/remoting/webapp/all_js_load.gtestjs b/remoting/webapp/all_js_load.gtestjs
index a8f5918..db1d184 100644
--- a/remoting/webapp/all_js_load.gtestjs
+++ b/remoting/webapp/all_js_load.gtestjs
@@ -56,7 +56,6 @@ AllJsLoadTest.prototype = {
'session_connector.js',
'server_log_entry.js',
'stats_accumulator.js',
- 'storage.js',
'toolbar.js',
'ui_mode.js',
//'viewer_plugin_proto.js', // Only used by jscompiler.
diff --git a/remoting/webapp/appsv2.patch b/remoting/webapp/appsv2.patch
index 505cb12..dcb2417 100644
--- a/remoting/webapp/appsv2.patch
+++ b/remoting/webapp/appsv2.patch
@@ -100,15 +100,14 @@ diff --git a/remoting/webapp/remoting.js b/remoting/webapp/remoting.js
index f89072a..2fadd83 100644
--- a/remoting.js
+++ b/remoting.js
-@@ -34,8 +34,6 @@ function consentRequired_(authContinue) {
+@@ -34,7 +34,6 @@ function consentRequired_(authContinue) {
* Entry point for app initialization.
*/
remoting.init = function() {
- migrateLocalToChromeStorage_();
--
- // TODO(jamiewalch): Remove this when we migrate to apps v2
- // (http://crbug.com/ 134213).
- remoting.initMockStorage();
+ remoting.logExtensionInfo_();
+ l10n.localize();
+ // Create global objects.
@@ -45,10 +45,7 @@ remoting.init = function() {
// Create global objects.
remoting.settings = new remoting.Settings();
diff --git a/remoting/webapp/host_list.js b/remoting/webapp/host_list.js
index f1282d5..99ad354 100644
--- a/remoting/webapp/host_list.js
+++ b/remoting/webapp/host_list.js
@@ -104,7 +104,7 @@ remoting.HostList.prototype.load = function(onDone) {
}
onDone();
};
- remoting.storage.local.get(remoting.HostList.HOSTS_KEY, storeHostList);
+ chrome.storage.local.get(remoting.HostList.HOSTS_KEY, storeHostList);
};
/**
@@ -462,7 +462,7 @@ remoting.HostList.prototype.onErrorClick_ = function() {
remoting.HostList.prototype.save_ = function() {
var items = {};
items[remoting.HostList.HOSTS_KEY] = JSON.stringify(this.hosts_);
- remoting.storage.local.set(items);
+ chrome.storage.local.set(items);
};
/**
diff --git a/remoting/webapp/host_settings.js b/remoting/webapp/host_settings.js
index 65b5fdd..9fa43b6 100644
--- a/remoting/webapp/host_settings.js
+++ b/remoting/webapp/host_settings.js
@@ -60,7 +60,7 @@ remoting.HostSettings.save = function(hostId, options, opt_callback) {
allHosts[hostId] = requestedHost;
var newSettings = {};
newSettings[remoting.HostSettings.KEY_] = JSON.stringify(allHosts);
- remoting.storage.local.set(newSettings, opt_callback);
+ chrome.storage.local.set(newSettings, opt_callback);
};
remoting.HostSettings.loadInternal_(hostId, onDone);
};
@@ -96,7 +96,7 @@ remoting.HostSettings.loadInternal_ = function(hostId, callback) {
}
callback({}, /** @type {Object} */ (result));
};
- remoting.storage.local.get(remoting.HostSettings.KEY_, onDone);
+ chrome.storage.local.get(remoting.HostSettings.KEY_, onDone);
};
/** @type {string} @private */
diff --git a/remoting/webapp/jscompiler_hacks.js b/remoting/webapp/jscompiler_hacks.js
index c5df2fc..94477a8 100644
--- a/remoting/webapp/jscompiler_hacks.js
+++ b/remoting/webapp/jscompiler_hacks.js
@@ -67,19 +67,45 @@ var WebKitMutationObserver = function(callback) {};
@param {Object} options */
WebKitMutationObserver.prototype.observe = function(element, options) {};
-// TODO(jamiewalch): Flesh this out with the correct type when we're a v2 app.
-/** @type {remoting.MockStorage} */
-remoting.storage.local = null;
-
/** @type {Object} */
chrome.storage = {};
-/** @type {remoting.MockStorage} */
+/** @type {chrome.Storage} */
chrome.storage.local;
-/** @type {remoting.MockStorage} */
+/** @type {chrome.Storage} */
chrome.storage.sync;
+/** @constructor */
+chrome.Storage = function() {};
+
+/**
+ * @param {string|Array.<string>|Object.<string>} items
+ * @param {function(Object.<string>):void} callback
+ * @return {void}
+ */
+chrome.Storage.prototype.get = function(items, callback) {};
+
+/**
+ * @param {Object.<string>} items
+ * @param {function():void=} opt_callback
+ * @return {void}
+ */
+chrome.Storage.prototype.set = function(items, opt_callback) {};
+
+/**
+ * @param {string|Array.<string>} items
+ * @param {function():void=} opt_callback
+ * @return {void}
+ */
+chrome.Storage.prototype.remove = function(items, opt_callback) {};
+
+/**
+ * @param {function():void=} opt_callback
+ * @return {void}
+ */
+chrome.Storage.prototype.clear = function(opt_callback) {};
+
/** @type {Object} */
chrome.app.runtime = {
/** @type {chrome.Event} */
diff --git a/remoting/webapp/main.html b/remoting/webapp/main.html
index a4db8a0..8325732 100644
--- a/remoting/webapp/main.html
+++ b/remoting/webapp/main.html
@@ -45,7 +45,6 @@ found in the LICENSE file.
<script src="server_log_entry.js"></script>
<script src="session_connector.js"></script>
<script src="stats_accumulator.js"></script>
- <script src="storage.js"></script>
<script src="third_party_host_permissions.js"></script>
<script src="third_party_token_fetcher.js"></script>
<script src="toolbar.js"></script>
diff --git a/remoting/webapp/remoting.js b/remoting/webapp/remoting.js
index e3a6b8b..8d97f73 100644
--- a/remoting/webapp/remoting.js
+++ b/remoting/webapp/remoting.js
@@ -35,11 +35,6 @@ function consentRequired_(authContinue) {
*/
remoting.init = function() {
migrateLocalToChromeStorage_();
-
- // TODO(jamiewalch): Remove this when we migrate to apps v2
- // (http://crbug.com/ 134213).
- remoting.initMockStorage();
-
remoting.logExtensionInfo_();
l10n.localize();
// Create global objects.
@@ -236,7 +231,7 @@ remoting.promptClose = function() {
*/
remoting.signOut = function() {
remoting.oauth2.clear();
- remoting.storage.local.clear();
+ chrome.storage.local.clear();
remoting.setMode(remoting.AppMode.HOME);
document.getElementById('auth-dialog').hidden = false;
};
diff --git a/remoting/webapp/storage.js b/remoting/webapp/storage.js
deleted file mode 100644
index 72c3ff6..0000000
--- a/remoting/webapp/storage.js
+++ /dev/null
@@ -1,138 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/**
- * @fileoverview
- * Mock class for Chrome's storage API to aid with the transition to Apps v2.
- *
- * The local storage API is not supported in Apps v2, so we'll have to use
- * the new storage API instead. This doesn't require Apps v2, but it turns
- * out that migrating our OAuth2 code to the new API is non-trivial; since
- * that code will need to be rewritten to be Apps-v2-compatible anyway, a
- * mock seems like a good temporary solution.
- *
- * TODO(jamiewalch): Delete this file when we migrate to apps v2
- * (http://crbug.com/ 134213).
- */
-
-'use strict';
-
-/** @suppress {duplicate} */
-var remoting = remoting || {};
-
-/** @type {Object} */
-remoting.storage = {};
-
-remoting.initMockStorage = function() {
- if (typeof(chrome.storage) != 'undefined') {
- console.warn('If storage.js is no longer needed, consider removing it.');
- remoting.storage.local = chrome.storage.local;
- } else {
- remoting.storage.local = new remoting.MockStorage();
- }
-};
-
-/**
- * @constructor
- */
-remoting.MockStorage = function() {
-};
-
-/** @type {number} Delay for |get|, in ms, to simulate slow local storage
- * and test correct asynchronous behavior. A value of 0 results in
- * synchronous behavior.
- */
-remoting.MockStorage.GET_DELAY = 0;
-
-/**
- * @param {string|Array.<string>|Object.<string>} items
- * @param {function(Object.<string>):void} callback
- * @return {void}
- */
-remoting.MockStorage.prototype.get = function(items, callback) {
- var result = {};
- if (items == null) {
- // Return all items for null input.
- result = window.localStorage;
-
- } else if (typeof(items) == 'string') {
- // If the input is a string, return one or zero items, depending on
- // whether or not the value is stored in localStorage.
- if (window.localStorage.hasOwnProperty(items)) {
- result[items] = window.localStorage.getItem(items);
- }
-
- } else if (items.constructor == Array) {
- // If the input is an array, return those items that have an entry
- // in localStorage.
- for (var index in items) {
- /** @type {string} */
- var item = items[index];
- if (window.localStorage.hasOwnProperty(item)) {
- result[item] = window.localStorage.getItem(item);
- }
- }
-
- } else {
- // If the input is a dictionary, return the localStorage value for
- // items that are stored, and the dictionary value otherwise.
- for (var item in items) {
- if (window.localStorage.hasOwnProperty(item)) {
- result[item] = window.localStorage.getItem(item);
- } else {
- result[item] = items[item];
- }
- }
- }
-
- if (remoting.MockStorage.GET_DELAY == 0) {
- callback(result);
- } else {
- window.setTimeout(callback.bind(null, result),
- remoting.MockStorage.GET_DELAY);
- }
-};
-
-/**
- * @param {Object.<string>} items
- * @param {function():void=} opt_callback
- * @return {void}
- */
-remoting.MockStorage.prototype.set = function(items, opt_callback) {
- for (var item in items) {
- window.localStorage.setItem(item, items[item]);
- }
- if (opt_callback) {
- opt_callback();
- }
-};
-
-/**
- * @param {string|Array.<string>} items
- * @param {function():void=} opt_callback
- * @return {void}
- */
-remoting.MockStorage.prototype.remove = function(items, opt_callback) {
- if (typeof(items) == 'string') {
- window.localStorage.removeItem(items);
- } else if (items.constructor == Array) {
- for (var index in items) {
- window.localStorage.removeItem(items[index]);
- }
- }
- if (opt_callback) {
- opt_callback();
- }
-};
-
-/**
- * @param {function():void=} opt_callback
- * @return {void}
- */
-remoting.MockStorage.prototype.clear = function(opt_callback) {
- window.localStorage.clear();
- if (opt_callback) {
- opt_callback();
- }
-}; \ No newline at end of file
diff --git a/remoting/webapp/ui_mode.js b/remoting/webapp/ui_mode.js
index c8d3c5c..0a425fc 100644
--- a/remoting/webapp/ui_mode.js
+++ b/remoting/webapp/ui_mode.js
@@ -157,32 +157,32 @@ remoting.showOrHideCallback = function(mode, items) {
};
remoting.showOrHideIT2MeUi = function() {
- remoting.storage.local.get(remoting.kIT2MeVisitedStorageKey,
- remoting.showOrHideCallback.bind(null, 'it2me'));
+ chrome.storage.local.get(remoting.kIT2MeVisitedStorageKey,
+ remoting.showOrHideCallback.bind(null, 'it2me'));
};
remoting.showOrHideMe2MeUi = function() {
- remoting.storage.local.get(remoting.kMe2MeVisitedStorageKey,
- remoting.showOrHideCallback.bind(null, 'me2me'));
+ chrome.storage.local.get(remoting.kMe2MeVisitedStorageKey,
+ remoting.showOrHideCallback.bind(null, 'me2me'));
};
remoting.showIT2MeUiAndSave = function() {
var items = {};
items[remoting.kIT2MeVisitedStorageKey] = true;
- remoting.storage.local.set(items);
+ chrome.storage.local.set(items);
remoting.showOrHideCallback('it2me', [true]);
};
remoting.showMe2MeUiAndSave = function() {
var items = {};
items[remoting.kMe2MeVisitedStorageKey] = true;
- remoting.storage.local.set(items);
+ chrome.storage.local.set(items);
remoting.showOrHideCallback('me2me', [true]);
};
remoting.resetInfographics = function() {
- remoting.storage.local.remove(remoting.kIT2MeVisitedStorageKey);
- remoting.storage.local.remove(remoting.kMe2MeVisitedStorageKey);
+ chrome.storage.local.remove(remoting.kIT2MeVisitedStorageKey);
+ chrome.storage.local.remove(remoting.kMe2MeVisitedStorageKey);
remoting.showOrHideCallback('it2me', [false]);
remoting.showOrHideCallback('me2me', [false]);
}