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

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: Rebase after 3 spin off CLs landed. Created 3 years, 12 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 content {
18
19 class FrameTreeNode;
20 class RenderFrameHost;
21 struct WebPreferences;
22
23 using ThrottleCheckResult = NavigationThrottle::ThrottleCheckResult;
24
25 // Responsible for browser process side mixed-content security. It checks only
26 // for frame-level resource loads (aka navigation loads); fetching of
27 // sub-resources are checked in the renderer process by MixedContentChecker.
28 // Changes to this class might need to be reflected on its renderer counterpart.
29 //
30 // Current mixed content draft that drives this implementation:
31 // https://w3c.github.io/webappsec-mixed-content/
32 class MixedContentNavigationThrottle : public NavigationThrottle {
33 public:
34 MixedContentNavigationThrottle(NavigationHandle* navigation_handle);
35 ~MixedContentNavigationThrottle() override;
36
37 ThrottleCheckResult WillStartRequest() override;
38
39 ThrottleCheckResult WillRedirectRequest() override;
40
41 ThrottleCheckResult WillProcessResponse() override;
42
43 private:
44 FRIEND_TEST_ALL_PREFIXES(MixedContentNavigationThrottleTest, IsMixedContent);
45
46 // Copy of all mixed content related values from the blink::UseCounter enum.
47 enum UseCounterFeature {
48 MixedContentFormsSubmitted = 441,
49 MixedContentPrivateHostnameInPublicHostname = 530,
50 MixedContentPresent = 609,
51 MixedContentBlockable = 610,
52 MixedContentAudio = 611,
53 MixedContentDownload = 612,
54 MixedContentFavicon = 613,
55 MixedContentImage = 614,
56 MixedContentInternal = 615,
57 MixedContentPlugin = 616,
58 MixedContentPrefetch = 617,
59 MixedContentVideo = 618,
60 MixedContentInNonHTTPSFrameThatRestrictsMixedContent = 661,
61 MixedContentInSecureFrameThatDoesNotRestrictMixedContent = 662,
62 MixedContentWebSocket = 663,
63 MixedContentFormPresent = 665,
64 MixedContentBlockableAllowed = 896,
65 BlockableMixedContentInSubframeBlocked = 966,
66 };
67
68 // Checks if a navigation should be blocked or not due to mixed content.
69 bool ShouldBlockNavigation(bool for_redirect);
70
71 // Returns the parent frame where mixed content exists for the provided data
72 // or null if there is no mixed content.
73 FrameTreeNode* InWhichFrameIsContentMixed(FrameTreeNode* node,
74 const GURL& url);
75
76 // Updates the renderer in regards to mixed content checked in the browser, if
77 // necessary.
78 void MaybeSendRendererUpdate(RenderFrameHost* rfh,
79 bool for_redirect,
80 bool has_mixed_content);
81
82 // Reports basic mixed content features when any kinds of mixed is found.
83 void ReportBasicMixedContentFeatures(RequestContextType context,
84 const WebPreferences& prefs);
85
86 static bool CONTENT_EXPORT IsMixedContentForTesting(const GURL& origin_url,
87 const GURL& url);
88
89 // Keeps track of mixed content features (as defined in UseCounter)
90 // encountered while running one of the navigation throttling steps. These
91 // values are reported to the respective renderer process once mixed content
92 // checking is finished.
93 std::set<int> mixed_content_features_;
94
95 DISALLOW_COPY_AND_ASSIGN(MixedContentNavigationThrottle);
96 };
97
98 } // namespace content
99
100 #endif // CONTENT_BROWSER_FRAME_HOST_MIXED_CONTENT_NAVIGATION_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698