Sample that shows how to use the context menu API in an app to manage various application context menus, such as…
Sample that shows how to use the context menu API in an app to manage various application context menus, such as menus that only apply to particular windows, menus that apply to selections or media types, and context menus that work on the app launcher.
A single context menu structure is normally global to the entire app, and thus all windows would have the same menu. This sample uses a focus event handler in each window to detect when a window is brought to the foreground. When it is, the contents of the context menu are updated with that window's commands, while leaving the other menus intact. The chrome.contextMenus.onClicked event handler also only handles events that occur in that window.
See the source code at https://github.com/GoogleChrome/chrome-app-samples/tree/master/context-menu