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

Unified Diff: chrome/browser/android/url_utilities.cc

Issue 2480153003: Add a TLD whitelist for Google Search URLs. (Closed)
Patch Set: Disable intent:// links to instant apps from non-SERP pages. Created 4 years, 1 month 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 | « chrome/android/java/src/org/chromium/chrome/browser/instantapps/InstantAppsHandler.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/url_utilities.cc
diff --git a/chrome/browser/android/url_utilities.cc b/chrome/browser/android/url_utilities.cc
index cc7d3d1f63fb9a8ee1e22a72e24f1b250e482d16..584759a0de1b2d9d92fc1a70e27d5fe207c74498 100644
--- a/chrome/browser/android/url_utilities.cc
+++ b/chrome/browser/android/url_utilities.cc
@@ -26,6 +26,44 @@ static const char* const g_downloadable_schemes[] = {
static const char* const g_fallback_valid_schemes[] = {
"http", "https", nullptr };
+// TODO(mariakhomenko): figure out how to keep this list updated.
battre (please use the other) 2016/11/11 22:54:10 IsCanonicalHostGoogleHostname in components/google
+static const char* const g_google_tld_list[] = {"ac", "ad", "ae", "af", "ag",
+ "al", "am", "as", "at", "aw", "az", "ba", "be", "bf", "bg", "bi", "biz",
+ "bj", "bm", "bn", "bo", "bs", "bt", "by", "bz", "ca", "cat", "cc", "cd",
+ "cf", "cg", "ch", "ci", "cl", "cm", "cn", "co", "co.ao", "co.at", "co.ba",
+ "co.bi", "co.bw", "co.ci", "co.ck", "co.cr", "co.gg", "co.gl", "co.gy",
+ "co.hu", "co.id", "co.il", "co.im", "co.in", "co.it", "co.je", "co.jp",
+ "co.ke", "co.kr", "co.ls", "co.ma", "co.mu", "co.mw", "co.mz", "co.nz",
+ "co.pn", "co.rs", "co.th", "co.tt", "co.tz", "co.ua", "co.ug", "co.uk",
+ "co.uz", "co.ve", "co.vi", "co.za", "co.zm", "co.zw", "com", "com.af",
+ "com.ag", "com.ai", "com.ar", "com.au", "com.az", "com.bd", "com.bh",
+ "com.bi", "com.bn", "com.bo", "com.br", "com.bs", "com.by", "com.bz",
+ "com.cn", "com.co", "com.cu", "com.cy", "com.do", "com.dz", "com.ec",
+ "com.eg", "com.er", "com.et", "com.fj", "com.ge", "com.gh", "com.gi",
+ "com.gl", "com.gp", "com.gr", "com.gt", "com.gy", "com.hk", "com.hn",
+ "com.hr", "com.ht", "com.iq", "com.jm", "com.jo", "com.kg", "com.kh",
+ "com.ki", "com.kw", "com.kz", "com.lb", "com.lc", "com.lk", "com.lv",
+ "com.ly", "com.mk", "com.mm", "com.mt", "com.mu", "com.mw", "com.mx",
+ "com.my", "com.na", "com.nc", "com.nf", "com.ng", "com.ni", "com.np",
+ "com.nr", "com.om", "com.pa", "com.pe", "com.pg", "com.ph", "com.pk",
+ "com.pl", "com.pr", "com.ps", "com.pt", "com.py", "com.qa", "com.ru",
+ "com.sa", "com.sb", "com.sc", "com.sg", "com.sl", "com.sv", "com.tj",
+ "com.tm", "com.tn", "com.tr", "com.tt", "com.tw", "com.ua", "com.uy",
+ "com.uz", "com.vc", "com.ve", "com.vi", "com.vn", "com.ws", "cv", "cx",
+ "cz", "de", "dj", "dk", "dm", "do", "dz", "ec", "ee", "es", "eu", "fi",
+ "fm", "fr", "ga", "gd", "ge", "gf", "gg", "gl", "gm", "gp", "gr", "gw",
+ "gy", "hk", "hn", "hr", "ht", "hu", "ie", "im", "in", "info", "in.rs", "io",
+ "iq", "is", "it", "it.ao", "je", "jo", "jobs", "jp", "kg", "ki", "kids.us",
+ "km", "kn", "kr", "kz", "la", "li", "lk", "lt", "lu", "lv", "ma", "md",
+ "me", "mg", "mh", "mk", "ml", "mn", "mobi", "mr", "ms", "mu", "mv", "mw",
+ "mx", "name", "ne", "ne.jp", "net", "net.in", "net.nz", "nf", "ng", "nl",
+ "no", "nom.es", "nr", "nu", "off.ai", "org", "org.af", "org.es", "org.in",
+ "org.nz", "org.uk", "pf", "ph", "pk", "pl", "pn", "pr", "pro", "ps", "pt",
+ "qa", "re", "ro", "rs", "ru", "rw", "sc", "se", "sg", "sh", "si", "sk",
+ "sl", "sm", "sn", "so", "sr", "st", "sz", "td", "tel", "tg", "tk", "tl",
+ "tm", "tn", "to", "tt", "tv", "tw", "ua", "ug", "us", "uz", "vc", "vg",
+ "vn", "vu", "ws", "yt"};
+
GURL ConvertJavaStringToGURL(JNIEnv* env, jstring url) {
return url ? GURL(ConvertJavaStringToUTF8(env, url)) : GURL();
}
@@ -103,7 +141,26 @@ static jboolean IsGoogleSearchUrl(JNIEnv* env,
GURL gurl = ConvertJavaStringToGURL(env, url);
if (gurl.is_empty())
return false;
- return google_util::IsGoogleSearchUrl(gurl);
+ bool is_search = google_util::IsGoogleSearchUrl(gurl);
battre (please use the other) 2016/11/11 22:54:10 Wouldn't it make sense to move the logic into this
+ if (!is_search)
+ return is_search;
+
+ size_t length = net::registry_controlled_domains::GetRegistryLength(
+ gurl,
+ net::registry_controlled_domains::EXCLUDE_UNKNOWN_REGISTRIES,
+ net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES);
+ if ((length == 0) || (length == std::string::npos))
+ return false;
+
+ std::string tld(gurl.host().substr(gurl.host().length() - length,
+ std::string::npos));
+ // TODO(mariakhomenko): binary search instead?
+ for (size_t i = 0; g_google_tld_list[i]; i++) {
+ if (g_google_tld_list[i] == tld) {
+ return true;
+ }
+ }
+ return false;
}
static jboolean IsGoogleHomePageUrl(JNIEnv* env,
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/instantapps/InstantAppsHandler.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698