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: Corrected width and height of clickhide popup Created Jan. 7, 2014, 5:37 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 | « block.js ('k') | include.postload.js » ('j') | safari/background.js » ('J')
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 = [];
Wladimir Palant 2014/01/17 15:36:55 Nit: Would contextMenuItems be a better name?
Thomas Greiner 2014/01/18 10:32:05 Done.
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()
Wladimir Palant 2014/01/17 15:36:55 Nit: These methods should be called showMenuItems/
Thomas Greiner 2014/01/18 10:32:05 Done.
+ {
+ chrome.contextMenus.removeAll();
}
};
+
})();
Wladimir Palant 2014/01/17 15:36:55 The API here is somewhat unexpected - addMenuItem
Thomas Greiner 2014/01/18 10:32:05 Done. However, I decided to go with true as the de
« no previous file with comments | « block.js ('k') | include.postload.js » ('j') | safari/background.js » ('J')

Powered by Google App Engine
This is Rietveld