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

Side by Side Diff: content/browser/frame_host/mixed_content_navigation_throttle.h

Issue 1905033002: PlzNavigate: Move navigation-level mixed content checks to the browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@console-security-message
Patch Set: Now using shared scheme collections from url_util.h. Created 3 years, 11 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 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 class MixedContentNavigationThrottle : public NavigationThrottle {
34 public:
35 static std::unique_ptr<NavigationThrottle> CreateThrottleForNavigation(
36 NavigationHandle* navigation_handle);
37
38 MixedContentNavigationThrottle(NavigationHandle* navigation_handle);
39 ~MixedContentNavigationThrottle() override;
40
41 // NavigationThrottle overrides.
42 ThrottleCheckResult WillStartRequest() override;
43 ThrottleCheckResult WillRedirectRequest() override;
44 ThrottleCheckResult WillProcessResponse() override;
45
46 private:
47 FRIEND_TEST_ALL_PREFIXES(MixedContentNavigationThrottleTest, IsMixedContent);
48
49 // Copy of all mixed content related values from the blink::UseCounter enum.
50 enum UseCounterFeature {
51 MIXED_CONTENT_FORMS_SUBMITTED = 441,
52 MIXED_CONTENT_PRIVATE_HOSTNAME_IN_PUBLIC_HOSTNAME = 530,
53 MIXED_CONTENT_PRESENT = 609,
54 MIXED_CONTENT_BLOCKABLE = 610,
55 MIXED_CONTENT_AUDIO = 611,
56 MIXED_CONTENT_DOWNLOAD = 612,
57 MIXED_CONTENT_FAVICON = 613,
58 MIXED_CONTENT_IMAGE = 614,
59 MIXED_CONTENT_INTERNAL = 615,
60 MIXED_CONTENT_PLUGIN = 616,
61 MIXED_CONTENT_PREFETCH = 617,
62 MIXED_CONTENT_VIDEO = 618,
63 MIXED_CONTENT_IN_NON_HTTPS_FRAME_THAT_RESTRICTS_MIXED_CONTENT = 661,
64 MIXED_CONTENT_IN_SECURE_FRAME_THAT_DOES_NOT_RESTRICT_MIXED_CONTENT = 662,
65 MIXED_CONTENT_WEB_SOCKET = 663,
66 MIXED_CONTENT_FORM_PRESENT = 665,
67 MIXED_CONTENT_BLOCKABLE_ALLOWED = 896,
68 BLOCKABLE_MIXED_CONTENT_IN_SUBFRAME_BLOCKED = 966,
69 };
70
71 // Checks if a navigation should be blocked or not due to mixed content.
72 bool ShouldBlockNavigation(bool for_redirect);
73
74 // Returns the parent frame where mixed content exists for the provided data
75 // or nullptr if there is no mixed content.
76 FrameTreeNode* InWhichFrameIsContentMixed(FrameTreeNode* node,
77 const GURL& url);
78
79 // Updates the renderer about any Blink feature usage.
80 void MaybeSendBlinkFeatureUsageReport();
81
82 // Records basic mixed content "feature" usage when any kind of mixed content
83 // is found.
84 void ReportBasicMixedContentFeatures(
85 RequestContextType request_context_type,
86 blink::WebMixedContentContextType mixed_content_context_type,
87 const WebPreferences& prefs);
88
89 static bool CONTENT_EXPORT IsMixedContentForTesting(const GURL& origin_url,
90 const GURL& url);
91
92 // Keeps track of mixed content features (as defined in blink::UseCounter)
93 // encountered while running one of the navigation throttling steps. These
94 // values are reported to the respective renderer process after each mixed
95 // content check is finished.
96 std::set<int> mixed_content_features_;
97
98 DISALLOW_COPY_AND_ASSIGN(MixedContentNavigationThrottle);
99 };
100
101 } // namespace content
102
103 #endif // CONTENT_BROWSER_FRAME_HOST_MIXED_CONTENT_NAVIGATION_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698