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

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: Make isMe2MeInstallable private 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
« no previous file with comments | « remoting/webapp/crd/js/crd_main.js ('k') | remoting/webapp/crd/js/host_list.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0f727f0855fbd30337148c58f0178cbc570dcb03..49fa5bbbd4c028de0822d7ed66d0386493320b90 100644
--- a/remoting/webapp/crd/js/desktop_remoting.js
+++ b/remoting/webapp/crd/js/desktop_remoting.js
@@ -81,7 +81,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);
}
@@ -114,7 +115,7 @@ remoting.DesktopRemoting.prototype.init = function() {
document.getElementById('startup-mode-box-it2me').hidden = false;
}
};
- isWindowed_(onIsWindowed);
+ this.isWindowed_(onIsWindowed);
}
remoting.ClientPlugin.factory.preloadPlugin();
@@ -333,6 +334,56 @@ remoting.DesktopRemoting.prototype.handleError = function(error) {
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) {
+ /** @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() {
+ var sessionConnector = remoting.app.getSessionConnector();
+ if (sessionConnector &&
+ sessionConnector.getConnectionMode() ==
+ 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;
+ }
+ }
+};
+
/** @returns {remoting.DesktopConnectedView} */
remoting.DesktopRemoting.prototype.getConnectedViewForTesting = function() {
return this.connectedView_;
@@ -342,4 +393,4 @@ remoting.DesktopRemoting.prototype.getConnectedViewForTesting = function() {
* Global instance of remoting.DesktopRemoting used for testing.
* @type {remoting.DesktopRemoting}
*/
-remoting.desktopDelegateForTesting = null;
+remoting.desktopDelegateForTesting = null;
« no previous file with comments | « remoting/webapp/crd/js/crd_main.js ('k') | remoting/webapp/crd/js/host_list.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698