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

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: Addressed all jam@ latest comments. 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 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 #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
17 namespace blink {
18 enum class WebMixedContentContextType;
19 }
20
21 namespace content {
22
23 class FrameTreeNode;
24 struct WebPreferences;
25
26 using ThrottleCheckResult = NavigationThrottle::ThrottleCheckResult;
27
28 // Responsible for browser process side mixed-content security. It checks only
29 // for frame-level resource loads (aka navigation loads); fetching of
30 // sub-resources are checked in the renderer process by MixedContentChecker.
31 // Changes to this class might need to be reflected on its renderer counterpart.
32 //
33 // Current mixed content draft that drives this implementation:
34 // https://w3c.github.io/webappsec-mixed-content/
35 class MixedContentNavigationThrottle : public NavigationThrottle {
36 public:
37 MixedContentNavigationThrottle(NavigationHandle* navigation_handle);
38 ~MixedContentNavigationThrottle() override;
39
40 ThrottleCheckResult WillStartRequest() override;
41
42 ThrottleCheckResult WillRedirectRequest() override;
43
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 MixedContentFormsSubmitted = 441,
jam 2017/01/09 21:15:46 It's unfortunate to copy these enums between webki
carlosk 2017/01/10 19:13:11 The inertia for those values ever changing is very
jam 2017/01/10 19:28:37 just to be clear, I had meant that the content def
carlosk 2017/01/10 20:03:59 Acknowledged. Will keep all as is then.
carlosk 2017/01/11 03:32:21 In fact I still had to re-case the enum values so.
52 MixedContentPrivateHostnameInPublicHostname = 530,
53 MixedContentPresent = 609,
54 MixedContentBlockable = 610,
55 MixedContentAudio = 611,
56 MixedContentDownload = 612,
57 MixedContentFavicon = 613,
58 MixedContentImage = 614,
59 MixedContentInternal = 615,
60 MixedContentPlugin = 616,
61 MixedContentPrefetch = 617,
62 MixedContentVideo = 618,
63 MixedContentInNonHTTPSFrameThatRestrictsMixedContent = 661,
64 MixedContentInSecureFrameThatDoesNotRestrictMixedContent = 662,
65 MixedContentWebSocket = 663,
66 MixedContentFormPresent = 665,
67 MixedContentBlockableAllowed = 896,
68 BlockableMixedContentInSubframeBlocked = 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 null if there is no mixed content.
76 FrameTreeNode* InWhichFrameIsContentMixed(FrameTreeNode* node,
77 const GURL& url);
78
79 // Updates the renderer if any Blink features were used.
80 void MaybeSendBlinkFeatureUsageReport();
81
82 // Reports basic mixed content features when any kinds of mixed is found.
83 void ReportBasicMixedContentFeatures(
84 RequestContextType request_context_type,
85 blink::WebMixedContentContextType mixed_content_context_type,
86 const WebPreferences& prefs);
87
88 static bool CONTENT_EXPORT IsMixedContentForTesting(const GURL& origin_url,
89 const GURL& url);
90
91 // Keeps track of mixed content features (as defined in UseCounter)
92 // encountered while running one of the navigation throttling steps. These
93 // values are reported to the respective renderer process once mixed content
94 // checking is finished.
95 std::set<int> mixed_content_features_;
96
97 DISALLOW_COPY_AND_ASSIGN(MixedContentNavigationThrottle);
98 };
99
100 } // namespace content
101
102 #endif // CONTENT_BROWSER_FRAME_HOST_MIXED_CONTENT_NAVIGATION_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698