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

Side by Side Diff: chrome/renderer/app_categorizer.cc

Issue 1974413003: Whitelist hangouts.google.com further to allow video effects plugin access. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Swapping comments 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 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
10 namespace {
11 // Note: all domain names here must be in lowercase (see GURL::DomainIs, which
12 // properly handles sub-domains).
13
14 const char* const kPredefinedHangoutsDomains[] = {
15 "hangouts.google.com",
16 "meet.google.com",
17 "talkgadget.google.com",
18 "plus.google.com",
19 "plus.sandbox.google.com"
20 };
21
22 const char* const kPredefinedPlusDomains[] = {
23 "plus.google.com",
24 "plus.sandbox.google.com"
25 };
26
27 bool isInWhitelistedDomain(
28 const GURL& url, const char* const domains[], size_t numberOfDomains) {
29 for (size_t i = 0; i < numberOfDomains; ++i) {
30 if (url.DomainIs(domains[i])) {
31 return true;
32 }
33 }
34
35 return false;
36 }
37
38 } // namespace
39
40 namespace app_categorizer {
41 // Whitelisted apps must be served over https.
42
43 bool IsHangoutsUrl(const GURL& url) {
Tom Sepez 2016/05/18 23:42:19 I think we need to lowercase the domain in both of
AlexZ 2016/05/19 16:18:51 No, GURL handles this. Added a test for this and i
Tom Sepez 2016/05/20 16:35:09 Acknowledged.
44 return url.SchemeIsCryptographic() &&
45 base::StartsWith(url.path(), "/hangouts/",
Tom Sepez 2016/05/18 23:42:19 This doesn't add much security as it turns out, si
AlexZ 2016/05/19 16:18:51 Pre-existing. Leaving it as-is.
46 base::CompareCase::INSENSITIVE_ASCII) &&
47 isInWhitelistedDomain(
48 url,
49 kPredefinedHangoutsDomains,
50 arraysize(kPredefinedHangoutsDomains));
51 }
52
53 bool IsWhitelistedApp(const GURL& manifest_url, const GURL& app_url) {
54 if (!app_url.SchemeIsCryptographic())
55 return false;
56
57 std::string manifest_url_path = manifest_url.path();
58 bool is_photo_app =
59 manifest_url.SchemeIsCryptographic() &&
60 manifest_url.DomainIs("ssl.gstatic.com") &&
61 (manifest_url_path.find("s2/oz/nacl/") == 1 ||
Tom Sepez 2016/05/18 23:42:19 put in a leading "/" in your literal and check for
AlexZ 2016/05/19 16:18:52 No idea why this was written this way but base::St
62 manifest_url_path.find("photos/nacl/") == 1) &&
63 isInWhitelistedDomain(
64 app_url,
65 kPredefinedPlusDomains,
66 arraysize(kPredefinedPlusDomains));
67
68 bool is_hangouts_app =
69 manifest_url.SchemeIsFileSystem() &&
70 manifest_url.inner_url() != NULL &&
71 manifest_url.inner_url()->SchemeIsCryptographic() &&
72 // The manifest must be loaded from the host's FileSystem.
73 (manifest_url.inner_url()->host() == app_url.host()) &&
74 IsHangoutsUrl(app_url);
75
76 return is_photo_app || is_hangouts_app;
77 }
78
79 } // namespace app_categorizer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698