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

Unified Diff: options.js

Issue 29339192: Issue 3880 - Improve behavior of Safari content blocker option (Closed)
Patch Set: Don't persists whether Safari needs to be restarted Created March 31, 2016, 3:15 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 | « options.html ('k') | skin/options.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: options.js
===================================================================
--- a/options.js
+++ b/options.js
@@ -707,7 +707,7 @@
{
getPref(key, function(value)
{
- onPrefMessage(key, value);
+ onPrefMessage(key, value, true);
});
});
ext.backgroundPage.sendMessage(
@@ -718,7 +718,14 @@
function(features)
{
hidePref("show_devtools_panel", !features.devToolsPanel);
- hidePref("safari_contentblocker", !features.safariContentBlocker);
+
+ // Only show option to switch between Safari Content Blockers
+ // and event based blocking if both are available.
+ hidePref("safari_contentblocker", !(
+ features.safariContentBlocker &&
+ "canLoad" in safari.self.tab &&
+ "onbeforeload" in Element.prototype
+ ));
});
var filterTextbox = document.querySelector("#custom-filters-add input");
@@ -1021,17 +1028,26 @@
}
};
- function onPrefMessage(key, value)
+ function onPrefMessage(key, value, initial)
{
+ switch (key)
+ {
+ case "notifications_ignoredcategories":
+ value = value.indexOf("*") == -1;
+ break;
+
+ case "notifications_showui":
+ hidePref("notifications_ignoredcategories", !value);
+ break;
+
+ case "safari_contentblocker":
+ E("restart-safari").setAttribute("aria-hidden", value || initial);
+ break;
+ }
+
var checkbox = document.querySelector("[data-pref='" + key + "'] button[role='checkbox']");
if (checkbox)
- {
- if (key == "notifications_ignoredcategories")
- value = (value.indexOf("*") == -1);
checkbox.setAttribute("aria-checked", value);
- }
- else if (key == "notifications_showui")
- hidePref("notifications_ignoredcategories", !value);
}
function onShareLinkClick(e)
@@ -1093,7 +1109,7 @@
onFilterMessage(message.action, message.args[0]);
break;
case "prefs.respond":
- onPrefMessage(message.action, message.args[0]);
+ onPrefMessage(message.action, message.args[0], false);
break;
case "subscriptions.respond":
onSubscriptionMessage(message.action, message.args[0]);
« no previous file with comments | « options.html ('k') | skin/options.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld