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

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: copyright + rebase 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
« no previous file with comments | « remoting/webapp/me2mom/choice.html ('k') | remoting/webapp/me2mom/remoting_session.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/me2mom/remoting.js
diff --git a/remoting/webapp/me2mom/remoting.js b/remoting/webapp/me2mom/remoting.js
index 76dd63f224e77c4ba8ad677f66402677b95c11a6..7b1adde5664331059037091d671a2cf2db79c05c 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)) {
+ 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,17 @@ function setClientMode(mode) {
}
function tryShare() {
+ if (remoting.oauth2.needsNewAccessToken()) {
+ remoting.oauth2.refreshAccessToken(function() {
+ if (remoting.oauth2.needsNewAccessToken()) {
+ // If we still need it, we're going to infinite loop.
+ throw "Unable to get access token";
+ }
+ tryShare();
+ });
+ return;
+ }
+
var div = document.getElementById('plugin_wrapper');
var plugin = document.createElement('embed');
plugin.setAttribute('type', 'HOST_PLUGIN_MIMETYPE');
@@ -202,7 +225,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 +310,19 @@ 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() {
+ if (remoting.oauth2.needsNewAccessToken()) {
+ // If we still need it, we're going to infinite loop.
+ throw "Unable to get access token";
+ }
+ tryConnect(accessCode);
+ });
+ 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 +330,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]);
}
}
« no previous file with comments | « remoting/webapp/me2mom/choice.html ('k') | remoting/webapp/me2mom/remoting_session.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698