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

Side by Side Diff: remoting/webapp/app_remoting/js/window_activation_menu.js

Issue 1816653002: Remove app_remoting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 unified diff | Download patch
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 /**
6 * @fileoverview
7 * Class to update the application's context menu to include host-side windows
8 * and to notify the host when one of these menu items is selected.
9 */
10
11 'use strict';
12
13 /** @suppress {duplicate} */
14 var remoting = remoting || {};
15
16 /**
17 * @param {remoting.ContextMenuAdapter} adapter
18 * @constructor
19 */
20 remoting.WindowActivationMenu = function(adapter) {
21 /** @private {remoting.SubmenuManager} */
22 this.submenuManager_ = new remoting.SubmenuManager(
23 adapter,
24 chrome.i18n.getMessage(/*i18n-content*/'WINDOWS_SUBMENU_TITLE'),
25 false);
26 /** @private {function(string, string)} */
27 this.sendExtensionMessage_ = base.doNothing;
28
29 adapter.addListener(this.onContextMenu_.bind(this));
30 };
31
32 /**
33 * Add a window to the application's context menu, or update the title of an
34 * existing window.
35 *
36 * @param {number} id The window id.
37 * @param {string} title The window title.
38 */
39 remoting.WindowActivationMenu.prototype.add = function(id, title) {
40 this.submenuManager_.add(this.makeMenuId_(id), title);
41 // TODO(jamiewalch): Once crbug.com/426283 is fixed, call drawAttention()
42 // here if the window does not have focus.
43 };
44
45 /**
46 * Remove a window from the application's context menu.
47 *
48 * @param {number} id The window id.
49 */
50 remoting.WindowActivationMenu.prototype.remove = function(id) {
51 this.submenuManager_.remove(this.makeMenuId_(id));
52 };
53
54 /**
55 * Create a menu id from the given window id.
56 *
57 * @param {number} windowId
58 * @return {string}
59 * @private
60 */
61 remoting.WindowActivationMenu.prototype.makeMenuId_ = function(windowId) {
62 return 'window-' + windowId;
63 };
64
65 /** @param {function(string, string)} callback */
66 remoting.WindowActivationMenu.prototype.setExtensionMessageSender =
67 function(callback) {
68 this.sendExtensionMessage_ = callback;
69 };
70
71 /**
72 * Handle a click on the application's context menu.
73 *
74 * @param {OnClickData=} info
75 * @private
76 */
77 remoting.WindowActivationMenu.prototype.onContextMenu_ = function(info) {
78 var menuId = info.menuItemId.toString();
79 var components = menuId.split('-');
80 if (components.length == 2 &&
81 this.makeMenuId_(parseInt(components[1], 10)) == menuId) {
82 this.sendExtensionMessage_(
83 'activateWindow',
84 JSON.stringify({ id: parseInt(components[1], 0) }));
85 if (chrome.app.window.current().isMinimized()) {
86 chrome.app.window.current().restore();
87 }
88 }
89 };
OLDNEW
« no previous file with comments | « remoting/webapp/app_remoting/js/submenu_manager.js ('k') | remoting/webapp/app_remoting/manifest_common.json.jinja2 » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698