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

Unified Diff: remoting/webapp/crd/js/desktop_remoting.js

Issue 1020743002: [Chromoting] Move app-specific code out of remoting.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: remoting/webapp/crd/js/desktop_remoting.js
diff --git a/remoting/webapp/crd/js/desktop_remoting.js b/remoting/webapp/crd/js/desktop_remoting.js
index 0ef6beabf613939a1d13d78ea2dd9d94b75b5c1f..e9490222eacc93155955f2e9fd0284ef7af8df2e 100644
--- a/remoting/webapp/crd/js/desktop_remoting.js
+++ b/remoting/webapp/crd/js/desktop_remoting.js
@@ -76,7 +76,8 @@ remoting.DesktopRemoting.prototype.init = function() {
document.getElementById('session-toolbar'));
remoting.optionsMenu = remoting.toolbar.createOptionsMenu();
- window.addEventListener('beforeunload', remoting.promptClose, false);
+ window.addEventListener('beforeunload',
+ this.promptClose_.bind(this), false);
window.addEventListener('unload',
remoting.app.disconnect.bind(remoting.app), false);
}
@@ -109,7 +110,7 @@ remoting.DesktopRemoting.prototype.init = function() {
document.getElementById('startup-mode-box-it2me').hidden = false;
}
};
- isWindowed_(onIsWindowed);
+ this.isWindowed_(onIsWindowed);
}
remoting.ClientPlugin.factory.preloadPlugin();
@@ -134,16 +135,6 @@ remoting.DesktopRemoting.prototype.start = function(connector, token) {
};
/**
- * Report an authentication error to the user. This is called in lieu of start()
- * if the user cannot be authenticated or if they decline the app permissions.
- *
- * @param {!remoting.Error} error The failure reason.
- */
-remoting.DesktopRemoting.prototype.signInFailed = function(error) {
- remoting.showErrorMessage(error);
-};
-
-/**
* @return {string} Application product name to be used in UI.
*/
remoting.DesktopRemoting.prototype.getApplicationName = function() {
@@ -325,7 +316,76 @@ remoting.DesktopRemoting.prototype.handleError = function(error) {
};
/**
+ * Report an authentication error to the user. This is called in lieu of start()
+ * if the user cannot be authenticated or if they decline the app permissions.
+ *
+ * @param {!remoting.Error} error The failure reason.
+ */
+remoting.DesktopRemoting.prototype.handleAuthError = function(error) {
garykac 2015/03/19 01:03:43 function copied from remoting.showErrorMessage
+ l10n.localizeElementFromTag(
+ document.getElementById('token-refresh-error-message'),
+ error.getTag());
+ var auth_failed = (error.hasTag(remoting.Error.Tag.AUTHENTICATION_FAILED));
+ if (auth_failed && base.isAppsV2()) {
+ remoting.handleAuthFailureAndRelaunch();
+ } else {
+ document.getElementById('token-refresh-auth-failed').hidden = !auth_failed;
+ document.getElementById('token-refresh-other-error').hidden = auth_failed;
+ remoting.setMode(remoting.AppMode.TOKEN_REFRESH_FAILED);
+ }
+};
+
+/**
* No cleanup required for desktop remoting.
*/
remoting.DesktopRemoting.prototype.handleExit = function() {
};
+
+/**
+ * Determine whether or not the app is running in a window.
+ * @param {function(boolean):void} callback Callback to receive whether or not
+ * the current tab is running in windowed mode.
+ * @private
+ */
+remoting.DesktopRemoting.prototype.isWindowed_ = function(callback) {
garykac 2015/03/19 01:03:43 moved here from remoting.js
+ /** @param {chrome.Window} win The current window. */
+ var windowCallback = function(win) {
+ callback(win.type == 'popup');
+ };
+ /** @param {chrome.Tab} tab The current tab. */
+ var tabCallback = function(tab) {
+ if (tab.pinned) {
+ callback(false);
+ } else {
+ chrome.windows.get(tab.windowId, null, windowCallback);
+ }
+ };
+ if (chrome.tabs) {
+ chrome.tabs.getCurrent(tabCallback);
+ } else {
+ console.error('chome.tabs is not available.');
+ }
+}
+
+/**
+ * If an IT2Me client or host is active then prompt the user before closing.
+ * If a Me2Me client is active then don't bother, since closing the window is
+ * the more intuitive way to end a Me2Me session, and re-connecting is easy.
+ * @private
+ */
+remoting.DesktopRemoting.prototype.promptClose_ = function() {
garykac 2015/03/19 01:03:44 moved here from remoting.js
+ if (remoting.desktopConnectedView &&
kelvinp 2015/03/19 17:50:20 desktopConnectedView is gone now. Need remerging.
garykac 2015/03/19 21:58:38 Acknowledged.
+ remoting.desktopConnectedView.getMode() ==
+ remoting.DesktopConnectedView.Mode.IT2ME) {
+ switch (remoting.currentMode) {
+ case remoting.AppMode.CLIENT_CONNECTING:
+ case remoting.AppMode.HOST_WAITING_FOR_CODE:
+ case remoting.AppMode.HOST_WAITING_FOR_CONNECTION:
+ case remoting.AppMode.HOST_SHARED:
+ case remoting.AppMode.IN_SESSION:
+ return chrome.i18n.getMessage(/*i18n-content*/'CLOSE_PROMPT');
+ default:
+ return null;
+ }
+ }
+};

Powered by Google App Engine
This is Rietveld 408576698