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

Side by Side 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, 6 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/renderer/app_categorizer.h"
6
7 #include "base/macros.h"
8 #include "base/strings/string_util.h"
9 #include "url/gurl.h"
10
11 namespace {
12 // Note: all domain names here must be in lowercase (see GURL::DomainIs, which
13 // properly handles sub-domains).
14
15 const char* const kPredefinedHangoutsDomains[] = {
16 "hangouts.google.com",
17 "meet.google.com",
18 "talkgadget.google.com",
19 "plus.google.com",
20 "plus.sandbox.google.com"
21 };
22
23 const char* const kPredefinedPlusDomains[] = {
24 "plus.google.com",
25 "plus.sandbox.google.com"
26 };
27
28 bool IsInWhitelistedDomain(
29 const GURL& url, const char* const domains[], size_t number_of_domains) {
30 for (size_t i = 0; i < number_of_domains; ++i) {
31 if (url.DomainIs(domains[i])) {
32 return true;
33 }
34 }
35
36 return false;
37 }
38
39 } // namespace
40
41 bool AppCategorizer::IsHangoutsUrl(const GURL& url) {
42 // Whitelisted apps must be served over https.
43 return url.SchemeIsCryptographic() &&
44 base::StartsWith(url.path(), "/hangouts/",
45 base::CompareCase::INSENSITIVE_ASCII) &&
46 IsInWhitelistedDomain(
47 url,
48 kPredefinedHangoutsDomains,
49 arraysize(kPredefinedHangoutsDomains));
50 }
51
52 bool AppCategorizer::IsWhitelistedApp(
53 const GURL& manifest_url, const GURL& app_url) {
54 // Whitelisted apps must be served over https.
55 if (!app_url.SchemeIsCryptographic())
56 return false;
57
58 std::string manifest_url_path = manifest_url.path();
59 bool is_photo_app =
60 manifest_url.SchemeIsCryptographic() &&
61 manifest_url.DomainIs("ssl.gstatic.com") &&
62 (base::StartsWith(manifest_url_path, "/s2/oz/nacl/",
63 base::CompareCase::SENSITIVE) ||
64 base::StartsWith(manifest_url_path, "/photos/nacl/",
65 base::CompareCase::SENSITIVE)) &&
66 IsInWhitelistedDomain(
67 app_url,
68 kPredefinedPlusDomains,
69 arraysize(kPredefinedPlusDomains));
70
71 bool is_hangouts_app =
72 manifest_url.SchemeIsFileSystem() &&
73 manifest_url.inner_url() != NULL &&
74 manifest_url.inner_url()->SchemeIsCryptographic() &&
75 // The manifest must be loaded from the host's FileSystem.
76 (manifest_url.inner_url()->host() == app_url.host()) &&
77 IsHangoutsUrl(app_url);
78
79 return is_photo_app || is_hangouts_app;
80 }
OLDNEW
« 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