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

Unified Diff: desktop-options.js

Issue 29570614: Issue 5028 - Use browser namespace (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Update adblockplusui dependency Created Oct. 17, 2017, 1:02 p.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 | « desktop-options.html ('k') | devtools.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: desktop-options.js
===================================================================
--- a/desktop-options.js
+++ b/desktop-options.js
@@ -45,17 +45,17 @@
let lastArg = paramValues[paramValues.length - 1];
if (typeof lastArg == "function")
callback = lastArg;
for (let i = 0; i < paramValues.length - (callback ? 1 : 0); i++)
message[paramKeys[i]] = paramValues[i];
}
- chrome.runtime.sendMessage(message, callback);
+ browser.runtime.sendMessage(message, callback);
};
}
const getDocLink = wrapper({type: "app.get", what: "doclink"}, "link");
const getInfo = wrapper({type: "app.get"}, "what");
const getPref = wrapper({type: "prefs.get"}, "key");
const togglePref = wrapper({type: "prefs.toggle"}, "key");
const getSubscriptions = wrapper({type: "subscriptions.get"},
@@ -86,17 +86,17 @@
let delayedSubscriptionSelection = null;
let acceptableAdsUrl;
// Loads options from localStorage and sets UI elements accordingly
function loadOptions()
{
// Set page title to i18n version of "Adblock Plus Options"
- document.title = chrome.i18n.getMessage("options");
+ document.title = browser.i18n.getMessage("options");
// Set links
getPref("subscriptions_exceptionsurl", url =>
{
acceptableAdsUrl = url;
$("#acceptableAdsLink").attr("href", acceptableAdsUrl);
});
getDocLink("acceptable_ads", url =>
@@ -156,30 +156,30 @@
});
getPref("notifications_showui", showNotificationsUI =>
{
if (!showNotificationsUI)
document.getElementById("shouldShowNotificationsContainer").hidden = true;
});
// Register listeners in the background message responder
- chrome.runtime.sendMessage({
+ browser.runtime.sendMessage({
type: "app.listen",
filter: ["addSubscription", "focusSection"]
});
- chrome.runtime.sendMessage({
+ browser.runtime.sendMessage({
type: "filters.listen",
filter: ["added", "loaded", "removed"]
});
- chrome.runtime.sendMessage({
+ browser.runtime.sendMessage({
type: "prefs.listen",
filter: ["notifications_ignoredcategories", "notifications_showui",
"show_devtools_panel", "shouldShowBlockElementMenu"]
});
- chrome.runtime.sendMessage({
+ browser.runtime.sendMessage({
type: "subscriptions.listen",
filter: ["added", "disabled", "homepage", "lastDownload", "removed",
"title", "downloadStatus", "downloading"]
});
// Load recommended subscriptions
loadRecommendations();
@@ -300,17 +300,17 @@
selectedPrefix = prefix;
}
}
}
list.appendChild(option);
}
let option = new Option();
- let label = chrome.i18n.getMessage("filters_addSubscriptionOther_label");
+ let label = browser.i18n.getMessage("filters_addSubscriptionOther_label");
option.text = label + "\u2026";
option._data = null;
list.appendChild(option);
list.selectedIndex = selectedIndex;
if (delayedSubscriptionSelection)
startSubscriptionSelection(...delayedSubscriptionSelection);
@@ -360,17 +360,17 @@
if (data)
addSubscription(data.url, data.title, data.homepage);
else
{
let url = document.getElementById("customSubscriptionLocation")
.value.trim();
if (!/^https?:/i.test(url))
{
- alert(chrome.i18n.getMessage("global_subscription_invalid_location"));
+ alert(browser.i18n.getMessage("global_subscription_invalid_location"));
$("#customSubscriptionLocation").focus();
return;
}
let title = document.getElementById("customSubscriptionTitle").value.trim();
if (!title)
title = url;
@@ -416,37 +416,37 @@
enabled.checked = !subscription.disabled;
let lastUpdate = element.getElementsByClassName("subscriptionUpdate")[0];
lastUpdate.classList.remove("error");
let {downloadStatus} = subscription;
if (subscription.isDownloading)
{
- lastUpdate.textContent = chrome.i18n.getMessage(
+ lastUpdate.textContent = browser.i18n.getMessage(
"filters_subscription_lastDownload_inProgress"
);
}
else if (downloadStatus && downloadStatus != "synchronize_ok")
{
if (statusMessages.has(downloadStatus))
{
- lastUpdate.textContent = chrome.i18n.getMessage(
+ lastUpdate.textContent = browser.i18n.getMessage(
statusMessages.get(downloadStatus)
);
}
else
lastUpdate.textContent = downloadStatus;
lastUpdate.classList.add("error");
}
else if (subscription.lastDownload > 0)
{
let timeDate = i18nTimeDateStrings(subscription.lastDownload * 1000);
let messageID = (timeDate[1] ? "last_updated_at" : "last_updated_at_today");
- lastUpdate.textContent = chrome.i18n.getMessage(messageID, timeDate);
+ lastUpdate.textContent = browser.i18n.getMessage(messageID, timeDate);
}
}
function onSubscriptionMessage(action, subscription)
{
let element = findSubscriptionElement(subscription);
switch (action)
@@ -651,17 +651,17 @@
let removeButton = element.getElementsByClassName(
"subscriptionRemoveButton"
)[0];
removeButton.setAttribute("title", removeButton.textContent);
removeButton.textContent = "\xD7";
removeButton.addEventListener("click", () =>
{
- if (!confirm(chrome.i18n.getMessage("global_remove_subscription_warning")))
+ if (!confirm(browser.i18n.getMessage("global_remove_subscription_warning")))
return;
removeSubscription(subscription.url);
}, false);
getPref("additional_subscriptions", additionalSubscriptions =>
{
if (additionalSubscriptions.includes(subscription.url))
« no previous file with comments | « desktop-options.html ('k') | devtools.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld