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

Side by Side Diff: background.js

Issue 5099207639695360: Made browser actions per tab on Safari (Closed)
Patch Set: Rebased, addressed comment and enabled to set global browser actions Created Jan. 15, 2014, 7:19 p.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 | « no previous file | chrome/ext/background.js » ('j') | chrome/ext/background.js » ('J')
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-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // when using Safari, because icons are grayscale already and icons 110 // when using Safari, because icons are grayscale already and icons
111 // aren't per tab in Safari. 111 // aren't per tab in Safari.
112 iconFilename = "icons/abp-16.png" 112 iconFilename = "icons/abp-16.png"
113 else 113 else
114 { 114 {
115 var excluded = isWhitelisted(tab.url); 115 var excluded = isWhitelisted(tab.url);
116 iconFilename = excluded ? "icons/abp-19-whitelisted.png" : "icons/abp-19.png "; 116 iconFilename = excluded ? "icons/abp-19-whitelisted.png" : "icons/abp-19.png ";
117 } 117 }
118 118
119 tab.browserAction.setIcon(iconFilename); 119 tab.browserAction.setIcon(iconFilename);
120 tab.browserAction.setTitle(ext.i18n.getMessage("name"));
121
122 iconAnimation.registerTab(tab, iconFilename); 120 iconAnimation.registerTab(tab, iconFilename);
123 121
124 // Set context menu status according to whether current tab has whitelisted do main 122 // Set context menu status according to whether current tab has whitelisted do main
125 if (excluded) 123 if (excluded)
126 chrome.contextMenus.removeAll(); 124 chrome.contextMenus.removeAll();
127 else 125 else
128 showContextMenu(); 126 showContextMenu();
129 } 127 }
130 128
131 /** 129 /**
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 // sendResponse asynchronously 402 // sendResponse asynchronously
405 return true; 403 return true;
406 } 404 }
407 break; 405 break;
408 default: 406 default:
409 sendResponse({}); 407 sendResponse({});
410 break; 408 break;
411 } 409 }
412 }); 410 });
413 411
412 // Set icon title/tooltip globally
413 ext.browserAction.setTitle(ext.i18n.getMessage("name"));
Wladimir Palant 2014/01/16 09:10:05 If you take this route then there should also be a
Sebastian Noack 2014/01/16 12:45:02 I think it is fine as it is. the default icon is a
Wladimir Palant 2014/01/16 12:55:18 The difference however is: Chrome will reset the i
Sebastian Noack 2014/01/16 14:01:52 Yes, but we backup the default (which comes from I
Wladimir Palant 2014/01/17 07:54:36 Ok, I see - setting the image explicitly is indeed
414
414 // Show icon as browser action for all tabs that already exist 415 // Show icon as browser action for all tabs that already exist
415 ext.windows.getAll(function(windows) 416 ext.windows.getAll(function(windows)
416 { 417 {
417 for (var i = 0; i < windows.length; i++) 418 for (var i = 0; i < windows.length; i++)
418 { 419 {
419 windows[i].getAllTabs(function(tabs) 420 windows[i].getAllTabs(function(tabs)
420 { 421 {
421 tabs.forEach(refreshIconAndContextMenu); 422 tabs.forEach(refreshIconAndContextMenu);
422 }); 423 });
423 } 424 }
424 }); 425 });
425 426
426 // Update icon if a tab changes location 427 // Update icon if a tab changes location
427 ext.tabs.onLoading.addListener(function(tab) 428 ext.tabs.onLoading.addListener(function(tab)
428 { 429 {
429 tab.sendMessage({type: "clickhide-deactivate"}); 430 tab.sendMessage({type: "clickhide-deactivate"});
430 refreshIconAndContextMenu(tab); 431 refreshIconAndContextMenu(tab);
431 }); 432 });
432 433
433 setTimeout(function() 434 setTimeout(function()
434 { 435 {
435 var notificationToShow = Notification.getNextToShow(); 436 var notificationToShow = Notification.getNextToShow();
436 if (notificationToShow) 437 if (notificationToShow)
437 showNotification(notificationToShow); 438 showNotification(notificationToShow);
438 }, 3 * 60 * 1000); 439 }, 3 * 60 * 1000);
OLDNEW
« no previous file with comments | « no previous file | chrome/ext/background.js » ('j') | chrome/ext/background.js » ('J')

Powered by Google App Engine
This is Rietveld