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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/mixed_content_navigation_throttle.h
diff --git a/content/browser/frame_host/mixed_content_navigation_throttle.h b/content/browser/frame_host/mixed_content_navigation_throttle.h
new file mode 100644
index 0000000000000000000000000000000000000000..1317ef43561ff2c78232f20a84a05f5aaf86344f
--- /dev/null
+++ b/content/browser/frame_host/mixed_content_navigation_throttle.h
@@ -0,0 +1,102 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_FRAME_HOST_MIXED_CONTENT_NAVIGATION_THROTTLE_H_
+#define CONTENT_BROWSER_FRAME_HOST_MIXED_CONTENT_NAVIGATION_THROTTLE_H_
+
+#include <set>
+
+#include "base/gtest_prod_util.h"
+#include "base/macros.h"
+#include "content/common/content_export.h"
+#include "content/public/browser/navigation_handle.h"
+#include "content/public/browser/navigation_throttle.h"
+#include "content/public/common/request_context_type.h"
+
+namespace blink {
+enum class WebMixedContentContextType;
+}
+
+namespace content {
+
+class FrameTreeNode;
+struct WebPreferences;
+
+using ThrottleCheckResult = NavigationThrottle::ThrottleCheckResult;
+
+// Responsible for browser process side mixed-content security. It checks only
+// for frame-level resource loads (aka navigation loads); fetching of
+// sub-resources are checked in the renderer process by MixedContentChecker.
+// Changes to this class might need to be reflected on its renderer counterpart.
+//
+// Current mixed content draft that drives this implementation:
+// https://w3c.github.io/webappsec-mixed-content/
+class MixedContentNavigationThrottle : public NavigationThrottle {
+ public:
+ MixedContentNavigationThrottle(NavigationHandle* navigation_handle);
+ ~MixedContentNavigationThrottle() override;
+
+ ThrottleCheckResult WillStartRequest() override;
+
+ ThrottleCheckResult WillRedirectRequest() override;
+
+ ThrottleCheckResult WillProcessResponse() override;
+
+ private:
+ FRIEND_TEST_ALL_PREFIXES(MixedContentNavigationThrottleTest, IsMixedContent);
+
+ // Copy of all mixed content related values from the blink::UseCounter enum.
+ enum UseCounterFeature {
+ 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.
+ MixedContentPrivateHostnameInPublicHostname = 530,
+ MixedContentPresent = 609,
+ MixedContentBlockable = 610,
+ MixedContentAudio = 611,
+ MixedContentDownload = 612,
+ MixedContentFavicon = 613,
+ MixedContentImage = 614,
+ MixedContentInternal = 615,
+ MixedContentPlugin = 616,
+ MixedContentPrefetch = 617,
+ MixedContentVideo = 618,
+ MixedContentInNonHTTPSFrameThatRestrictsMixedContent = 661,
+ MixedContentInSecureFrameThatDoesNotRestrictMixedContent = 662,
+ MixedContentWebSocket = 663,
+ MixedContentFormPresent = 665,
+ MixedContentBlockableAllowed = 896,
+ BlockableMixedContentInSubframeBlocked = 966,
+ };
+
+ // Checks if a navigation should be blocked or not due to mixed content.
+ bool ShouldBlockNavigation(bool for_redirect);
+
+ // Returns the parent frame where mixed content exists for the provided data
+ // or null if there is no mixed content.
+ FrameTreeNode* InWhichFrameIsContentMixed(FrameTreeNode* node,
+ const GURL& url);
+
+ // Updates the renderer if any Blink features were used.
+ void MaybeSendBlinkFeatureUsageReport();
+
+ // Reports basic mixed content features when any kinds of mixed is found.
+ void ReportBasicMixedContentFeatures(
+ RequestContextType request_context_type,
+ blink::WebMixedContentContextType mixed_content_context_type,
+ const WebPreferences& prefs);
+
+ static bool CONTENT_EXPORT IsMixedContentForTesting(const GURL& origin_url,
+ const GURL& url);
+
+ // Keeps track of mixed content features (as defined in UseCounter)
+ // encountered while running one of the navigation throttling steps. These
+ // values are reported to the respective renderer process once mixed content
+ // checking is finished.
+ std::set<int> mixed_content_features_;
+
+ DISALLOW_COPY_AND_ASSIGN(MixedContentNavigationThrottle);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_FRAME_HOST_MIXED_CONTENT_NAVIGATION_THROTTLE_H_

Powered by Google App Engine
This is Rietveld 408576698