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

Side by Side Diff: remoting/webapp/crd/js/activation_handler.js

Issue 868203002: Handle authentication failures in the v2 app by restarting the app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « remoting/webapp/base/js/auth_init.js ('k') | remoting/webapp/crd/js/app_launcher.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /** @suppress {duplicate} */
6 var remoting = remoting || {};
7
8 (function(){
9
10 'use strict';
11
12 /** @type {string} */
13 var NEW_WINDOW_MENU_ID_ = 'new-window';
14
15 /**
16 * A class that handles application activation.
17 *
18 * @param {base.Ipc} ipc
19 * @param {remoting.V2AppLauncher} appLauncher
20 * @constructor
21 */
22 remoting.ActivationHandler = function (ipc, appLauncher) {
23 /**
24 * @type {remoting.V2AppLauncher}
25 * @private
26 */
27 this.appLauncher_ = appLauncher;
28
29 chrome.contextMenus.create({
30 id: NEW_WINDOW_MENU_ID_,
31 contexts: ['launcher'],
32 title: chrome.i18n.getMessage(/*i18n-content*/'NEW_WINDOW')
33 });
34
35 chrome.contextMenus.onClicked.addListener(this.onContextMenu_.bind(this));
36 chrome.app.runtime.onLaunched.addListener(this.onLaunched_.bind(this));
37 ipc.register(remoting.ActivationHandler.Ipc.RELAUNCH,
38 appLauncher.restart.bind(appLauncher));
39 };
40
41 /** @enum {string} */
42 remoting.ActivationHandler.Ipc = {
43 RELAUNCH: 'remoting.ActivationHandler.restart'
44 };
45
46 /**
47 * @param {OnClickData} info
48 * @private
49 */
50 remoting.ActivationHandler.prototype.onContextMenu_ = function(info) {
51 if (info.menuItemId == NEW_WINDOW_MENU_ID_) {
52 this.appLauncher_.launch();
53 }
54 };
55
56 /**
57 * Called when the App is activated (e.g. from the Chrome App Launcher). It
58 * creates a new window if there are no existing ones. Otherwise, it will put
59 * focus on the last window created.
60 *
61 * @private
62 */
63 remoting.ActivationHandler.prototype.onLaunched_ = function() {
64 var windows = chrome.app.window.getAll();
65 if (windows.length >= 1) {
66 windows[windows.length - 1].focus();
67 } else {
68 this.appLauncher_.launch();
69 }
70 };
71
72 })();
OLDNEW
« no previous file with comments | « remoting/webapp/base/js/auth_init.js ('k') | remoting/webapp/crd/js/app_launcher.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698