Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: chrome/background.js

Issue 5589897452716032: Implemented ext.contextMenus for Safari (Closed)
Patch Set: Moved code to safari/content.js Created Jan. 7, 2014, 3 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « background.js ('k') | include.postload.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/background.js
===================================================================
--- a/chrome/background.js
+++ b/chrome/background.js
@@ -370,10 +370,11 @@
handlerBehaviorChanged: chrome.webRequest.handlerBehaviorChanged
};
+ var contextMenu = [];
ext.contextMenus = {
- create: function(title, contexts, onclick)
+ addMenuItem: function(title, contexts, onclick)
{
- chrome.contextMenus.create({
+ contextMenu.push({
title: title,
contexts: contexts,
onclick: function(info, tab)
@@ -382,9 +383,29 @@
}
});
},
- removeAll: function(callback)
+ removeMenuItems: function()
{
- chrome.contextMenus.removeAll(callback);
+ contextMenu = [];
+ },
+ showMenu: function()
+ {
+ chrome.contextMenus.removeAll(function()
+ {
+ for (var i = 0; i < contextMenu.length; i++)
+ {
+ var item = contextMenu[i];
+ chrome.contextMenus.create({
+ title: item.title,
+ contexts: item.contexts,
+ onclick: item.onclick
+ });
+ }
+ });
+ },
+ hideMenu: function()
+ {
+ chrome.contextMenus.removeAll();
}
};
+
})();
« no previous file with comments | « background.js ('k') | include.postload.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld