OLD | NEW |
(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 #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. 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 MIXED_CONTENT_FORMS_SUBMITTED = 441, |
| 49 MIXED_CONTENT_PRIVATE_HOSTNAME_IN_PUBLIC_HOSTNAME = 530, |
| 50 MIXED_CONTENT_PRESENT = 609, |
| 51 MIXED_CONTENT_BLOCKABLE = 610, |
| 52 MIXED_CONTENT_AUDIO = 611, |
| 53 MIXED_CONTENT_DOWNLOAD = 612, |
| 54 MIXED_CONTENT_FAVICON = 613, |
| 55 MIXED_CONTENT_IMAGE = 614, |
| 56 MIXED_CONTENT_INTERNAL = 615, |
| 57 MIXED_CONTENT_PLUGIN = 616, |
| 58 MIXED_CONTENT_PREFETCH = 617, |
| 59 MIXED_CONTENT_VIDEO = 618, |
| 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_WEB_SOCKET = 663, |
| 63 MIXED_CONTENT_FORM_PRESENT = 665, |
| 64 MIXED_CONTENT_BLOCKABLE_ALLOWED = 896, |
| 65 BLOCKABLE_MIXED_CONTENT_IN_SUBFRAME_BLOCKED = 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 if any Blink features were used. |
| 77 void MaybeSendBlinkFeatureUsageReport(); |
| 78 |
| 79 // Reports basic mixed content features when any kinds of mixed is found. |
| 80 void ReportBasicMixedContentFeatures( |
| 81 RequestContextType request_context_type, |
| 82 blink::WebMixedContentContextType mixed_content_context_type, |
| 83 const WebPreferences& prefs); |
| 84 |
| 85 static bool CONTENT_EXPORT IsMixedContentForTesting(const GURL& origin_url, |
| 86 const GURL& url); |
| 87 |
| 88 // Keeps track of mixed content features (as defined in UseCounter) |
| 89 // encountered while running one of the navigation throttling steps. These |
| 90 // values are reported to the respective renderer process once mixed content |
| 91 // checking is finished. |
| 92 std::set<int> mixed_content_features_; |
| 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(MixedContentNavigationThrottle); |
| 95 }; |
| 96 |
| 97 } // namespace content |
| 98 |
| 99 #endif // CONTENT_BROWSER_FRAME_HOST_MIXED_CONTENT_NAVIGATION_THROTTLE_H_ |
OLD | NEW |