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
parent 1025efbb
...@@ -2358,6 +2358,7 @@ ...@@ -2358,6 +2358,7 @@
'host/win/core.rc.jinja2', 'host/win/core.rc.jinja2',
'host/win/host_messages.mc.jinja2', 'host/win/host_messages.mc.jinja2',
'host/win/version.rc.jinja2', 'host/win/version.rc.jinja2',
'webapp/background.js',
'webapp/butter_bar.js', 'webapp/butter_bar.js',
'webapp/client_screen.js', 'webapp/client_screen.js',
'webapp/error.js', 'webapp/error.js',
......
...@@ -680,6 +680,9 @@ ...@@ -680,6 +680,9 @@
<message desc="Menu option to open a new connection." name="IDR_NEW_CONNECTION"> <message desc="Menu option to open a new connection." name="IDR_NEW_CONNECTION">
New connection… New connection…
</message> </message>
<message desc="Menu option to open a new window." name="IDR_NEW_WINDOW">
New window…
</message>
</messages> </messages>
</release> </release>
</grit> </grit>
...@@ -37,13 +37,14 @@ index d1f8d1f..67bf660 100644 ...@@ -37,13 +37,14 @@ index d1f8d1f..67bf660 100644
"optional_permissions": [ "optional_permissions": [
"<all_urls>" "<all_urls>"
], ],
@@ -42,16 +28,21 @@ @@ -42,16 +28,22 @@
"clipboardRead", "clipboardRead",
"clipboardWrite", "clipboardWrite",
- "nativeMessaging" - "nativeMessaging"
+ "nativeMessaging", + "nativeMessaging",
+ "fullscreen", + "fullscreen",
+ "identity" + "identity",
+ "contextMenus"
], ],
- "plugins": [ - "plugins": [
- { "path": "remoting_host_plugin.dll", "public": false }, - { "path": "remoting_host_plugin.dll", "public": false },
......
...@@ -2,9 +2,31 @@ ...@@ -2,9 +2,31 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // 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', { chrome.app.window.create('main.html', {
'width': 800, 'width': 800,
'height': 600 '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();
...@@ -121,6 +121,36 @@ chrome.app.window = { ...@@ -121,6 +121,36 @@ chrome.app.window = {
create: function(name, parameters) {} 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} */ /** @type {Object} */
chrome.identity = { chrome.identity = {
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment