blob: ce68a100ff46fc0b4b5b41a41d22be5811e90f33 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/** @suppress {duplicate} */
var remoting = remoting || {};
(function(){
'use strict';
/** @type {string} */
var NEW_WINDOW_MENU_ID_ = 'new-window';
/**
* A class that handles application activation.
*
* @param {base.Ipc} ipc
* @param {remoting.V2AppLauncher} appLauncher
* @constructor
*/
remoting.ActivationHandler = function (ipc, appLauncher) {
/** @private {remoting.V2AppLauncher} */
this.appLauncher_ = appLauncher;
chrome.contextMenus.create({
id: NEW_WINDOW_MENU_ID_,
contexts: ['launcher'],
title: chrome.i18n.getMessage(/*i18n-content*/'NEW_WINDOW')
});
chrome.contextMenus.onClicked.addListener(this.onContextMenu_.bind(this));
chrome.app.runtime.onLaunched.addListener(this.onLaunched_.bind(this));
ipc.register(remoting.ActivationHandler.Ipc.RELAUNCH,
appLauncher.restart.bind(appLauncher));
};
/** @enum {string} */
remoting.ActivationHandler.Ipc = {
RELAUNCH: 'remoting.ActivationHandler.restart'
};
/**
* @param {OnClickData} info
* @private
*/
remoting.ActivationHandler.prototype.onContextMenu_ = function(info) {
if (info.menuItemId == NEW_WINDOW_MENU_ID_) {
this.appLauncher_.launch();
}
};
/**
* Create a new window when the App is launched.
*
* @private
*/
remoting.ActivationHandler.prototype.onLaunched_ = function() {
this.appLauncher_.launch();
};
})();
|