OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 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 #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 checks. It is | |
26 // only enabled if PlzNavigate is and checks only for frame-level resource loads | |
27 // (aka navigation loads). Sub-resources fetches are checked in the renderer | |
28 // process by MixedContentChecker. Changes to this class might need to be | |
29 // reflected on its renderer counterpart. | |
30 // | |
31 // Current mixed content W3C draft that drives this implementation: | |
32 // https://w3c.github.io/webappsec-mixed-content/ | |
33 // | |
34 // TODO(carlosk): For HSTS to work properly in PlzNavigate when these browser | |
35 // side mixed content checks happen it needs to be ported to the browser as a | |
36 // navigation throttle implementation. See https://crbug.com/691930. | |
nasko
2017/02/15 17:41:39
This bug talks about localhost, not HSTS. How are
carlosk
2017/02/15 21:46:31
I linked the wrong bug. Thanks for catching it! Fi
| |
37 class MixedContentNavigationThrottle : public NavigationThrottle { | |
38 public: | |
39 static std::unique_ptr<NavigationThrottle> CreateThrottleForNavigation( | |
40 NavigationHandle* navigation_handle); | |
41 | |
42 MixedContentNavigationThrottle(NavigationHandle* navigation_handle); | |
43 ~MixedContentNavigationThrottle() override; | |
44 | |
45 // NavigationThrottle overrides. | |
46 ThrottleCheckResult WillStartRequest() override; | |
47 ThrottleCheckResult WillRedirectRequest() override; | |
48 ThrottleCheckResult WillProcessResponse() override; | |
49 | |
50 private: | |
51 FRIEND_TEST_ALL_PREFIXES(MixedContentNavigationThrottleTest, IsMixedContent); | |
52 | |
53 // Copy of mixed content related values from the blink::UseCounter enum that | |
54 // are needed to report feature usage during browser side checks. | |
55 enum UseCounterFeature { | |
56 MIXED_CONTENT_PRESENT = 609, | |
57 MIXED_CONTENT_BLOCKABLE = 610, | |
58 MIXED_CONTENT_INTERNAL = 615, | |
59 MIXED_CONTENT_PREFETCH = 617, | |
60 MIXED_CONTENT_IN_NON_HTTPS_FRAME_THAT_RESTRICTS_MIXED_CONTENT = 661, | |
61 MIXED_CONTENT_IN_SECURE_FRAME_THAT_DOES_NOT_RESTRICT_MIXED_CONTENT = 662, | |
62 MIXED_CONTENT_BLOCKABLE_ALLOWED = 896, | |
63 }; | |
64 | |
65 // Checks if a navigation should be blocked or not due to mixed content. | |
66 bool ShouldBlockNavigation(bool for_redirect); | |
67 | |
68 // Returns the parent frame where mixed content exists for the provided data | |
69 // or nullptr if there is no mixed content. | |
70 FrameTreeNode* InWhichFrameIsContentMixed(FrameTreeNode* node, | |
71 const GURL& url); | |
72 | |
73 // Updates the renderer about any Blink feature usage. | |
74 void MaybeSendBlinkFeatureUsageReport(); | |
75 | |
76 // Records basic mixed content "feature" usage when any kind of mixed content | |
77 // is found. | |
78 void ReportBasicMixedContentFeatures( | |
79 RequestContextType request_context_type, | |
80 blink::WebMixedContentContextType mixed_content_context_type, | |
81 const WebPreferences& prefs); | |
82 | |
83 static bool CONTENT_EXPORT IsMixedContentForTesting(const GURL& origin_url, | |
84 const GURL& url); | |
85 | |
86 // Keeps track of mixed content features (as defined in blink::UseCounter) | |
87 // encountered while running one of the navigation throttling steps. These | |
88 // values are reported to the respective renderer process after each mixed | |
89 // content check is finished. | |
90 std::set<int> mixed_content_features_; | |
91 | |
92 DISALLOW_COPY_AND_ASSIGN(MixedContentNavigationThrottle); | |
93 }; | |
94 | |
95 } // namespace content | |
96 | |
97 #endif // CONTENT_BROWSER_FRAME_HOST_MIXED_CONTENT_NAVIGATION_THROTTLE_H_ | |
OLD | NEW |