summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-06 19:44:31 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-06 19:44:31 +0000
commitf6cff51e79687f3203fdd06d1ea0103aa43d7723 (patch)
tree768602331b58b74adcab9ccc89aa70394464e988
parent0233bf2a7059f6f24db9705be5ac61128a4b86c0 (diff)
downloadchromium_src-f6cff51e79687f3203fdd06d1ea0103aa43d7723.zip
chromium_src-f6cff51e79687f3203fdd06d1ea0103aa43d7723.tar.gz
chromium_src-f6cff51e79687f3203fdd06d1ea0103aa43d7723.tar.bz2
Ask for PIN when connecting to Me2Me hosts and pass it to the plugin.
BUG=105214 Review URL: http://codereview.chromium.org/9116032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116718 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--remoting/client/chromoting_client.cc4
-rw-r--r--remoting/client/client_config.h4
-rw-r--r--remoting/client/plugin/chromoting_scriptable_object.cc14
-rw-r--r--remoting/webapp/me2mom/_locales/en/messages.json4
-rw-r--r--remoting/webapp/me2mom/choice.html19
-rw-r--r--remoting/webapp/me2mom/client_screen.js39
-rw-r--r--remoting/webapp/me2mom/client_session.js13
-rw-r--r--remoting/webapp/me2mom/event_handlers.js10
-rw-r--r--remoting/webapp/me2mom/ui_mode.js3
-rw-r--r--remoting/webapp/me2mom/viewer_plugin_proto.js7
10 files changed, 83 insertions, 34 deletions
diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc
index 6f10746..0577ac5 100644
--- a/remoting/client/chromoting_client.cc
+++ b/remoting/client/chromoting_client.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -45,7 +45,7 @@ void ChromotingClient::Start(scoped_refptr<XmppProxy> xmpp_proxy) {
DCHECK(message_loop()->BelongsToCurrentThread());
connection_->Connect(xmpp_proxy, config_.local_jid, config_.host_jid,
- config_.host_public_key, config_.access_code,
+ config_.host_public_key, config_.authentication_code,
this, this, this);
if (!view_->Initialize()) {
diff --git a/remoting/client/client_config.h b/remoting/client/client_config.h
index c2ce82b..52b8e34 100644
--- a/remoting/client/client_config.h
+++ b/remoting/client/client_config.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -20,7 +20,7 @@ struct ClientConfig {
std::string host_jid;
std::string host_public_key;
- std::string access_code;
+ std::string authentication_code;
};
} // namespace remoting
diff --git a/remoting/client/plugin/chromoting_scriptable_object.cc b/remoting/client/plugin/chromoting_scriptable_object.cc
index 1185570..0cbfe4c 100644
--- a/remoting/client/plugin/chromoting_scriptable_object.cc
+++ b/remoting/client/plugin/chromoting_scriptable_object.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -358,7 +358,7 @@ Var ChromotingScriptableObject::DoConnect(const std::vector<Var>& args,
// host_jid
// host_public_key
// client_jid
- // access_code (optional)
+ // authentication_code (optional)
unsigned int arg = 0;
if (!args[arg].is_string()) {
*exception = Var("The host_jid must be a string.");
@@ -378,13 +378,13 @@ Var ChromotingScriptableObject::DoConnect(const std::vector<Var>& args,
}
std::string client_jid = args[arg++].AsString();
- std::string access_code;
+ std::string authentication_code;
if (args.size() > arg) {
if (!args[arg].is_string()) {
- *exception = Var("The access code must be a string.");
+ *exception = Var("The authentication code must be a string.");
return Var();
}
- access_code = args[arg++].AsString();
+ authentication_code = args[arg++].AsString();
}
if (args.size() != arg) {
@@ -394,12 +394,12 @@ Var ChromotingScriptableObject::DoConnect(const std::vector<Var>& args,
VLOG(1) << "Connecting to host. "
<< "client_jid: " << client_jid << ", host_jid: " << host_jid
- << ", access_code: " << access_code;
+ << ", authentication_code: " << authentication_code;
ClientConfig config;
config.local_jid = client_jid;
config.host_jid = host_jid;
config.host_public_key = host_public_key;
- config.access_code = access_code;
+ config.authentication_code = authentication_code;
instance_->Connect(config);
return Var();
diff --git a/remoting/webapp/me2mom/_locales/en/messages.json b/remoting/webapp/me2mom/_locales/en/messages.json
index f75480f..fa9613d 100644
--- a/remoting/webapp/me2mom/_locales/en/messages.json
+++ b/remoting/webapp/me2mom/_locales/en/messages.json
@@ -197,6 +197,10 @@
"message": "Offline",
"description": "Label indicating that a host in the list is not currently available for remote access."
},
+ "PIN": {
+ "message": "PIN",
+ "description": "Label for the PIN entry box."
+ },
"PRODUCT_DESCRIPTION": {
"message": "Access other computers or allow another user to access your computer securely over the Internet.",
"description": "Web-app description. Displayed in Chromium's extensions page."
diff --git a/remoting/webapp/me2mom/choice.html b/remoting/webapp/me2mom/choice.html
index 9ff1a5e..270896d 100644
--- a/remoting/webapp/me2mom/choice.html
+++ b/remoting/webapp/me2mom/choice.html
@@ -1,6 +1,6 @@
<!doctype html>
<!--
-Copyright (c) 2011 The Chromium Authors. All rights reserved.
+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.
-->
@@ -244,6 +244,23 @@ found in the LICENSE file.
i18n-content="MESSAGE_CONNECTING">
</div> <!-- client.connecting -->
+ <div data-ui-mode="client.pin-prompt" class="message">
+ <div>
+ <form id="pin-form" action="">
+ <label for="pin-entry" i18n-content="PIN"></label>
+ <input id="pin-entry"
+ type="password"
+ autofocus="autofocus"
+ autocomplete="off"/>
+ <button id="connect-button"
+ class="big-button"
+ type="submit"
+ i18n-content="CONNECT_BUTTON">
+ </button>
+ </form>
+ </div>
+ </div> <!-- client.pin-prompt -->
+
<div data-ui-mode="client.connect-failed"
class="message">
<span id="connect-error-message" class="error-state"></span>
diff --git a/remoting/webapp/me2mom/client_screen.js b/remoting/webapp/me2mom/client_screen.js
index b7e2824..c130247 100644
--- a/remoting/webapp/me2mom/client_screen.js
+++ b/remoting/webapp/me2mom/client_screen.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -34,12 +34,17 @@ remoting.accessCode = '';
remoting.hostJid = '';
/**
- * @type {string} For Me2Me connections, the id of the current host, used when
- * (re-)connecting, as the JID may have changed.
+ * @type {string} For Me2Me connections, the id of the current host.
*/
remoting.hostId = '';
/**
+ * @type {boolean} For Me2Me connections. Set to true if connection
+ * must be retried on failure.
+ */
+remoting.retryIfOffline = false;
+
+/**
* @type {string} The host's public key, returned by the server.
*/
remoting.hostPublicKey = '';
@@ -283,7 +288,7 @@ function onClientStateChange_(oldState, newState) {
* @return {void} Nothing.
*/
function retryConnectOrReportOffline_() {
- if (remoting.hostId) {
+ if (remoting.hostId && remoting.retryIfOffline) {
console.log('Connection failed. Retrying.');
/** @param {boolean} success True if the refresh was successful. */
var onDone = function(success) {
@@ -428,7 +433,7 @@ function updateStatistics_() {
/**
- * Start a connection to the specified host, using the cached details.
+ * Shows PIN entry screen.
*
* @param {string} hostId The unique id of the host.
* @param {boolean} retryIfOffline If true and the host can't be contacted,
@@ -437,14 +442,24 @@ function updateStatistics_() {
* @return {void} Nothing.
*/
remoting.connectHost = function(hostId, retryIfOffline) {
- remoting.debug.log('Connecting to host...');
remoting.currentConnectionType = remoting.ConnectionType.Me2Me;
+ remoting.hostId = hostId;
+ remoting.retryIfOffline = retryIfOffline;
+
+ remoting.setMode(remoting.AppMode.CLIENT_PIN_PROMPT);
+}
- // Storing the hostId indicates that it should be retried on failure.
- remoting.hostId = retryIfOffline ? hostId : '';
+/**
+ * Start a connection to the specified host, using the cached details
+ * and the PIN entered by the user.
+ *
+ * @return {void} Nothing.
+ */
+remoting.connectHostWithPin = function() {
+ remoting.debug.log('Connecting to host...');
remoting.setMode(remoting.AppMode.CLIENT_CONNECTING);
- var host = remoting.hostList.getHostForId(hostId);
+ var host = remoting.hostList.getHostForId(remoting.hostId);
if (!host) {
retryConnectOrReportOffline_();
return;
@@ -470,10 +485,14 @@ remoting.connectHost = function(hostId, retryIfOffline) {
* @return {void} Nothing.
*/
remoting.connectHostWithWcs = function() {
+ /** @type {string} */
+ var pin = document.getElementById('pin-entry').value;
+ document.getElementById('pin-entry').value = '';
+
remoting.clientSession =
new remoting.ClientSession(
remoting.hostJid, remoting.hostPublicKey,
- '', /** @type {string} */ (remoting.oauth2.getCachedEmail()),
+ pin, /** @type {string} */ (remoting.oauth2.getCachedEmail()),
onClientStateChange_);
/** @param {string} token The auth token. */
var createPluginAndConnect = function(token) {
diff --git a/remoting/webapp/me2mom/client_session.js b/remoting/webapp/me2mom/client_session.js
index a63f9fe..da57018 100644
--- a/remoting/webapp/me2mom/client_session.js
+++ b/remoting/webapp/me2mom/client_session.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -20,20 +20,21 @@ var remoting = remoting || {};
* @param {string} hostJid The jid of the host to connect to.
* @param {string} hostPublicKey The base64 encoded version of the host's
* public key.
- * @param {string} accessCode The access code for the IT2Me connection.
+ * @param {string} authenticationCode The access code for IT2Me or the
+ * PIN for Me2Me.
* @param {string} email The username for the talk network.
* @param {function(remoting.ClientSession.State,
remoting.ClientSession.State):void} onStateChange
* The callback to invoke when the session changes state.
* @constructor
*/
-remoting.ClientSession = function(hostJid, hostPublicKey, accessCode, email,
- onStateChange) {
+remoting.ClientSession = function(hostJid, hostPublicKey, authenticationCode,
+ email, onStateChange) {
this.state = remoting.ClientSession.State.CREATED;
this.hostJid = hostJid;
this.hostPublicKey = hostPublicKey;
- this.accessCode = accessCode;
+ this.authenticationCode = authenticationCode;
this.email = email;
this.clientJid = '';
this.sessionId = '';
@@ -316,7 +317,7 @@ remoting.ClientSession.prototype.connectPluginToWcs_ =
}
remoting.wcs.setOnIq(onIq);
that.plugin.connect(this.hostJid, this.hostPublicKey, this.clientJid,
- this.accessCode);
+ this.authenticationCode);
};
/**
diff --git a/remoting/webapp/me2mom/event_handlers.js b/remoting/webapp/me2mom/event_handlers.js
index e39a924..2baf133 100644
--- a/remoting/webapp/me2mom/event_handlers.js
+++ b/remoting/webapp/me2mom/event_handlers.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -19,6 +19,11 @@ function onLoad() {
remoting.tryConnect();
event.preventDefault();
};
+ /** @param {Event} event */
+ var connectHostWithPin = function(event) {
+ remoting.connectHostWithPin();
+ event.preventDefault();
+ };
var doAuthRedirect = function() {
remoting.oauth2.doAuthRedirect();
}
@@ -36,7 +41,8 @@ function onLoad() {
{ event: 'click', id: 'client-finished-button', fn: goClient },
{ event: 'click', id: 'cancel-button',
fn: remoting.cancelPendingOperation },
- { event: 'submit', id: 'access-code-form', fn: sendAccessCode }
+ { event: 'submit', id: 'access-code-form', fn: sendAccessCode },
+ { event: 'submit', id: 'pin-form', fn: connectHostWithPin }
];
for (var i = 0; i < actions.length; ++i) {
diff --git a/remoting/webapp/me2mom/ui_mode.js b/remoting/webapp/me2mom/ui_mode.js
index 4c19091..da0253c 100644
--- a/remoting/webapp/me2mom/ui_mode.js
+++ b/remoting/webapp/me2mom/ui_mode.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -18,6 +18,7 @@ remoting.AppMode = {
UNAUTHENTICATED: 'auth',
CLIENT: 'client',
CLIENT_UNCONNECTED: 'client.unconnected',
+ CLIENT_PIN_PROMPT: 'client.pin-prompt',
CLIENT_CONNECTING: 'client.connecting',
CLIENT_CONNECT_FAILED_IT2ME: 'client.connect-failed.it2me',
CLIENT_CONNECT_FAILED_ME2ME: 'client.connect-failed.me2me',
diff --git a/remoting/webapp/me2mom/viewer_plugin_proto.js b/remoting/webapp/me2mom/viewer_plugin_proto.js
index d480d17..18d6461 100644
--- a/remoting/webapp/me2mom/viewer_plugin_proto.js
+++ b/remoting/webapp/me2mom/viewer_plugin_proto.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -26,11 +26,12 @@ remoting.ViewerPlugin.prototype.releaseAllKeys = function() {};
* @param {string} hostJid The host's JID.
* @param {string} hostPublicKey The host's public key.
* @param {string} clientJid The client's JID.
- * @param {string} accessCode The access code.
+ * @param {string} authenticationCode The access code for IT2Me or the
+ * PIN for Me2Me.
* @return {void} Nothing.
*/
remoting.ViewerPlugin.prototype.connect =
- function(hostJid, hostPublicKey, clientJid, accessCode) {};
+ function(hostJid, hostPublicKey, clientJid, authenticationCode) {};
/** @type {function(number, number): void} State change callback function. */
remoting.ViewerPlugin.prototype.connectionInfoUpdate;