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

Side by Side Diff: remoting/webapp/me2mom/remoting.js

Issue 7016001: Simple OAuth1 implementation based on http://code.google.com/chrome/extensions/tut_oauth.html. (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var chromoting = {}; 5 var chromoting = {};
6 XMPP_TOKEN_NAME = 'xmpp_token'; 6 XMPP_TOKEN_NAME = 'xmpp_token';
7 OAUTH2_TOKEN_NAME = 'oauth2_token'; 7 OAUTH2_TOKEN_NAME = 'oauth2_token';
8 8
9 function updateAuthStatus() {
10 var oauth1_status = document.getElementById('oauth1_status');
11 if (chromoting.oauth.hasToken()) {
12 oauth1_status.innerText = 'OK';
13 oauth1_status.style.color='green';
14 } else {
15 oauth1_status.innerText = 'Unauthorized';
16 oauth1_status.style.color='red';
17 }
18 }
19
20 function authorizeOAuth1() {
21 chromoting.oauth.authorize(updateAuthStatus);
22 }
23
24 function clearOAuth1() {
25 chromoting.oauth.clearTokens();
26 updateAuthStatus();
27 }
28
9 function initAuthPanel_() { 29 function initAuthPanel_() {
10 document.getElementById('oauth2_token').value =
11 chromoting.getItem(OAUTH2_TOKEN_NAME);
12 document.getElementById('xmpp_token').value = 30 document.getElementById('xmpp_token').value =
13 chromoting.getItem(XMPP_TOKEN_NAME); 31 chromoting.getItem(XMPP_TOKEN_NAME);
32 updateAuthStatus();
14 } 33 }
15 34
16 function initBackgroundFuncs_() { 35 function initBackgroundFuncs_() {
17 chromoting.getItem = chrome.extension.getBackgroundPage().getItem; 36 chromoting.getItem = chrome.extension.getBackgroundPage().getItem;
18 chromoting.setItem = chrome.extension.getBackgroundPage().setItem; 37 chromoting.setItem = chrome.extension.getBackgroundPage().setItem;
38 chromoting.oauth = chrome.extension.getBackgroundPage().oauth;
19 } 39 }
20 40
21 function saveCredentials(form) { 41 function saveCredentials(form) {
22 chromoting.setItem(OAUTH2_TOKEN_NAME, form['oauth2_token'].value); 42 chromoting.setItem(OAUTH2_TOKEN_NAME, form['oauth2_token'].value);
23 chromoting.setItem(XMPP_TOKEN_NAME, form['xmpp_token'].value); 43 chromoting.setItem(XMPP_TOKEN_NAME, form['xmpp_token'].value);
24 } 44 }
25 45
26 function init() { 46 function init() {
27 initBackgroundFuncs_(); 47 initBackgroundFuncs_();
28 initAuthPanel_(); 48 initAuthPanel_();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 setGlobalMode('session'); 99 setGlobalMode('session');
80 }, 100 },
81 3000); 101 3000);
82 } 102 }
83 103
84 function cancelConnect() { 104 function cancelConnect() {
85 chromoting.accessCode = ''; 105 chromoting.accessCode = '';
86 setClientMode('unconnected'); 106 setClientMode('unconnected');
87 clearTimeout(chromoting.clientTimer); 107 clearTimeout(chromoting.clientTimer);
88 } 108 }
OLDNEW
« remoting/webapp/me2mom/chrome_ex_oauthsimple.js ('K') | « remoting/webapp/me2mom/manifest.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698