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

Side by Side Diff: background.js

Issue 6622721232338944: Issue 1268 - Correctly mimic Chrome's behavior when opening the options page (Closed)
Patch Set: Created Aug. 26, 2014, 2:43 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 | « .hgsubstate ('k') | chrome/ext/background.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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 else 276 else
277 notifyUser(); 277 notifyUser();
278 } 278 }
279 279
280 Prefs.addListener(function(name) 280 Prefs.addListener(function(name)
281 { 281 {
282 if (name == "shouldShowBlockElementMenu") 282 if (name == "shouldShowBlockElementMenu")
283 refreshIconAndContextMenuForAllPages(); 283 refreshIconAndContextMenuForAllPages();
284 }); 284 });
285 285
286 /**
287 * Opens options page or focuses an existing one, within the last focused windo w.
288 * @param {Function} callback function to be called with the
289 Page object of the options page
290 */
291 function openOptions(callback)
292 {
293 ext.pages.query({lastFocusedWindow: true}, function(pages)
294 {
295 var optionsUrl = ext.getURL("options.html");
296
297 for (var i = 0; i < pages.length; i++)
298 {
299 var page = pages[i];
300 if (page.url == optionsUrl)
301 {
302 page.activate();
303 if (callback)
304 callback(page);
305 return;
306 }
307 }
308
309 ext.pages.open(optionsUrl, callback);
310 });
311 }
312
313 function prepareNotificationIconAndPopup() 286 function prepareNotificationIconAndPopup()
314 { 287 {
315 var animateIcon = (activeNotification.type !== "question"); 288 var animateIcon = (activeNotification.type !== "question");
316 activeNotification.onClicked = function() 289 activeNotification.onClicked = function()
317 { 290 {
318 if (animateIcon) 291 if (animateIcon)
319 iconAnimation.stop(); 292 iconAnimation.stop();
320 notificationClosed(); 293 notificationClosed();
321 }; 294 };
322 if (animateIcon) 295 if (animateIcon)
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 } 544 }
572 break; 545 break;
573 case "add-filters": 546 case "add-filters":
574 if (msg.filters && msg.filters.length) 547 if (msg.filters && msg.filters.length)
575 { 548 {
576 for (var i = 0; i < msg.filters.length; i++) 549 for (var i = 0; i < msg.filters.length; i++)
577 FilterStorage.addFilter(Filter.fromText(msg.filters[i])); 550 FilterStorage.addFilter(Filter.fromText(msg.filters[i]));
578 } 551 }
579 break; 552 break;
580 case "add-subscription": 553 case "add-subscription":
581 openOptions(function(page) 554 ext.showOptions(function(page)
582 { 555 {
583 page.sendMessage(msg); 556 page.sendMessage(msg);
584 }); 557 });
585 break; 558 break;
586 case "add-key-exception": 559 case "add-key-exception":
587 processKeyException(msg.token, sender.page, sender.frame); 560 processKeyException(msg.token, sender.page, sender.frame);
588 break; 561 break;
589 case "forward": 562 case "forward":
590 if (sender.page) 563 if (sender.page)
591 { 564 {
(...skipping 15 matching lines...) Expand all
607 page.sendMessage({type: "clickhide-deactivate"}); 580 page.sendMessage({type: "clickhide-deactivate"});
608 refreshIconAndContextMenu(page); 581 refreshIconAndContextMenu(page);
609 }); 582 });
610 583
611 setTimeout(function() 584 setTimeout(function()
612 { 585 {
613 var notificationToShow = Notification.getNextToShow(); 586 var notificationToShow = Notification.getNextToShow();
614 if (notificationToShow) 587 if (notificationToShow)
615 showNotification(notificationToShow); 588 showNotification(notificationToShow);
616 }, 3 * 60 * 1000); 589 }, 3 * 60 * 1000);
OLDNEW
« no previous file with comments | « .hgsubstate ('k') | chrome/ext/background.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld