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

Side by Side Diff: remoting/webapp/background.js

Issue 23536033: Add 'New window' option to context menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 chrome.app.runtime.onLaunched.addListener(function() { 5 /** @type {string} */
6 var kNewWindowId = 'new-window';
7
8 function createWindow() {
6 chrome.app.window.create('main.html', { 9 chrome.app.window.create('main.html', {
7 'width': 800, 10 'width': 800,
8 'height': 600 11 'height': 600
9 }); 12 });
10 }); 13 };
14
15 /** @param {OnClickData} info */
16 function onContextMenu(info) {
17 if (info.menuItemId == kNewWindowId) {
18 createWindow();
19 }
20 };
21
22 function initializeContextMenu() {
23 try {
24 chrome.contextMenus.remove(kNewWindowId);
25 } catch (ignore) {
26 // There is no way to detect if the context menu is already added, therefore
27 // try to recreate it every time.
Lambros 2013/09/06 22:16:14 This is the only place you're adding the context m
Jamie 2013/09/06 23:45:50 I added it because the sample I based it on did so
28 }
29 chrome.contextMenus.create({
30 id: kNewWindowId,
31 contexts: ['launcher'],
32 title: chrome.i18n.getMessage(/*i18n-content*/'NEW_WINDOW')
33 });
34 }
35
36 chrome.app.runtime.onLaunched.addListener(createWindow);
37 chrome.contextMenus.onClicked.addListener(onContextMenu);
38 initializeContextMenu();
Lambros 2013/09/06 22:16:14 Shouldn't we call this from remoting.init() (or th
Jamie 2013/09/06 23:45:50 This is the background page. It gets run when the
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698