diff options
author | garykac@google.com <garykac@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-08 21:32:14 +0000 |
---|---|---|
committer | garykac@google.com <garykac@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-08 21:32:14 +0000 |
commit | f4107ff9e51e0a768423e46bace472fe5f641b2d (patch) | |
tree | ed302bf3755f5b745ed63c39ce6bf9af29afc6e8 /remoting/webapp/me2mom | |
parent | 342508e43bd18155fd892f38d26086024844b84f (diff) | |
download | chromium_src-f4107ff9e51e0a768423e46bace472fe5f641b2d.zip chromium_src-f4107ff9e51e0a768423e46bace472fe5f641b2d.tar.gz chromium_src-f4107ff9e51e0a768423e46bace472fe5f641b2d.tar.bz2 |
Add basic debug log to host page.
BUG=none
TEST=manual
Review URL: http://codereview.chromium.org/7108007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88409 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/webapp/me2mom')
-rw-r--r-- | remoting/webapp/me2mom/choice.html | 13 | ||||
-rw-r--r-- | remoting/webapp/me2mom/debug_log.css | 32 | ||||
-rw-r--r-- | remoting/webapp/me2mom/debug_log.js | 42 | ||||
-rw-r--r-- | remoting/webapp/me2mom/remoting.js | 11 | ||||
-rw-r--r-- | remoting/webapp/me2mom/remoting_session.css | 19 | ||||
-rw-r--r-- | remoting/webapp/me2mom/remoting_session.html | 2 | ||||
-rw-r--r-- | remoting/webapp/me2mom/remoting_session.js | 39 |
7 files changed, 97 insertions, 61 deletions
diff --git a/remoting/webapp/me2mom/choice.html b/remoting/webapp/me2mom/choice.html index 546a3c9..8a9ddab 100644 --- a/remoting/webapp/me2mom/choice.html +++ b/remoting/webapp/me2mom/choice.html @@ -9,10 +9,12 @@ found in the LICENSE file. <head> <meta charset="utf-8" /> <link rel="shortcut icon" href="chromoting128.png" /> + <link rel="stylesheet" href="debug_log.css" /> <link rel="stylesheet" href="main.css" /> <link rel="stylesheet" href="choice.css" /> - <script src="remoting.js"></script> + <script src="debug_log.js"></script> <script src="oauth2.js"></script> + <script src="remoting.js"></script> <title>Chromoting</title> </head> @@ -47,6 +49,13 @@ found in the LICENSE file. </form> </span> <!-- email-entry --> + <span id="debug-enable"> + <form> + <input id="debug-log-toggle" class="display-inline" type="button" + value="Debug Log" onclick="toggleDebugLog(); return false;"/> + </form> + </span> <!-- debug-enable --> + </div> <!-- auth-panel --> <div id="main-panel" class="hidden"> @@ -194,5 +203,7 @@ found in the LICENSE file. <div id="plugin-wrapper"> </div> + <div id="debug-log"> + </div> </body> </html> diff --git a/remoting/webapp/me2mom/debug_log.css b/remoting/webapp/me2mom/debug_log.css new file mode 100644 index 0000000..4d05001 --- /dev/null +++ b/remoting/webapp/me2mom/debug_log.css @@ -0,0 +1,32 @@ +/* Copyright (c) 2011 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#debug-log { + background-color: white; + bottom: 0; + border-top: 1px solid black; + display: none; + height: 150px; + margin: 0; + opacity: 0.85; + overflow: auto; + padding: 0; + position: fixed; + width: 100%; + z-index: 100; + -webkit-user-select: text; +} + +#debug-log > p { + font-family: monospace; + font-weight: bold; + font-size: small; + margin: 0.35em; + padding: 0; +} + +#debug-log-toggle { + float: right; +} diff --git a/remoting/webapp/me2mom/debug_log.js b/remoting/webapp/me2mom/debug_log.js new file mode 100644 index 0000000..a848b2d --- /dev/null +++ b/remoting/webapp/me2mom/debug_log.js @@ -0,0 +1,42 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Maximum numer of lines to record in the debug log. +// Only the most recent <n> lines are displayed. +var MAX_DEBUG_LOG_SIZE = 1000; + +function toggleDebugLog() { + debugLog = document.getElementById('debug-log'); + toggleButton = document.getElementById('debug-log-toggle'); + + if (!debugLog.style.display || debugLog.style.display == 'none') { + debugLog.style.display = 'block'; + toggleButton.value = 'Hide Debug Log'; + } else { + debugLog.style.display = 'none'; + toggleButton.value = 'Show Debug Log'; + } +} + +/** + * Add the given message to the debug log. + * + * @param {string} message The debug info to add to the log. + */ +function addToDebugLog(message) { + var debugLog = document.getElementById('debug-log'); + + // Remove lines from top if we've hit our max log size. + if (debugLog.childNodes.length == MAX_DEBUG_LOG_SIZE) { + debugLog.removeChild(debugLog.firstChild); + } + + // Add the new <p> to the end of the debug log. + var p = document.createElement('p'); + p.appendChild(document.createTextNode(message)); + debugLog.appendChild(p); + + // Scroll to bottom of div + debugLog.scrollTop = debugLog.scrollHeight; +} diff --git a/remoting/webapp/me2mom/remoting.js b/remoting/webapp/me2mom/remoting.js index 0640d73..2dfecfa 100644 --- a/remoting/webapp/me2mom/remoting.js +++ b/remoting/webapp/me2mom/remoting.js @@ -169,20 +169,25 @@ function setGlobalModePersistent(mode) { function setHostMode(mode) { var section = document.getElementById('host-section'); var modes = section.getElementsByClassName('mode'); + addToDebugLog('Host mode: ' + mode); setMode_(mode, modes); } function setClientMode(mode) { var section = document.getElementById('client-section'); var modes = section.getElementsByClassName('mode'); + addToDebugLog('Client mode: ' + mode); setMode_(mode, modes); } function tryShare() { + addToDebugLog("Attempting to share..."); if (remoting.oauth2.needsNewAccessToken()) { + addToDebugLog("Refreshing token..."); remoting.oauth2.refreshAccessToken(function() { if (remoting.oauth2.needsNewAccessToken()) { // If we still need it, we're going to infinite loop. + addToDebugLog("Unable to get access token"); throw "Unable to get access token"; } tryShare(); @@ -217,16 +222,18 @@ function onStateChanged_() { setHostMode('unshared'); plugin.parentNode.removeChild(plugin); } else { - window.alert('Unknown state -> ' + state); + addToDebugLog('Unknown state -> ' + state); } } function cancelShare() { + addToDebugLog('Canceling share...'); var plugin = document.getElementById(remoting.HOST_PLUGIN_ID); plugin.disconnect(); } function startSession_() { + addToDebugLog('Starting session...'); remoting.username = remoting.getItem(remoting.XMPP_LOGIN_NAME); document.location = 'remoting_session.html'; } @@ -289,7 +296,7 @@ function tryConnect() { 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"; + throw "Unable to get access token."; } tryConnect(); }); diff --git a/remoting/webapp/me2mom/remoting_session.css b/remoting/webapp/me2mom/remoting_session.css index f5e98ff..cc33d240 100644 --- a/remoting/webapp/me2mom/remoting_session.css +++ b/remoting/webapp/me2mom/remoting_session.css @@ -12,25 +12,6 @@ body { } /* Ids */ -#debug-log { - background-color: white; - bottom: 0; - border-top: 1px solid black; - display: none; - font-family: monospace; - font-weight: bold; - font-size: small; - height: 150px; - margin: 0; - opacity: 0.85; - overflow: auto; - padding: 0; - position: fixed; - width: 100%; - z-index: 100; - -webkit-user-select: text; -} - #plugin-scroll-panel { overflow: auto; width: 100%; diff --git a/remoting/webapp/me2mom/remoting_session.html b/remoting/webapp/me2mom/remoting_session.html index 0a1cf70..e1e3eed 100644 --- a/remoting/webapp/me2mom/remoting_session.html +++ b/remoting/webapp/me2mom/remoting_session.html @@ -9,8 +9,10 @@ found in the LICENSE file. <head> <title>Chromoting Session</title> <link rel="shortcut icon" href="chromoting128.png" /> + <link rel="stylesheet" href="debug_log.css" /> <link rel="stylesheet" href="main.css" /> <link rel="stylesheet" href="remoting_session.css" /> + <script src="debug_log.js"></script> <script src="oauth2.js"></script> <script src="remoting_session.js"></script> </head> diff --git a/remoting/webapp/me2mom/remoting_session.js b/remoting/webapp/me2mom/remoting_session.js index 705dc7e..1860b31 100644 --- a/remoting/webapp/me2mom/remoting_session.js +++ b/remoting/webapp/me2mom/remoting_session.js @@ -2,10 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Maximum numer of lines to record in the debug log. -// Only the most recent <n> lines are displayed. -var MAX_DEBUG_LOG_SIZE = 1000; - var remoting = chrome.extension.getBackgroundPage().remoting; // Chromoting session API version (for this javascript). @@ -170,19 +166,6 @@ function init_() { } -function toggleDebugLog() { - debugLog = document.getElementById('debug-log'); - toggleButton = document.getElementById('debug-log-toggle'); - - if (!debugLog.style.display || debugLog.style.display == 'none') { - debugLog.style.display = 'block'; - toggleButton.value = 'Hide Debug Log'; - } else { - debugLog.style.display = 'none'; - toggleButton.value = 'Show Debug Log'; - } -} - function toggleScaleToFit() { remoting.scaleToFit = !remoting.scaleToFit; document.getElementById('scale-to-fit-toggle').value = @@ -313,28 +296,6 @@ function debugInfoCallback(msg) { addToDebugLog('plugin: ' + msg); } -/** - * Add the given message to the debug log. - * - * @param {string} message The debug info to add to the log. - */ -function addToDebugLog(message) { - var debugLog = document.getElementById('debug-log'); - - // Remove lines from top if we've hit our max log size. - if (debugLog.childNodes.length == MAX_DEBUG_LOG_SIZE) { - debugLog.removeChild(debugLog.firstChild); - } - - // Add the new <p> to the end of the debug log. - var p = document.createElement('p'); - p.appendChild(document.createTextNode(message)); - debugLog.appendChild(p); - - // Scroll to bottom of div - debugLog.scrollTop = debugLog.scrollHeight; -} - function updateStatusBarStats() { if (remoting.plugin.status != remoting.plugin.STATUS_CONNECTED) return; |