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

Unified Diff: chrome/renderer/app_categorizer.cc

Issue 2011623002: Cherry-picking hangouts.google.com whitelisting change into M52. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 7 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 | « chrome/renderer/app_categorizer.h ('k') | chrome/renderer/app_categorizer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/app_categorizer.cc
diff --git a/chrome/renderer/app_categorizer.cc b/chrome/renderer/app_categorizer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..42519779f555a46f96cbf139b90f19c3b105b78e
--- /dev/null
+++ b/chrome/renderer/app_categorizer.cc
@@ -0,0 +1,80 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/app_categorizer.h"
+
+#include "base/macros.h"
+#include "base/strings/string_util.h"
+#include "url/gurl.h"
+
+namespace {
+// Note: all domain names here must be in lowercase (see GURL::DomainIs, which
+// properly handles sub-domains).
+
+const char* const kPredefinedHangoutsDomains[] = {
+ "hangouts.google.com",
+ "meet.google.com",
+ "talkgadget.google.com",
+ "plus.google.com",
+ "plus.sandbox.google.com"
+};
+
+const char* const kPredefinedPlusDomains[] = {
+ "plus.google.com",
+ "plus.sandbox.google.com"
+};
+
+bool IsInWhitelistedDomain(
+ const GURL& url, const char* const domains[], size_t number_of_domains) {
+ for (size_t i = 0; i < number_of_domains; ++i) {
+ if (url.DomainIs(domains[i])) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+} // namespace
+
+bool AppCategorizer::IsHangoutsUrl(const GURL& url) {
+ // Whitelisted apps must be served over https.
+ return url.SchemeIsCryptographic() &&
+ base::StartsWith(url.path(), "/hangouts/",
+ base::CompareCase::INSENSITIVE_ASCII) &&
+ IsInWhitelistedDomain(
+ url,
+ kPredefinedHangoutsDomains,
+ arraysize(kPredefinedHangoutsDomains));
+}
+
+bool AppCategorizer::IsWhitelistedApp(
+ const GURL& manifest_url, const GURL& app_url) {
+ // Whitelisted apps must be served over https.
+ if (!app_url.SchemeIsCryptographic())
+ return false;
+
+ std::string manifest_url_path = manifest_url.path();
+ bool is_photo_app =
+ manifest_url.SchemeIsCryptographic() &&
+ manifest_url.DomainIs("ssl.gstatic.com") &&
+ (base::StartsWith(manifest_url_path, "/s2/oz/nacl/",
+ base::CompareCase::SENSITIVE) ||
+ base::StartsWith(manifest_url_path, "/photos/nacl/",
+ base::CompareCase::SENSITIVE)) &&
+ IsInWhitelistedDomain(
+ app_url,
+ kPredefinedPlusDomains,
+ arraysize(kPredefinedPlusDomains));
+
+ bool is_hangouts_app =
+ manifest_url.SchemeIsFileSystem() &&
+ manifest_url.inner_url() != NULL &&
+ manifest_url.inner_url()->SchemeIsCryptographic() &&
+ // The manifest must be loaded from the host's FileSystem.
+ (manifest_url.inner_url()->host() == app_url.host()) &&
+ IsHangoutsUrl(app_url);
+
+ return is_photo_app || is_hangouts_app;
+}
« no previous file with comments | « chrome/renderer/app_categorizer.h ('k') | chrome/renderer/app_categorizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698