summaryrefslogtreecommitdiffstats
path: root/remoting/webapp
diff options
context:
space:
mode:
authorjamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-07 01:39:42 +0000
committerjamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-07 01:39:42 +0000
commitd160e49b32215b935f27c27e48d93bc5079f234f (patch)
treea98178dc28f7ace3602b0b9fac1c0b34bd02a30e /remoting/webapp
parent1025efbb94a59e33ca9125263c793c81c9f1972c (diff)
downloadchromium_src-d160e49b32215b935f27c27e48d93bc5079f234f.zip
chromium_src-d160e49b32215b935f27c27e48d93bc5079f234f.tar.gz
chromium_src-d160e49b32215b935f27c27e48d93bc5079f234f.tar.bz2
Add 'New window' option to context menu.
See https://codereview.chromium.org/18024002 for a similar example. Note that this API doesn't work on UNIX, so we still need an in-app method of opening a new window. BUG=252881 R=lambroslambrou@chromium.org Review URL: https://codereview.chromium.org/23536033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221852 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/webapp')
-rw-r--r--remoting/webapp/appsv2.patch5
-rw-r--r--remoting/webapp/background.js26
-rw-r--r--remoting/webapp/jscompiler_hacks.js30
3 files changed, 57 insertions, 4 deletions
diff --git a/remoting/webapp/appsv2.patch b/remoting/webapp/appsv2.patch
index 9deac20..7350ad4 100644
--- a/remoting/webapp/appsv2.patch
+++ b/remoting/webapp/appsv2.patch
@@ -37,13 +37,14 @@ index d1f8d1f..67bf660 100644
"optional_permissions": [
"<all_urls>"
],
-@@ -42,16 +28,21 @@
+@@ -42,16 +28,22 @@
"clipboardRead",
"clipboardWrite",
- "nativeMessaging"
+ "nativeMessaging",
+ "fullscreen",
-+ "identity"
++ "identity",
++ "contextMenus"
],
- "plugins": [
- { "path": "remoting_host_plugin.dll", "public": false },
diff --git a/remoting/webapp/background.js b/remoting/webapp/background.js
index 290b43a..118b7e57 100644
--- a/remoting/webapp/background.js
+++ b/remoting/webapp/background.js
@@ -2,9 +2,31 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-chrome.app.runtime.onLaunched.addListener(function() {
+/** @type {string} */
+var kNewWindowId = 'new-window';
+
+function createWindow() {
chrome.app.window.create('main.html', {
'width': 800,
'height': 600
});
-});
+};
+
+/** @param {OnClickData} info */
+function onContextMenu(info) {
+ if (info.menuItemId == kNewWindowId) {
+ createWindow();
+ }
+};
+
+function initializeContextMenu() {
+ chrome.contextMenus.create({
+ id: kNewWindowId,
+ contexts: ['launcher'],
+ title: chrome.i18n.getMessage(/*i18n-content*/'NEW_WINDOW')
+ });
+}
+
+chrome.app.runtime.onLaunched.addListener(createWindow);
+chrome.contextMenus.onClicked.addListener(onContextMenu);
+initializeContextMenu();
diff --git a/remoting/webapp/jscompiler_hacks.js b/remoting/webapp/jscompiler_hacks.js
index ad4d755..57c9419 100644
--- a/remoting/webapp/jscompiler_hacks.js
+++ b/remoting/webapp/jscompiler_hacks.js
@@ -121,6 +121,36 @@ chrome.app.window = {
create: function(name, parameters) {}
};
+/**
+ * @type {Object}
+ * @see http://code.google.com/chrome/extensions/dev/contextMenus.html
+ */
+chrome.contextMenus = {
+ /** @type {chrome.Event} */
+ onClicked: null,
+ /**
+ * @param {!Object} createProperties
+ * @param {function()=} opt_callback
+ * @return {string|number}
+ */
+ create: function(createProperties, opt_callback) {},
+ /**
+ * @param {string|number} menuItemId
+ * @param {function()=} opt_callback
+ */
+ remove: function(menuItemId, opt_callback) {},
+ /**
+ * @param {function()=} opt_callback
+ */
+ removeAll: function(opt_callback) {},
+ /**
+ * @param {string|number} id
+ * @param {!Object} updateProperties
+ * @param {function()=} opt_callback
+ */
+ update: function(id, updateProperties, opt_callback) {}
+};
+
/** @type {Object} */
chrome.identity = {
/**