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

Delta Between Two Patch Sets: background.js

Issue 29573905: Issue 4580 - Replace ext.devtools with devtools Base URL: https://hg.adblockplus.org/adblockplusui/
Left Patch Set: Use runtime.onConnect Created Oct. 12, 2017, 1:22 a.m.
Right Patch Set: Rebase Created Oct. 18, 2017, 1:37 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | desktop-options.js » ('j') | polyfill.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 filterlistsReinitialized: false, 72 filterlistsReinitialized: false,
73 addSubscription: false, 73 addSubscription: false,
74 filterError: false, 74 filterError: false,
75 downloadStatus: "synchronize_ok", 75 downloadStatus: "synchronize_ok",
76 showNotificationUI: false, 76 showNotificationUI: false,
77 showPageOptions: false 77 showPageOptions: false
78 }; 78 };
79 updateFromURL(params); 79 updateFromURL(params);
80 80
81 let modules = {}; 81 let modules = {};
82 82 window.require = function(module)
83 window.require = module => modules[module]; 83 {
84 return modules[module];
85 };
84 86
85 modules.utils = { 87 modules.utils = {
86 Utils: { 88 Utils: {
87 getDocLink(link) 89 getDocLink(link)
88 { 90 {
89 return "https://adblockplus.org/redirect?link=" + encodeURIComponent(lin k); 91 return "https://adblockplus.org/redirect?link=" + encodeURIComponent(lin k);
90 }, 92 },
91 get appLocale() 93 get appLocale()
92 { 94 {
93 return chrome.i18n.getUILanguage(); 95 return browser.i18n.getUILanguage();
94 }, 96 },
95 get readingDirection() 97 get readingDirection()
96 { 98 {
97 return /^(?:ar|fa|he|ug|ur)\b/.test(this.appLocale) ? "rtl" : "ltr"; 99 return /^(?:ar|fa|he|ug|ur)\b/.test(this.appLocale) ? "rtl" : "ltr";
98 } 100 }
99 } 101 }
100 }; 102 };
101 103
102 modules.prefs = {Prefs: new EventEmitter()}; 104 modules.prefs = {Prefs: new EventEmitter()};
103 let prefs = { 105 let prefs = {
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 showOptions(callback) 411 showOptions(callback)
410 { 412 {
411 if (!/\/(?:mobile|desktop)-options\.html\b/.test(top.location.href)) 413 if (!/\/(?:mobile|desktop)-options\.html\b/.test(top.location.href))
412 window.open("desktop-options.html", "_blank"); 414 window.open("desktop-options.html", "_blank");
413 415
414 if (callback) 416 if (callback)
415 callback(); 417 callback();
416 } 418 }
417 }; 419 };
418 420
419 modules.requestBlocker = { 421 modules.requestBlocker = {
Manish Jethani 2017/10/12 01:30:02 Unrelated, but requestBlocker.filterTypes needs to
420 filterTypes: [] 422 filterTypes: []
421 }; 423 };
422 424
423 window.addEventListener("message", (event) => 425 window.addEventListener("message", (event) =>
424 { 426 {
425 if (event.data.type != "message") 427 if (event.data.type != "message")
426 return; 428 return;
427 let message = event.data.payload; 429 let message = event.data.payload;
428 let {messageId} = event.data; 430 let {messageId} = event.data;
429 let sender = { 431 let sender = {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 { 538 {
537 host, 539 host,
538 whitelisted: isWhitelisted 540 whitelisted: isWhitelisted
539 } 541 }
540 ] 542 ]
541 } 543 }
542 }, "*"); 544 }, "*");
543 }, 1000); 545 }, 1000);
544 } 546 }
545 547
546 chrome.runtime.onConnect.addListener(port => 548 browser.runtime.onConnect.addListener(port =>
Manish Jethani 2017/10/12 01:30:02 Use runtime.onConnect, what the real background pa
547 { 549 {
548 // blocked request 550 // blocked request
549 port.postMessage({ 551 port.postMessage({
550 type: "add-record", 552 type: "add-record",
551 request: { 553 request: {
552 url: "http://adserver.example.com/ad_banner.png", 554 url: "http://adserver.example.com/ad_banner.png",
553 type: "IMAGE", 555 type: "IMAGE",
554 docDomain: "example.com" 556 docDomain: "example.com"
555 }, 557 },
556 filter: { 558 filter: {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 }, 615 },
614 filter: { 616 filter: {
615 text: "||example.com/some-annoying-popup$popup", 617 text: "||example.com/some-annoying-popup$popup",
616 whitelisted: false, 618 whitelisted: false,
617 userDefined: true, 619 userDefined: true,
618 subscription: null 620 subscription: null
619 } 621 }
620 }); 622 });
621 }); 623 });
622 }()); 624 }());
LEFTRIGHT
« no previous file | desktop-options.js » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld