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

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

Issue 7108007: Add basic debug log to host page. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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
« no previous file with comments | « remoting/webapp/me2mom/debug_log.js ('k') | remoting/webapp/me2mom/remoting_session.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // TODO(jamiewalch): strict mode causes the page to crash so it's disabled for 5 // TODO(jamiewalch): strict mode causes the page to crash so it's disabled for
6 // now. Reinstate this when the associated bug is fixed. 6 // now. Reinstate this when the associated bug is fixed.
7 // http://code.google.com/p/v8/issues/detail?id=1423 7 // http://code.google.com/p/v8/issues/detail?id=1423
8 //"use strict"; 8 //"use strict";
9 9
10 // TODO(ajwong): This seems like a bad idea to share the exact same object 10 // TODO(ajwong): This seems like a bad idea to share the exact same object
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 } 150 }
151 151
152 function setGlobalModePersistent(mode) { 152 function setGlobalModePersistent(mode) {
153 setGlobalMode(mode); 153 setGlobalMode(mode);
154 remoting.setItem('startup-mode', mode); 154 remoting.setItem('startup-mode', mode);
155 } 155 }
156 156
157 function setHostMode(mode) { 157 function setHostMode(mode) {
158 var section = document.getElementById('host-section'); 158 var section = document.getElementById('host-section');
159 var modes = section.getElementsByClassName('mode'); 159 var modes = section.getElementsByClassName('mode');
160 addToDebugLog('Host mode: ' + mode);
160 setMode_(mode, modes); 161 setMode_(mode, modes);
161 } 162 }
162 163
163 function setClientMode(mode) { 164 function setClientMode(mode) {
164 var section = document.getElementById('client-section'); 165 var section = document.getElementById('client-section');
165 var modes = section.getElementsByClassName('mode'); 166 var modes = section.getElementsByClassName('mode');
167 addToDebugLog('Client mode: ' + mode);
166 setMode_(mode, modes); 168 setMode_(mode, modes);
167 } 169 }
168 170
169 function tryShare() { 171 function tryShare() {
172 addToDebugLog("Attempting to share...");
170 if (remoting.oauth2.needsNewAccessToken()) { 173 if (remoting.oauth2.needsNewAccessToken()) {
174 addToDebugLog("Refreshing token...");
171 remoting.oauth2.refreshAccessToken(function() { 175 remoting.oauth2.refreshAccessToken(function() {
172 if (remoting.oauth2.needsNewAccessToken()) { 176 if (remoting.oauth2.needsNewAccessToken()) {
173 // If we still need it, we're going to infinite loop. 177 // If we still need it, we're going to infinite loop.
178 addToDebugLog("Unable to get access token");
174 throw "Unable to get access token"; 179 throw "Unable to get access token";
175 } 180 }
176 tryShare(); 181 tryShare();
177 }); 182 });
178 return; 183 return;
179 } 184 }
180 185
181 var div = document.getElementById('plugin-wrapper'); 186 var div = document.getElementById('plugin-wrapper');
182 var plugin = document.createElement('embed'); 187 var plugin = document.createElement('embed');
183 plugin.setAttribute('type', remoting.PLUGIN_MIMETYPE); 188 plugin.setAttribute('type', remoting.PLUGIN_MIMETYPE);
(...skipping 14 matching lines...) Expand all
198 var accessCode = plugin.accessCode; 203 var accessCode = plugin.accessCode;
199 var accessCodeDisplay = document.getElementById('access-code-display'); 204 var accessCodeDisplay = document.getElementById('access-code-display');
200 accessCodeDisplay.innerText = accessCode; 205 accessCodeDisplay.innerText = accessCode;
201 setHostMode('ready-to-share'); 206 setHostMode('ready-to-share');
202 } else if (state == plugin.CONNECTED) { 207 } else if (state == plugin.CONNECTED) {
203 setHostMode('shared'); 208 setHostMode('shared');
204 } else if (state == plugin.DISCONNECTED) { 209 } else if (state == plugin.DISCONNECTED) {
205 setHostMode('unshared'); 210 setHostMode('unshared');
206 plugin.parentNode.removeChild(plugin); 211 plugin.parentNode.removeChild(plugin);
207 } else { 212 } else {
208 window.alert('Unknown state -> ' + state); 213 addToDebugLog('Unknown state -> ' + state);
209 } 214 }
210 } 215 }
211 216
212 function cancelShare() { 217 function cancelShare() {
218 addToDebugLog('Canceling share...');
213 var plugin = document.getElementById(remoting.HOST_PLUGIN_ID); 219 var plugin = document.getElementById(remoting.HOST_PLUGIN_ID);
214 plugin.disconnect(); 220 plugin.disconnect();
215 } 221 }
216 222
217 function startSession_() { 223 function startSession_() {
224 addToDebugLog('Starting session...');
218 remoting.username = remoting.getItem(remoting.XMPP_LOGIN_NAME); 225 remoting.username = remoting.getItem(remoting.XMPP_LOGIN_NAME);
219 document.location = 'remoting_session.html'; 226 document.location = 'remoting_session.html';
220 } 227 }
221 228
222 function showConnectError_(responseCode, responseString) { 229 function showConnectError_(responseCode, responseString) {
223 var invalid = document.getElementById('invalid-access-code'); 230 var invalid = document.getElementById('invalid-access-code');
224 var other = document.getElementById('other-connect-error'); 231 var other = document.getElementById('other-connect-error');
225 if (responseCode == 404) { 232 if (responseCode == 404) {
226 invalid.style.display = 'block'; 233 invalid.style.display = 'block';
227 other.style.display = 'none'; 234 other.style.display = 'none';
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 xhr.setRequestHeader('Authorization', 277 xhr.setRequestHeader('Authorization',
271 'OAuth ' + remoting.oauth2.getAccessToken()); 278 'OAuth ' + remoting.oauth2.getAccessToken());
272 xhr.send(null); 279 xhr.send(null);
273 } 280 }
274 281
275 function tryConnect() { 282 function tryConnect() {
276 if (remoting.oauth2.needsNewAccessToken()) { 283 if (remoting.oauth2.needsNewAccessToken()) {
277 remoting.oauth2.refreshAccessToken(function() { 284 remoting.oauth2.refreshAccessToken(function() {
278 if (remoting.oauth2.needsNewAccessToken()) { 285 if (remoting.oauth2.needsNewAccessToken()) {
279 // If we still need it, we're going to infinite loop. 286 // If we still need it, we're going to infinite loop.
280 throw "Unable to get access token"; 287 throw "Unable to get access token.";
281 } 288 }
282 tryConnect(); 289 tryConnect();
283 }); 290 });
284 return; 291 return;
285 } 292 }
286 var accessCode = document.getElementById('access-code-entry').value; 293 var accessCode = document.getElementById('access-code-entry').value;
287 remoting.accessCode = accessCode; 294 remoting.accessCode = accessCode;
288 // TODO(jamiewalch): Since the mapping from (SupportId, HostSecret) to 295 // TODO(jamiewalch): Since the mapping from (SupportId, HostSecret) to
289 // AccessCode is not yet defined, assume it's hyphen-separated for now. 296 // AccessCode is not yet defined, assume it's hyphen-separated for now.
290 var parts = remoting.accessCode.split('-'); 297 var parts = remoting.accessCode.split('-');
291 if (parts.length != 2) { 298 if (parts.length != 2) {
292 showConnectError_(404); 299 showConnectError_(404);
293 } else { 300 } else {
294 setClientMode('connecting'); 301 setClientMode('connecting');
295 resolveSupportId(parts[0]); 302 resolveSupportId(parts[0]);
296 } 303 }
297 } 304 }
298 305
299 function cancelConnect() { 306 function cancelConnect() {
300 remoting.accessCode = ''; 307 remoting.accessCode = '';
301 setClientMode('unconnected'); 308 setClientMode('unconnected');
302 } 309 }
OLDNEW
« no previous file with comments | « remoting/webapp/me2mom/debug_log.js ('k') | remoting/webapp/me2mom/remoting_session.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698