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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 var kSupportIdLen = 7; | 61 var kSupportIdLen = 7; |
62 var kHostSecretLen = 5; | 62 var kHostSecretLen = 5; |
63 var kAccessCodeLen = kSupportIdLen + kHostSecretLen; | 63 var kAccessCodeLen = kSupportIdLen + kHostSecretLen; |
64 var kDigitsPerGroup = 4; | 64 var kDigitsPerGroup = 4; |
65 | 65 |
66 function hasClass(classes, cls) { | 66 function hasClass(classes, cls) { |
67 return classes.match(new RegExp('(\\s|^)' + cls + '(\\s|$)')); | 67 return classes.match(new RegExp('(\\s|^)' + cls + '(\\s|$)')); |
68 } | 68 } |
69 | 69 |
70 function addClass(element, cls) { | 70 function addClass(element, cls) { |
71 if (!hasClass(element.className, cls)) | 71 if (!hasClass(element.className, cls)) { |
72 element.className = element.className + ' ' + cls; | 72 var padded = element.className == '' ? '' : element.className + ' '; |
73 element.className = padded + cls; | |
74 } | |
73 } | 75 } |
74 | 76 |
75 function removeClass(element, cls) { | 77 function removeClass(element, cls) { |
76 element.className = | 78 element.className = |
77 element.className.replace(new RegExp('\\b' + cls + '\\b', 'g'), ''); | 79 element.className.replace(new RegExp('\\b' + cls + '\\b', 'g'), '') |
80 .replace(' ', ' '); | |
78 } | 81 } |
79 | 82 |
80 function retrieveEmail_(access_token) { | 83 function retrieveEmail_(access_token) { |
81 var headers = { | 84 var headers = { |
82 'Authorization': 'OAuth ' + remoting.oauth2.getAccessToken() | 85 'Authorization': 'OAuth ' + remoting.oauth2.getAccessToken() |
83 }; | 86 }; |
84 | 87 |
85 var onResponse = function(xhr) { | 88 var onResponse = function(xhr) { |
86 if (xhr.status != 200) { | 89 if (xhr.status != 200) { |
87 // TODO(ajwong): Have a better way of showing an error. | 90 // TODO(ajwong): Have a better way of showing an error. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 var debugLog = document.getElementById('debug-log'); | 139 var debugLog = document.getElementById('debug-log'); |
137 if (debugLog.hidden) { | 140 if (debugLog.hidden) { |
138 debugLog.hidden = false; | 141 debugLog.hidden = false; |
139 } else { | 142 } else { |
140 debugLog.hidden = true; | 143 debugLog.hidden = true; |
141 } | 144 } |
142 } | 145 } |
143 | 146 |
144 remoting.init = function() { | 147 remoting.init = function() { |
145 l10n.localize(); | 148 l10n.localize(); |
149 var button = document.getElementById('toggle-scaling'); | |
150 button.title = chrome.i18n.getMessage(/*i18-content*/'TOOLTIP_SCALING'); | |
garykac
2011/08/26 00:43:17
/*i18n-content*/
| |
146 // Create global objects. | 151 // Create global objects. |
147 remoting.oauth2 = new remoting.OAuth2(); | 152 remoting.oauth2 = new remoting.OAuth2(); |
148 remoting.debug = | 153 remoting.debug = |
149 new remoting.DebugLog(document.getElementById('debug-messages')); | 154 new remoting.DebugLog(document.getElementById('debug-messages')); |
150 | 155 |
151 refreshEmail_(); | 156 refreshEmail_(); |
152 var email = getEmail(); | 157 var email = getEmail(); |
153 if (email) { | 158 if (email) { |
154 document.getElementById('current-email').innerText = email; | 159 document.getElementById('current-email').innerText = email; |
155 } | 160 } |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
586 * @return {boolean} True if Host mode is supported. | 591 * @return {boolean} True if Host mode is supported. |
587 */ | 592 */ |
588 function isHostModeSupported() { | 593 function isHostModeSupported() { |
589 // Currently, ChromeOS is not supported. | 594 // Currently, ChromeOS is not supported. |
590 return !navigator.userAgent.match(/\bCrOS\b/); | 595 return !navigator.userAgent.match(/\bCrOS\b/); |
591 } | 596 } |
592 | 597 |
593 /** | 598 /** |
594 * Enable or disable scale-to-fit. | 599 * Enable or disable scale-to-fit. |
595 * | 600 * |
601 * @param {boolean} scale True to enable scaling. | |
596 * @return {void} Nothing. | 602 * @return {void} Nothing. |
597 */ | 603 */ |
598 remoting.toggleScaleToFit = function() { | 604 remoting.toggleScaleToFit = function(button) { |
599 remoting.scaleToFit = !remoting.scaleToFit; | 605 remoting.scaleToFit = !remoting.scaleToFit; |
600 remoting.session.toggleScaleToFit(remoting.scaleToFit); | 606 if (remoting.scaleToFit) { |
607 addClass(button, 'toggle-button-active'); | |
608 } else { | |
609 removeClass(button, 'toggle-button-active'); | |
610 } | |
611 remoting.session.setScaleToFit(remoting.scaleToFit); | |
601 } | 612 } |
602 | 613 |
603 /** | 614 /** |
604 * Disconnect the remoting client. | 615 * Disconnect the remoting client. |
605 * | 616 * |
606 * @return {void} Nothing. | 617 * @return {void} Nothing. |
607 */ | 618 */ |
608 remoting.disconnect = function() { | 619 remoting.disconnect = function() { |
609 if (remoting.session) { | 620 if (remoting.session) { |
610 remoting.session.disconnect(); | 621 remoting.session.disconnect(); |
(...skipping 18 matching lines...) Expand all Loading... | |
629 var result = chrome.i18n.getMessage(/*i18n-content*/'CLOSE_PROMPT'); | 640 var result = chrome.i18n.getMessage(/*i18n-content*/'CLOSE_PROMPT'); |
630 return result; | 641 return result; |
631 default: | 642 default: |
632 return NULL; | 643 return NULL; |
633 } | 644 } |
634 } | 645 } |
635 | 646 |
636 }()); | 647 }()); |
637 | 648 |
638 // Shortcut to save typing now that this is the only way to show the debug log. | 649 // Shortcut to save typing now that this is the only way to show the debug log. |
639 var tdl = remoting.toggleDebugLog; | 650 var tdl = remoting.toggleDebugLog; |
OLD | NEW |