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

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

Issue 29340571: Issue 3687 - Add experimental support for Safari content blockers (Closed)
Patch Set: Added note about bug report Created May 17, 2016, 4: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
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 { 377 {
378 }, 378 },
379 getIndistinguishableTypes: function() 379 getIndistinguishableTypes: function()
380 { 380 {
381 return []; 381 return [];
382 } 382 }
383 }; 383 };
384 384
385 /* Message processing */ 385 /* Message processing */
386 386
387 var dispatchedLegacyAPISupportMessage = false;
387 safari.application.addEventListener("message", function(event) 388 safari.application.addEventListener("message", function(event)
388 { 389 {
389 var tab = event.target; 390 var tab = event.target;
390 var message = event.message; 391 var message = event.message;
391 var sender; 392 var sender;
392 if ("documentId" in message && "_documentLookup" in tab) 393 if ("documentId" in message && "_documentLookup" in tab)
393 { 394 {
394 sender = tab._documentLookup[message.documentId]; 395 sender = tab._documentLookup[message.documentId];
395 if (sender) 396 if (sender)
396 { 397 {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 pageId = lastPageId; 497 pageId = lastPageId;
497 page = lastPage; 498 page = lastPage;
498 parentFrame = lastPageTopLevelFrame; 499 parentFrame = lastPageTopLevelFrame;
499 } 500 }
500 501
501 frameId = page._frames.length; 502 frameId = page._frames.length;
502 page._frames.push({url: new URL(message.url), parent: parentFrame}); 503 page._frames.push({url: new URL(message.url), parent: parentFrame});
503 } 504 }
504 505
505 tab._documentLookup[documentId] = {pageId: pageId, frameId: frameId}; 506 tab._documentLookup[documentId] = {pageId: pageId, frameId: frameId};
507
508 if (!dispatchedLegacyAPISupportMessage)
509 {
510 ext.onMessage._dispatch({
511 type: "safari.legacyAPISupported",
512 legacyAPISupported: message.legacyAPISupported
513 });
514 dispatchedLegacyAPISupportMessage = true;
515 }
506 break; 516 break;
507 case "documentId": 517 case "documentId":
508 tab._documentLookup[message.documentId] = { 518 tab._documentLookup[message.documentId] = {
509 pageId: message.pageId, frameId: 0 519 pageId: message.pageId, frameId: 0
510 }; 520 };
511 break; 521 break;
512 } 522 }
513 }); 523 });
514 524
515 525
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 /* Windows */ 597 /* Windows */
588 ext.windows = { 598 ext.windows = {
589 // Safari doesn't provide as rich a windows API as Chrome does, so instead 599 // Safari doesn't provide as rich a windows API as Chrome does, so instead
590 // of chrome.windows.create we have to fall back to just opening a new tab. 600 // of chrome.windows.create we have to fall back to just opening a new tab.
591 create: function(createData, callback) 601 create: function(createData, callback)
592 { 602 {
593 ext.pages.open(createData.url, callback); 603 ext.pages.open(createData.url, callback);
594 } 604 }
595 }; 605 };
596 })(); 606 })();
OLDNEW

Powered by Google App Engine
This is Rietveld