Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Unified Diff: components/dom_distiller/content/renderer/distillability_agent.cc

Issue 1705323004: Support blacklisting domains for Reader Mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/dom_distiller/content/renderer/distillability_agent.cc
diff --git a/components/dom_distiller/content/renderer/distillability_agent.cc b/components/dom_distiller/content/renderer/distillability_agent.cc
index 99592ef0b6fef51c3ca712a6de556bd29d3c8e33..e50ef666475d2d15a61e905f376a10b708f8df1f 100644
--- a/components/dom_distiller/content/renderer/distillability_agent.cc
+++ b/components/dom_distiller/content/renderer/distillability_agent.cc
@@ -50,6 +50,19 @@ bool IsLast(bool is_loaded) {
return true;
}
+const char* const kBlacklist[] = {
mdjones 2016/02/18 17:13:27 Being a constant, this could probably be at the to
+ "www.reddit.com"
+};
+
+bool IsBlacklisted(const GURL& url) {
+ for (size_t i = 0; i < arraysize(kBlacklist); ++i) {
+ if (base::LowerCaseEqualsASCII(url.host(), kBlacklist[i])) {
+ return true;
+ }
+ }
+ return false;
+}
+
bool IsDistillablePageAdaboost(WebDocument& doc,
const DistillablePageDetector* detector,
bool is_last) {
@@ -68,6 +81,7 @@ bool IsDistillablePageAdaboost(WebDocument& doc,
features.mozScoreAllSqrt,
features.mozScoreAllLinear
));
+ bool blacklisted = IsBlacklisted(parsed_url);
int bucket = static_cast<unsigned>(features.isMobileFriendly) |
(static_cast<unsigned>(distillable) << 1);
@@ -78,7 +92,8 @@ bool IsDistillablePageAdaboost(WebDocument& doc,
UMA_HISTOGRAM_ENUMERATION("DomDistiller.PageDistillableAfterParsing",
bucket, 4);
}
- return distillable && (!features.isMobileFriendly);
+
+ return distillable && (!features.isMobileFriendly) && (!blacklisted);
}
bool IsDistillablePage(WebDocument& doc, bool is_last) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698