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(/*i18n-content*/'TOOLTIP_SCALING'); |
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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 * @return {boolean} True if Host mode is supported. | 595 * @return {boolean} True if Host mode is supported. |
591 */ | 596 */ |
592 function isHostModeSupported() { | 597 function isHostModeSupported() { |
593 // Currently, ChromeOS is not supported. | 598 // Currently, ChromeOS is not supported. |
594 return !navigator.userAgent.match(/\bCrOS\b/); | 599 return !navigator.userAgent.match(/\bCrOS\b/); |
595 } | 600 } |
596 | 601 |
597 /** | 602 /** |
598 * Enable or disable scale-to-fit. | 603 * Enable or disable scale-to-fit. |
599 * | 604 * |
| 605 * @param {boolean} scale True to enable scaling. |
600 * @return {void} Nothing. | 606 * @return {void} Nothing. |
601 */ | 607 */ |
602 remoting.toggleScaleToFit = function() { | 608 remoting.toggleScaleToFit = function(button) { |
603 remoting.scaleToFit = !remoting.scaleToFit; | 609 remoting.scaleToFit = !remoting.scaleToFit; |
604 remoting.session.toggleScaleToFit(remoting.scaleToFit); | 610 if (remoting.scaleToFit) { |
| 611 addClass(button, 'toggle-button-active'); |
| 612 } else { |
| 613 removeClass(button, 'toggle-button-active'); |
| 614 } |
| 615 remoting.session.setScaleToFit(remoting.scaleToFit); |
605 } | 616 } |
606 | 617 |
607 /** | 618 /** |
608 * Disconnect the remoting client. | 619 * Disconnect the remoting client. |
609 * | 620 * |
610 * @return {void} Nothing. | 621 * @return {void} Nothing. |
611 */ | 622 */ |
612 remoting.disconnect = function() { | 623 remoting.disconnect = function() { |
613 if (remoting.session) { | 624 if (remoting.session) { |
614 remoting.session.disconnect(); | 625 remoting.session.disconnect(); |
(...skipping 18 matching lines...) Expand all Loading... |
633 var result = chrome.i18n.getMessage(/*i18n-content*/'CLOSE_PROMPT'); | 644 var result = chrome.i18n.getMessage(/*i18n-content*/'CLOSE_PROMPT'); |
634 return result; | 645 return result; |
635 default: | 646 default: |
636 return NULL; | 647 return NULL; |
637 } | 648 } |
638 } | 649 } |
639 | 650 |
640 }()); | 651 }()); |
641 | 652 |
642 // Shortcut to save typing now that this is the only way to show the debug log. | 653 // Shortcut to save typing now that this is the only way to show the debug log. |
643 var tdl = remoting.toggleDebugLog; | 654 var tdl = remoting.toggleDebugLog; |
OLD | NEW |