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

Side by Side Diff: safari/ext/background.js

Issue 6236888415338496: Issue 1611 - Fixed inconsistent behavior with "Block element" context menu item (Closed)
Patch Set: Created Nov. 26, 2014, 11:28 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include.postload.js ('k') | safari/ext/content.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 return; 261 return;
262 262
263 var page = pages[event.userInfo.pageId]; 263 var page = pages[event.userInfo.pageId];
264 var items = contextMenuItems.get(page); 264 var items = contextMenuItems.get(page);
265 if (!items) 265 if (!items)
266 return; 266 return;
267 267
268 var context = event.userInfo.tagName; 268 var context = event.userInfo.tagName;
269 if (context == "img") 269 if (context == "img")
270 context = "image"; 270 context = "image";
271 if (!event.userInfo.srcUrl)
272 context = null;
273 271
274 for (var i = 0; i < items.length; i++) 272 for (var i = 0; i < items.length; i++)
275 { 273 {
276 // Supported contexts are: all, audio, image, video 274 // Supported contexts are: all, audio, image, video
277 var menuItem = items[i]; 275 var menuItem = items[i];
278 if (menuItem.contexts.indexOf("all") == -1 && menuItem.contexts.indexOf(co ntext) == -1) 276 if (menuItem.contexts.indexOf("all") == -1 && menuItem.contexts.indexOf(co ntext) == -1)
279 continue; 277 continue;
280 278
281 event.contextMenu.appendContextMenuItem(i, menuItem.title); 279 event.contextMenu.appendContextMenuItem(i, menuItem.title);
282 } 280 }
283 }); 281 });
284 282
285 safari.application.addEventListener("command", function(event) 283 safari.application.addEventListener("command", function(event)
286 { 284 {
287 var page = pages[event.userInfo.pageId]; 285 var page = pages[event.userInfo.pageId];
288 var items = contextMenuItems.get(page); 286 var items = contextMenuItems.get(page);
289 287
290 items[event.command].onclick(event.userInfo.srcUrl, page); 288 items[event.command].onclick(page);
291 }); 289 });
292 290
293 291
294 /* Web requests */ 292 /* Web requests */
295 293
296 ext.webRequest = { 294 ext.webRequest = {
297 onBeforeRequest: new ext._EventTarget(true), 295 onBeforeRequest: new ext._EventTarget(true),
298 handlerBehaviorChanged: function() {} 296 handlerBehaviorChanged: function() {}
299 }; 297 };
300 298
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 page.activate(); 670 page.activate();
673 if (callback) 671 if (callback)
674 callback(page); 672 callback(page);
675 return; 673 return;
676 } 674 }
677 } 675 }
678 676
679 ext.pages.open(optionsUrl, callback); 677 ext.pages.open(optionsUrl, callback);
680 }; 678 };
681 })(); 679 })();
OLDNEW
« no previous file with comments | « include.postload.js ('k') | safari/ext/content.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld