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

Unified Diff: chrome/ext/background.js

Issue 29374674: Issue 4864 - Start using ESLint for adblockpluschrome (Closed)
Patch Set: Rebased. Created March 7, 2017, 10:44 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/devtools.js ('k') | chrome/ext/common.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/ext/background.js
diff --git a/chrome/ext/background.js b/chrome/ext/background.js
index aa8adbabad64b9470c3716213285e7a8d113ceb2..01be1eee2fa150b95b334022cfffdb33e0748b83 100644
--- a/chrome/ext/background.js
+++ b/chrome/ext/background.js
@@ -57,24 +57,24 @@
function afterTabLoaded(callback)
{
- return openedTab =>
- {
- let onUpdated = (tabId, changeInfo, tab) =>
- {
- if (tabId == openedTab.id && changeInfo.status == "complete")
- {
- chrome.tabs.onUpdated.removeListener(onUpdated);
- callback(new Page(openedTab));
- }
- };
- chrome.tabs.onUpdated.addListener(onUpdated);
- };
+ return openedTab =>
+ {
+ let onUpdated = (tabId, changeInfo, tab) =>
+ {
+ if (tabId == openedTab.id && changeInfo.status == "complete")
+ {
+ chrome.tabs.onUpdated.removeListener(onUpdated);
+ callback(new Page(openedTab));
+ }
+ };
+ chrome.tabs.onUpdated.addListener(onUpdated);
+ };
}
ext.pages = {
open(url, callback)
{
- chrome.tabs.create({url: url}, callback && afterTabLoaded(callback));
+ chrome.tabs.create({url}, callback && afterTabLoaded(callback));
},
query(info, callback)
{
@@ -122,7 +122,7 @@
{
if (frameId == 0)
{
- let page = new Page({id: tabId, url: url});
+ let page = new Page({id: tabId, url});
ext._removeFromAllPageMaps(tabId);
@@ -143,7 +143,7 @@
let frame = createFrame(tabId, frameId);
frame.url = new URL(url);
frame.parent = framesOfTabs[tabId][parentFrameId] || null;
- };
+ }
chrome.webRequest.onHeadersReceived.addListener(details =>
{
@@ -189,7 +189,7 @@
let disposition = header.value.split(";")[0].replace(/[ \t]+$/, "");
if (disposition.toLowerCase() != "inline" &&
/^[\x21-\x7E]+$/.test(disposition) &&
- !/[()<>@,;:\\"/\[\]?={}]/.test(disposition))
+ !/[()<>@,;:\\"/[\]?={}]/.test(disposition))
return;
}
@@ -302,7 +302,7 @@
},
_queueChanges()
{
- chrome.tabs.get(this._tabId, function()
+ chrome.tabs.get(this._tabId, () =>
{
// If the tab is prerendered, chrome.tabs.get() sets
// chrome.runtime.lastError and we have to delay our changes
@@ -321,10 +321,8 @@
chrome.tabs.onReplaced.addListener(onReplaced);
}
else
- {
this._applyChanges();
- }
- }.bind(this));
+ });
},
_addChange(name, value)
{
@@ -343,9 +341,7 @@
setBadge(badge)
{
if (!badge)
- {
this._addChange("badgeText", "");
- }
else
{
if ("number" in badge)
@@ -446,7 +442,8 @@
return (framesOfTabs[tabId] || {})[frameId];
};
- let handlerBehaviorChangedQuota = chrome.webRequest.MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES;
+ let handlerBehaviorChangedQuota =
+ chrome.webRequest.MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES;
function propagateHandlerBehaviorChange()
{
@@ -455,7 +452,9 @@
// Otherwise Chrome notifies the user that this extension is causing issues.
if (handlerBehaviorChangedQuota > 0)
{
- chrome.webNavigation.onBeforeNavigate.removeListener(propagateHandlerBehaviorChange);
+ chrome.webNavigation.onBeforeNavigate.removeListener(
+ propagateHandlerBehaviorChange
+ );
chrome.webRequest.handlerBehaviorChanged();
handlerBehaviorChangedQuota--;
@@ -471,7 +470,7 @@
// There wouldn't be any visible effect when calling it earlier,
// but it's an expensive operation and that way we avoid to call
// it multiple times, if multiple filters are added/removed.
- let onBeforeNavigate = chrome.webNavigation.onBeforeNavigate;
+ let {onBeforeNavigate} = chrome.webNavigation;
if (!onBeforeNavigate.hasListener(propagateHandlerBehaviorChange))
onBeforeNavigate.addListener(propagateHandlerBehaviorChange);
}
@@ -488,11 +487,16 @@
let frames = framesOfTabs[tab.id] = Object.create(null);
for (let i = 0; i < details.length; i++)
- frames[details[i].frameId] = {url: new URL(details[i].url), parent: null};
+ {
+ frames[details[i].frameId] = {
+ url: new URL(details[i].url),
+ parent: null
+ };
+ }
for (let i = 0; i < details.length; i++)
{
- let parentFrameId = details[i].parentFrameId;
+ let {parentFrameId} = details[i];
if (parentFrameId != -1)
frames[details[i].frameId].parent = frames[parentFrameId];
@@ -514,17 +518,11 @@
// has triggered this request. For most requests (e.g. images) we
// can just use the request's frame ID, but for subdocument requests
// (e.g. iframes) we must instead use the request's parent frame ID.
- let frameId;
- let requestType;
- if (details.type == "sub_frame")
+ let {frameId, type} = details;
+ if (type == "sub_frame")
{
frameId = details.parentFrameId;
- requestType = "SUBDOCUMENT";
- }
- else
- {
- frameId = details.frameId;
- requestType = details.type.toUpperCase();
+ type = "SUBDOCUMENT";
}
let frame = ext.getFrame(details.tabId, frameId);
@@ -532,7 +530,7 @@
{
let results = ext.webRequest.onBeforeRequest._dispatch(
new URL(details.url),
- requestType,
+ type.toUpperCase(),
new Page({id: details.tabId}),
frame
);
@@ -572,7 +570,9 @@
};
}
- return ext.onMessage._dispatch(message, sender, sendResponse).indexOf(true) != -1;
+ return ext.onMessage._dispatch(
+ message, sender, sendResponse
+ ).indexOf(true) != -1;
});
@@ -603,9 +603,7 @@
ext.showOptions = callback =>
{
if (!callback)
- {
chrome.runtime.openOptionsPage();
- }
else
{
chrome.runtime.openOptionsPage(() =>
@@ -657,9 +655,7 @@
callback(new Page(tab));
}
else
- {
ext.pages.open(optionsUrl, callback);
- }
});
});
};
« no previous file with comments | « chrome/devtools.js ('k') | chrome/ext/common.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld