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

Side by Side Diff: remoting/webapp/app_remoting/js/context_menu_chrome.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 * remoting.ContextMenuAdapter implementation backed by chrome.contextMenus.
8 */
9
10 'use strict';
11
12 /** @suppress {duplicate} */
13 var remoting = remoting || {};
14
15 /**
16 * @constructor
17 * @implements {remoting.ContextMenuAdapter}
18 */
19 remoting.ContextMenuChrome = function() {};
20
21 remoting.ContextMenuChrome.prototype.dispose = function() {
22 chrome.contextMenus.removeAll();
23 };
24
25 /**
26 * @param {string} id An identifier for the menu entry.
27 * @param {string} title The text to display in the menu.
28 * @param {boolean} isCheckable True if the state of this menu entry should
29 * have a check-box and manage its toggle state automatically.
30 * @param {string=} opt_parentId The id of the parent menu item for submenus.
31 */
32 remoting.ContextMenuChrome.prototype.create = function(
33 id, title, isCheckable, opt_parentId) {
34 if (!opt_parentId) {
35 var message = {
36 method: 'addContextMenuId',
37 id: id
38 };
39 chrome.runtime.getBackgroundPage(this.postMessage_.bind(this, message));
40 }
41 var params = {
42 id: id,
43 contexts: ['launcher'],
44 title: title,
45 parentId: opt_parentId
46 };
47 if (isCheckable) {
48 params.type = 'checkbox';
49 }
50 chrome.contextMenus.create(params);
51 };
52
53 /**
54 * @param {string} id
55 * @param {string} title
56 */
57 remoting.ContextMenuChrome.prototype.updateTitle = function(id, title) {
58 chrome.contextMenus.update(id, {title: title});
59 };
60
61 /**
62 * @param {string} id
63 * @param {boolean} checked
64 */
65 remoting.ContextMenuChrome.prototype.updateCheckState = function(id, checked) {
66 chrome.contextMenus.update(id, {checked: checked});
67 };
68
69 /**
70 * @param {string} id
71 */
72 remoting.ContextMenuChrome.prototype.remove = function(id) {
73 chrome.contextMenus.remove(id);
74 var message = {
75 method: 'removeContextMenuId',
76 id: id
77 };
78 chrome.runtime.getBackgroundPage(this.postMessage_.bind(this, message));
79 };
80
81 /**
82 * @param {function(OnClickData):void} listener
83 */
84 remoting.ContextMenuChrome.prototype.addListener = function(listener) {
85 chrome.contextMenus.onClicked.addListener(
86 /** @type {function(Object, Tab=)} */ (listener));
87 };
88
89 /**
90 * @param {*} message
91 * @param {Window=} backgroundPage
92 */
93 remoting.ContextMenuChrome.prototype.postMessage_ = function(
94 message, backgroundPage) {
95 backgroundPage.postMessage(message, '*');
96 };
OLDNEW
« no previous file with comments | « remoting/webapp/app_remoting/js/context_menu_adapter.js ('k') | remoting/webapp/app_remoting/js/context_menu_dom.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698