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
|