Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
|
nasko
2017/01/12 18:32:37
nit: We are now 2017 ;).
carlosk
2017/01/21 02:54:59
Done for all added files.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_FRAME_HOST_MIXED_CONTENT_NAVIGATION_THROTTLE_H_ | |
| 6 #define CONTENT_BROWSER_FRAME_HOST_MIXED_CONTENT_NAVIGATION_THROTTLE_H_ | |
| 7 | |
| 8 #include <set> | |
| 9 | |
| 10 #include "base/gtest_prod_util.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "content/common/content_export.h" | |
| 13 #include "content/public/browser/navigation_handle.h" | |
| 14 #include "content/public/browser/navigation_throttle.h" | |
| 15 #include "content/public/common/request_context_type.h" | |
| 16 #include "third_party/WebKit/public/platform/WebMixedContentContextType.h" | |
| 17 | |
| 18 namespace content { | |
| 19 | |
| 20 class FrameTreeNode; | |
| 21 struct WebPreferences; | |
| 22 | |
| 23 using ThrottleCheckResult = NavigationThrottle::ThrottleCheckResult; | |
| 24 | |
| 25 // Responsible for browser-process-side mixed-content security. It is only | |
|
nasko
2017/01/12 18:32:37
nit: security checks.
carlosk
2017/01/21 02:54:59
Done.
| |
| 26 // enabled if PlzNavigate is and checks only for frame-level resource loads (aka | |
| 27 // navigation loads). Sub-resources fetches are checked in the renderer process | |
| 28 // by MixedContentChecker. Changes to this class might need to be reflected on | |
| 29 // its renderer counterpart. | |
| 30 // | |
| 31 // Current mixed content W3C draft that drives this implementation: | |
| 32 // https://w3c.github.io/webappsec-mixed-content/ | |
| 33 class MixedContentNavigationThrottle : public NavigationThrottle { | |
| 34 public: | |
| 35 MixedContentNavigationThrottle(NavigationHandle* navigation_handle); | |
| 36 ~MixedContentNavigationThrottle() override; | |
| 37 | |
| 38 ThrottleCheckResult WillStartRequest() override; | |
| 39 | |
|
nasko
2017/01/12 18:32:37
nit: No need for empty spaces, can cluster all thr
carlosk
2017/01/21 02:54:58
Done.
| |
| 40 ThrottleCheckResult WillRedirectRequest() override; | |
| 41 | |
| 42 ThrottleCheckResult WillProcessResponse() override; | |
| 43 | |
| 44 private: | |
| 45 FRIEND_TEST_ALL_PREFIXES(MixedContentNavigationThrottleTest, IsMixedContent); | |
| 46 | |
| 47 // Copy of all mixed content related values from the blink::UseCounter enum. | |
| 48 enum UseCounterFeature { | |
| 49 MIXED_CONTENT_FORMS_SUBMITTED = 441, | |
|
nasko
2017/01/12 18:32:37
Can we use static_assert to ensure we don't accide
carlosk
2017/01/21 02:54:58
See: https://codereview.chromium.org/1905033002/di
| |
| 50 MIXED_CONTENT_PRIVATE_HOSTNAME_IN_PUBLIC_HOSTNAME = 530, | |
| 51 MIXED_CONTENT_PRESENT = 609, | |
| 52 MIXED_CONTENT_BLOCKABLE = 610, | |
| 53 MIXED_CONTENT_AUDIO = 611, | |
| 54 MIXED_CONTENT_DOWNLOAD = 612, | |
| 55 MIXED_CONTENT_FAVICON = 613, | |
| 56 MIXED_CONTENT_IMAGE = 614, | |
| 57 MIXED_CONTENT_INTERNAL = 615, | |
| 58 MIXED_CONTENT_PLUGIN = 616, | |
| 59 MIXED_CONTENT_PREFETCH = 617, | |
| 60 MIXED_CONTENT_VIDEO = 618, | |
| 61 MIXED_CONTENT_IN_NON_HTTPS_FRAME_THAT_RESTRICTS_MIXED_CONTENT = 661, | |
| 62 MIXED_CONTENT_IN_SECURE_FRAME_THAT_DOES_NOT_RESTRICT_MIXED_CONTENT = 662, | |
| 63 MIXED_CONTENT_WEB_SOCKET = 663, | |
| 64 MIXED_CONTENT_FORM_PRESENT = 665, | |
| 65 MIXED_CONTENT_BLOCKABLE_ALLOWED = 896, | |
| 66 BLOCKABLE_MIXED_CONTENT_IN_SUBFRAME_BLOCKED = 966, | |
| 67 }; | |
|
Mike West
2017/01/13 13:20:00
I know we talked about this a while ago, but looki
carlosk
2017/01/21 02:54:59
Why do you think this triggers only on redirects?
Mike West
2017/01/25 11:37:30
Because I think you should remove the early-exit f
carlosk
2017/02/08 02:59:02
I trimmed down the constants list to only contain
| |
| 68 | |
| 69 // Checks if a navigation should be blocked or not due to mixed content. | |
| 70 bool ShouldBlockNavigation(bool for_redirect); | |
| 71 | |
| 72 // Returns the parent frame where mixed content exists for the provided data | |
| 73 // or nullptr if there is no mixed content. | |
| 74 FrameTreeNode* InWhichFrameIsContentMixed(FrameTreeNode* node, | |
| 75 const GURL& url); | |
| 76 | |
| 77 // Updates the renderer about any Blink feature usage. | |
| 78 void MaybeSendBlinkFeatureUsageReport(); | |
| 79 | |
| 80 // Records basic mixed content "feature" usage when any kind of mixed is | |
|
nasko
2017/01/12 18:32:37
nit: s/mixed/mixed content/
carlosk
2017/01/21 02:54:59
Done.
| |
| 81 // found. | |
| 82 void ReportBasicMixedContentFeatures( | |
| 83 RequestContextType request_context_type, | |
| 84 blink::WebMixedContentContextType mixed_content_context_type, | |
| 85 const WebPreferences& prefs); | |
| 86 | |
| 87 static bool CONTENT_EXPORT IsMixedContentForTesting(const GURL& origin_url, | |
|
nasko
2017/01/12 18:32:37
Why is this method CONTENT_EXPORT and private at t
carlosk
2017/01/21 02:54:59
Because its unit test friend-ed in line 45 needs t
| |
| 88 const GURL& url); | |
| 89 | |
| 90 // Keeps track of mixed content features (as defined in blink::UseCounter) | |
| 91 // encountered while running one of the navigation throttling steps. These | |
| 92 // values are reported to the respective renderer process after each mixed | |
| 93 // content check is finished. | |
| 94 std::set<int> mixed_content_features_; | |
| 95 | |
| 96 DISALLOW_COPY_AND_ASSIGN(MixedContentNavigationThrottle); | |
| 97 }; | |
| 98 | |
| 99 } // namespace content | |
| 100 | |
| 101 #endif // CONTENT_BROWSER_FRAME_HOST_MIXED_CONTENT_NAVIGATION_THROTTLE_H_ | |
| OLD | NEW |