summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-11 17:57:02 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-11 17:57:02 +0000
commitaa1cc2168edaa8db23bd201485b12f61648f3275 (patch)
tree9c7de6a7d794f79d52dcd641a57149cd4fc5e419 /remoting
parent82d7c2e9709a4624c08b451bed9625218ab4fb5c (diff)
downloadchromium_src-aa1cc2168edaa8db23bd201485b12f61648f3275.zip
chromium_src-aa1cc2168edaa8db23bd201485b12f61648f3275.tar.gz
chromium_src-aa1cc2168edaa8db23bd201485b12f61648f3275.tar.bz2
Add in simple local state storage functions, and a rudimentary auth panel.
BUG=none TEST=none Review URL: http://codereview.chromium.org/7002018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85000 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/webapp/me2mom/background.html19
-rw-r--r--remoting/webapp/me2mom/choice.html11
-rw-r--r--remoting/webapp/me2mom/manifest.json1
-rw-r--r--remoting/webapp/me2mom/remoting.js31
4 files changed, 57 insertions, 5 deletions
diff --git a/remoting/webapp/me2mom/background.html b/remoting/webapp/me2mom/background.html
new file mode 100644
index 0000000..216f22e
--- /dev/null
+++ b/remoting/webapp/me2mom/background.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<!--
+Copyright (c) 2011 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.
+-->
+<html>
+ <script type="text/javascript">
+ function setItem(key, value) {
+ window.localStorage.setItem(key, value);
+ }
+ function getItem(key) {
+ return window.localStorage.getItem(key);
+ }
+ function clearAll() {
+ window.localStorage.clear();
+ }
+ </script>
+</html>
diff --git a/remoting/webapp/me2mom/choice.html b/remoting/webapp/me2mom/choice.html
index 49abf80..9d550a3 100644
--- a/remoting/webapp/me2mom/choice.html
+++ b/remoting/webapp/me2mom/choice.html
@@ -15,6 +15,17 @@ found in the LICENSE file.
<body onload="init();">
+ <!-- Auth panel -->
+ <div id="auth_panel">
+ <form action="">
+ XMPP Token: <input type="text" id="xmpp_token" /><br />
+ OAuth2 Token: <input type="text" id="oauth2_token" /><br />
+ <button onclick="saveCredentials(this.form);">
+ Save Credentials
+ </button>
+ </form>
+ </div>
+
<!-- Host UI -->
<div id="host">
diff --git a/remoting/webapp/me2mom/manifest.json b/remoting/webapp/me2mom/manifest.json
index c12e141..beed1eb 100644
--- a/remoting/webapp/me2mom/manifest.json
+++ b/remoting/webapp/me2mom/manifest.json
@@ -7,6 +7,7 @@
"local_path": "choice.html"
}
},
+ "background_page": "background.html",
"icons": {
"128": "chromoting128.png"
},
diff --git a/remoting/webapp/me2mom/remoting.js b/remoting/webapp/me2mom/remoting.js
index e01b1ed..72a3b70 100644
--- a/remoting/webapp/me2mom/remoting.js
+++ b/remoting/webapp/me2mom/remoting.js
@@ -3,15 +3,36 @@
// found in the LICENSE file.
var chromoting = {};
+XMPP_TOKEN_NAME = 'xmpp_token';
+OAUTH2_TOKEN_NAME = 'oauth2_token';
+
+function initAuthPanel_() {
+ document.getElementById('oauth2_token').value =
+ chromoting.getItem(OAUTH2_TOKEN_NAME);
+ document.getElementById('xmpp_token').value =
+ chromoting.getItem(XMPP_TOKEN_NAME);
+}
+
+function initBackgroundFuncs_() {
+ chromoting.getItem = chrome.extension.getBackgroundPage().getItem;
+ chromoting.setItem = chrome.extension.getBackgroundPage().setItem;
+}
+
+function saveCredentials(form) {
+ chromoting.setItem(OAUTH2_TOKEN_NAME, form['oauth2_token'].value);
+ chromoting.setItem(XMPP_TOKEN_NAME, form['xmpp_token'].value);
+}
function init() {
+ initBackgroundFuncs_();
+ initAuthPanel_();
setHostMode('unshared');
setClientMode('unconnected');
setGlobalMode('host'); // TODO(jamiewalch): Make the initial mode sticky.
}
// Show the div with id |mode| and hide those with other ids in |modes|.
-function setMode(mode, modes) {
+function setMode_(mode, modes) {
for (var i = 0; i < modes.length; ++i) {
var div = document.getElementById(modes[i]);
if (mode == modes[i]) {
@@ -23,15 +44,15 @@ function setMode(mode, modes) {
}
function setGlobalMode(mode) {
- setMode(mode, ['host', 'client', 'session']);
+ setMode_(mode, ['host', 'client', 'session']);
}
function setHostMode(mode) {
- setMode(mode, ['unshared', 'ready_to_share', 'shared']);
+ setMode_(mode, ['unshared', 'ready_to_share', 'shared']);
}
function setClientMode(mode) {
- setMode(mode, ['unconnected', 'connecting']);
+ setMode_(mode, ['unconnected', 'connecting']);
}
function tryShare() {
@@ -49,7 +70,7 @@ function cancelShare() {
}
function tryConnect(form) {
- chromoting.accessCode = form.access_code_entry.value;
+ chromoting.accessCode = form['access_code_entry'].value;
setClientMode('connecting');
chromoting.clientTimer = setTimeout(
function() {