diff options
author | jamiewalch <jamiewalch@chromium.org> | 2015-05-26 11:20:09 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-26 18:20:44 +0000 |
commit | e566584971cba294e505294ba021dd9a3d94a241 (patch) | |
tree | f80e4f76e29e217da5d35878d07197a6b8001afe | |
parent | 55cf2e7a89eee71a345b3d1a12cec16a85a9db50 (diff) | |
download | chromium_src-e566584971cba294e505294ba021dd9a3d94a241.zip chromium_src-e566584971cba294e505294ba021dd9a3d94a241.tar.gz chromium_src-e566584971cba294e505294ba021dd9a3d94a241.tar.bz2 |
Create a new window on launch.
The current behaviour is to bring the existing window to the front if there is one.
That means that the only way to create a second window is using the in-app menu, which
is not very discoverable. Since the existing window can be brought to the front by
clicking the task-bar/tray/dock icon, creating a new window is more useful.
BUG=488694
Review URL: https://codereview.chromium.org/1157753004
Cr-Commit-Position: refs/heads/master@{#331396}
-rw-r--r-- | remoting/webapp/crd/js/activation_handler.js | 11 | ||||
-rw-r--r-- | remoting/webapp/crd/js/app_launcher.js | 19 |
2 files changed, 11 insertions, 19 deletions
diff --git a/remoting/webapp/crd/js/activation_handler.js b/remoting/webapp/crd/js/activation_handler.js index a483d36..ce68a10 100644 --- a/remoting/webapp/crd/js/activation_handler.js +++ b/remoting/webapp/crd/js/activation_handler.js @@ -51,19 +51,12 @@ remoting.ActivationHandler.prototype.onContextMenu_ = function(info) { }; /** - * Called when the App is activated (e.g. from the Chrome App Launcher). It - * creates a new window if there are no existing ones. Otherwise, it will put - * focus on the last window created. + * Create a new window when the App is launched. * * @private */ remoting.ActivationHandler.prototype.onLaunched_ = function() { - var windows = chrome.app.window.getAll(); - if (windows.length >= 1) { - windows[windows.length - 1].focus(); - } else { - this.appLauncher_.launch(); - } + this.appLauncher_.launch(); }; })(); diff --git a/remoting/webapp/crd/js/app_launcher.js b/remoting/webapp/crd/js/app_launcher.js index fc28ab7..d4a838c 100644 --- a/remoting/webapp/crd/js/app_launcher.js +++ b/remoting/webapp/crd/js/app_launcher.js @@ -161,20 +161,19 @@ remoting.V2AppLauncher.prototype.close = function(id) { }; /** - * @return {number} the next available window id. + * @return {number} The first available window id. Since Chrome remembers + * properties such as size and position for app windows, it is better + * to reuse window ids rather than allocating new ones. */ function getNextWindowId() { var appWindows = chrome.app.window.getAll(); - var lastId = /** @type(number) */ (0); - appWindows.forEach(function(appWindow) { - base.debug.assert(Number.isInteger(appWindow.id), - "Window Id should be an integer"); - var id = parseInt(appWindow.id, 10); - if (lastId <= id) { - lastId = id; + var result = 1; + for (; result <= appWindows.length; ++result) { + if (!chrome.app.window.get(String(result))) { + break; } - }); - return ++lastId; + } + return result; } })(); |