Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(583)

Unified Diff: remoting/webapp/me2mom/remoting.js

Issue 7008003: Wire in OAuth2 support into non-sandboxed connections in libjingle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/webapp/me2mom/remoting.js
diff --git a/remoting/webapp/me2mom/remoting.js b/remoting/webapp/me2mom/remoting.js
index 76dd63f224e77c4ba8ad677f66402677b95c11a6..adc0638209e2e764a64a88c6165f06710fc7978f 100644
--- a/remoting/webapp/me2mom/remoting.js
+++ b/remoting/webapp/me2mom/remoting.js
@@ -31,13 +31,20 @@ function updateAuthStatus_() {
document.getElementById('xmpp_form').style.display = 'none';
xmpp_status.innerText = 'OK';
xmpp_status.style.color = 'green';
- remoting.xmppAuthToken = remoting.getItem(XMPP_TOKEN_NAME);
} else {
document.getElementById('xmpp_clear').style.display = 'none';
document.getElementById('xmpp_form').style.display = 'inline';
xmpp_status.innerText = 'Unauthorized';
xmpp_status.style.color = 'red';
}
+ var current_email = document.getElementById('current_email');
+ if (remoting.getItem(XMPP_LOGIN_NAME)) {
Wez 2011/05/25 03:57:46 It's a bit confusing that XMPP_LOGIN_NAME contains
awong 2011/05/25 16:56:56 Yes...I'm not going to change this for now. We're
+ oauth2_status.style.color = 'green';
+ current_email.innerText = remoting.getItem(XMPP_LOGIN_NAME);
+ } else {
+ oauth2_status.style.color = 'red';
+ current_email.innerText = 'missing e-mail';
+ }
}
function clientLoginError_(xhr) {
@@ -139,6 +146,11 @@ function authorizeXmpp(form) {
xhr.send(post_data);
}
+function setEmail(form) {
+ remoting.setItem(XMPP_LOGIN_NAME, form['new_email'].value);
+ updateAuthStatus_();
+}
+
function authorizeOAuth2(code) {
remoting.oauth2.exchangeCodeForToken(code, updateAuthStatus_);
}
@@ -194,6 +206,11 @@ function setClientMode(mode) {
}
function tryShare() {
+ if (remoting.oauth2.needsNewAccessToken()) {
+ remoting.oauth2.refreshAccessToken(tryShare);
+ return;
+ }
+
var div = document.getElementById('plugin_wrapper');
var plugin = document.createElement('embed');
plugin.setAttribute('type', 'HOST_PLUGIN_MIMETYPE');
@@ -202,7 +219,7 @@ function tryShare() {
div.appendChild(plugin);
plugin.onStateChanged = onStateChanged_;
plugin.connect(remoting.getItem(XMPP_LOGIN_NAME),
- remoting.getItem(XMPP_TOKEN_NAME));
+ 'oauth2:' + remoting.oauth2.getAccessToken());
}
function onStateChanged_() {
@@ -287,8 +304,15 @@ function resolveSupportId(support_id) {
xhr.send(null);
}
-function tryConnect(form) {
- remoting.accessCode = normalizeAccessCode(form['access_code_entry'].value);
+function tryConnect(accessCode) {
+ if (remoting.oauth2.needsNewAccessToken()) {
+ remoting.oauth2.refreshAccessToken(function() {
+ tryConnect(accessCode);
Wez 2011/05/25 03:57:46 Is there any possibility of this getting stuck in
awong 2011/05/25 17:07:31 Good point. Added simple break for now.
+ });
+ return;
+ }
+
+ remoting.accessCode = accessCode;
// TODO(jamiewalch): Since the mapping from (SupportId, HostSecret) to
// AccessCode is not yet defined, assume it's hyphen-separated for now.
var parts = remoting.accessCode.split('-');
@@ -296,14 +320,7 @@ function tryConnect(form) {
showConnectError_(404);
} else {
setClientMode('connecting');
- if (remoting.oauth2.needsNewAccessToken()) {
- remoting.oauth2.refreshAccessToken(function() {
- resolveSupportId(parts[0]);
- });
- return;
- } else {
- resolveSupportId(parts[0]);
- }
+ resolveSupportId(parts[0]);
}
}

Powered by Google App Engine
This is Rietveld 408576698