Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / remoting / webapp / crd / js / activation_handler.js
blob5e2f6bdc4050257117972c599446efee14b0dd50
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.
5 /** @suppress {duplicate} */
6 var remoting = remoting || {};
8 (function(){
10 'use strict';
12 /** @type {string} */
13 var NEW_WINDOW_MENU_ID_ = 'new-window';
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   /** @private {remoting.V2AppLauncher} */
24   this.appLauncher_ = appLauncher;
26   chrome.contextMenus.create({
27      id: NEW_WINDOW_MENU_ID_,
28      contexts: ['launcher'],
29      title: chrome.i18n.getMessage(/*i18n-content*/'NEW_WINDOW')
30   });
32   chrome.contextMenus.onClicked.addListener(
33       /** @type {function (Object, Tab=)} */ (this.onContextMenu_.bind(this)));
34   chrome.app.runtime.onLaunched.addListener(this.onLaunched_.bind(this));
35   ipc.register(remoting.ActivationHandler.Ipc.RELAUNCH,
36                appLauncher.restart.bind(appLauncher));
39 /** @enum {string} */
40 remoting.ActivationHandler.Ipc = {
41   RELAUNCH: 'remoting.ActivationHandler.restart'
44 /**
45  * @param {OnClickData} info
46  * @private
47  */
48 remoting.ActivationHandler.prototype.onContextMenu_ = function(info) {
49   if (info.menuItemId == NEW_WINDOW_MENU_ID_) {
50     this.appLauncher_.launch();
51   }
54 /**
55  * Create a new window when the App is launched.
56  *
57  * @private
58  */
59 remoting.ActivationHandler.prototype.onLaunched_ = function() {
60   this.appLauncher_.launch();
63 })();