Chromium Code Reviews| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 var hidden = true; | 182 var hidden = true; |
| 183 for (var m = 0; m < modes.length; ++m) { | 183 for (var m = 0; m < modes.length; ++m) { |
| 184 if (hasClass(element.getAttribute('data-ui-mode'), modes[m])) { | 184 if (hasClass(element.getAttribute('data-ui-mode'), modes[m])) { |
| 185 hidden = false; | 185 hidden = false; |
| 186 break; | 186 break; |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 element.hidden = hidden; | 189 element.hidden = hidden; |
| 190 } | 190 } |
| 191 remoting.debug.log('App mode: ' + mode); | 191 remoting.debug.log('App mode: ' + mode); |
| 192 remoting.currentMode = modes[0]; | 192 remoting.currentMode = mode; |
| 193 } | |
| 194 | |
| 195 /** | |
| 196 * Get the major mode that the app is running in. | |
| 197 * @return {remoting.Mode} The app's current major mode. | |
| 198 */ | |
| 199 remoting.getMajorMode = function(mode) { | |
| 200 return remoting.currentMode.split('.')[0]; | |
| 193 } | 201 } |
| 194 | 202 |
| 195 remoting.tryShare = function() { | 203 remoting.tryShare = function() { |
| 196 remoting.debug.log('Attempting to share...'); | 204 remoting.debug.log('Attempting to share...'); |
| 197 if (remoting.oauth2.needsNewAccessToken()) { | 205 if (remoting.oauth2.needsNewAccessToken()) { |
| 198 remoting.debug.log('Refreshing token...'); | 206 remoting.debug.log('Refreshing token...'); |
| 199 remoting.oauth2.refreshAccessToken(function() { | 207 remoting.oauth2.refreshAccessToken(function() { |
| 200 if (remoting.oauth2.needsNewAccessToken()) { | 208 if (remoting.oauth2.needsNewAccessToken()) { |
| 201 // If we still need it, we're going to infinite loop. | 209 // If we still need it, we're going to infinite loop. |
| 202 showShareError_('unable-to-get-token'); | 210 showShareError_('unable-to-get-token'); |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 513 } | 521 } |
| 514 remoting.doTryConnect(); | 522 remoting.doTryConnect(); |
| 515 }); | 523 }); |
| 516 } else { | 524 } else { |
| 517 remoting.doTryConnect(); | 525 remoting.doTryConnect(); |
| 518 } | 526 } |
| 519 } | 527 } |
| 520 | 528 |
| 521 remoting.cancelPendingOperation = function() { | 529 remoting.cancelPendingOperation = function() { |
| 522 document.getElementById('cancel-button').disabled = true; | 530 document.getElementById('cancel-button').disabled = true; |
| 523 if (remoting.currentMode == remoting.AppMode.HOST) { | 531 if (remoting.getMajorMode() == remoting.AppMode.HOST) { |
| 524 remoting.cancelShare(); | 532 remoting.cancelShare(); |
| 525 } | 533 } |
| 526 } | 534 } |
| 527 | 535 |
| 528 /** | 536 /** |
| 529 * Changes the major-mode of the application (Eg., client or host). | 537 * Changes the major-mode of the application (Eg., client or host). |
| 530 * | 538 * |
| 531 * @param {remoting.AppMode} mode The mode to shift the application into. | 539 * @param {remoting.AppMode} mode The mode to shift the application into. |
| 532 * @return {void} Nothing. | 540 * @return {void} Nothing. |
| 533 */ | 541 */ |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 583 */ | 591 */ |
| 584 remoting.disconnect = function() { | 592 remoting.disconnect = function() { |
| 585 if (remoting.session) { | 593 if (remoting.session) { |
| 586 remoting.session.disconnect(); | 594 remoting.session.disconnect(); |
| 587 remoting.session = null; | 595 remoting.session = null; |
| 588 remoting.debug.log('Disconnected.'); | 596 remoting.debug.log('Disconnected.'); |
| 589 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED); | 597 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED); |
| 590 } | 598 } |
| 591 } | 599 } |
| 592 | 600 |
| 601 /** If the client is connected, or the host is shared, prompt before closing. | |
| 602 * | |
| 603 * @return {string|void} The prompt string if a connection is active. | |
| 604 */ | |
| 605 remoting.promptClose = function() { | |
| 606 var token = null; | |
|
awong
2011/08/05 23:17:25
How about messageId instead of token
Jamie
2011/08/05 23:36:51
Done.
| |
| 607 if (remoting.getMajorMode() == remoting.AppMode.HOST && | |
| 608 remoting.currentMode != remoting.AppMode.HOST_UNSHARED) { | |
| 609 token = 'closePromptHost'; | |
| 610 } else if (remoting.getMajorMode() == remoting.AppMode.IN_SESSION || | |
| 611 remoting.currentMode == remoting.AppMode.CLIENT_CONNECTING) { | |
| 612 token = 'closePromptClient'; | |
| 613 } | |
| 614 if (token) { | |
| 615 var result = chrome.i18n.getMessage(token); | |
| 616 return result; | |
| 617 } | |
| 618 } | |
| 619 | |
| 593 }()); | 620 }()); |
| OLD | NEW |