OLD | NEW |
---|---|
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 remoting = remoting || {}; | 5 var remoting = remoting || {}; |
6 | 6 |
7 (function() { | 7 (function() { |
8 'use strict'; | 8 'use strict'; |
9 | 9 |
10 window.addEventListener('blur', pluginLostFocus_, false); | 10 window.addEventListener('blur', pluginLostFocus_, false); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
143 remoting.init = function() { | 143 remoting.init = function() { |
144 l10n.localize(); | 144 l10n.localize(); |
145 // Create global objects. | 145 // Create global objects. |
146 remoting.oauth2 = new remoting.OAuth2(); | 146 remoting.oauth2 = new remoting.OAuth2(); |
147 remoting.debug = | 147 remoting.debug = |
148 new remoting.DebugLog(document.getElementById('debug-messages')); | 148 new remoting.DebugLog(document.getElementById('debug-messages')); |
149 | 149 |
150 // Process OAuth redirection | |
151 if (window.location.search) { | |
152 var parts = window.location.search.substring(1).split('&'); | |
153 var queryArgs = {}; | |
154 for (var i = 0; i < parts.length; i++) { | |
155 var pair = parts[i].split('='); | |
156 queryArgs[pair[0]] = pair[1]; | |
157 } | |
158 // If this an OAuth2 redirect, then strip the parameters from the URL | |
159 // to prevent them getting stored in bookmarks. | |
160 if ('code' in queryArgs) { | |
161 remoting.oauth2.exchangeCodeForToken(queryArgs['code'], function() { | |
162 window.location.replace(chrome.extension.getURL('choice.html')); | |
163 }); | |
164 return; | |
165 } else if ('error' in queryArgs) { | |
166 window.location.replace(chrome.extension.getURL('choice.html')); | |
167 return; | |
Jamie
2011/08/04 21:56:16
Does location.replace automatically terminate the
awong
2011/08/04 22:42:36
I think it does go immediately, but the return sti
| |
168 } | |
169 } | |
170 | |
150 refreshEmail_(); | 171 refreshEmail_(); |
151 var email = getEmail(); | 172 var email = getEmail(); |
152 if (email) { | 173 if (email) { |
153 document.getElementById('current-email').innerText = email; | 174 document.getElementById('current-email').innerText = email; |
154 } | 175 } |
155 remoting.setMode(getAppStartupMode()); | 176 remoting.setMode(getAppStartupMode()); |
156 if (isHostModeSupported()) { | 177 if (isHostModeSupported()) { |
157 var unsupported = document.getElementById('client-footer-text-cros'); | 178 var unsupported = document.getElementById('client-footer-text-cros'); |
158 unsupported.parentNode.removeChild(unsupported); | 179 unsupported.parentNode.removeChild(unsupported); |
159 } else { | 180 } else { |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
584 remoting.disconnect = function() { | 605 remoting.disconnect = function() { |
585 if (remoting.session) { | 606 if (remoting.session) { |
586 remoting.session.disconnect(); | 607 remoting.session.disconnect(); |
587 remoting.session = null; | 608 remoting.session = null; |
588 remoting.debug.log('Disconnected.'); | 609 remoting.debug.log('Disconnected.'); |
589 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED); | 610 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED); |
590 } | 611 } |
591 } | 612 } |
592 | 613 |
593 }()); | 614 }()); |
OLD | NEW |