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

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: Minor changes to code and commenst Created 3 years, 10 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_PRESENT = 609,
52 MIXED_CONTENT_BLOCKABLE = 610,
53 MIXED_CONTENT_INTERNAL = 615,
54 MIXED_CONTENT_PREFETCH = 617,
55 MIXED_CONTENT_IN_NON_HTTPS_FRAME_THAT_RESTRICTS_MIXED_CONTENT = 661,
56 MIXED_CONTENT_IN_SECURE_FRAME_THAT_DOES_NOT_RESTRICT_MIXED_CONTENT = 662,
57 MIXED_CONTENT_BLOCKABLE_ALLOWED = 896,
58 };
59
60 // Checks if a navigation should be blocked or not due to mixed content.
61 bool ShouldBlockNavigation(bool for_redirect);
62
63 // Returns the parent frame where mixed content exists for the provided data
64 // or nullptr if there is no mixed content.
65 FrameTreeNode* InWhichFrameIsContentMixed(FrameTreeNode* node,
66 const GURL& url);
67
68 // Updates the renderer about any Blink feature usage.
69 void MaybeSendBlinkFeatureUsageReport();
70
71 // Records basic mixed content "feature" usage when any kind of mixed content
72 // is found.
73 void ReportBasicMixedContentFeatures(
74 RequestContextType request_context_type,
75 blink::WebMixedContentContextType mixed_content_context_type,
76 const WebPreferences& prefs);
77
78 static bool CONTENT_EXPORT IsMixedContentForTesting(const GURL& origin_url,
79 const GURL& url);
80
81 // Keeps track of mixed content features (as defined in blink::UseCounter)
82 // encountered while running one of the navigation throttling steps. These
83 // values are reported to the respective renderer process after each mixed
84 // content check is finished.
85 std::set<int> mixed_content_features_;
86
87 DISALLOW_COPY_AND_ASSIGN(MixedContentNavigationThrottle);
88 };
89
90 } // namespace content
91
92 #endif // CONTENT_BROWSER_FRAME_HOST_MIXED_CONTENT_NAVIGATION_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698