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

Unified Diff: third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp

Issue 2873973002: CORS: Measure some ways in which we might tighten CORS processing.
Patch Set: Rebase. Created 3 years, 7 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: third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp
diff --git a/third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp b/third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp
index 7031a1942e53ea1ae76dddcee584c27fc5759480..7e9c54c2b8913beeafa6daf56d171c083cd01007 100644
--- a/third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp
@@ -600,6 +600,8 @@ bool DocumentThreadableLoader::RedirectReceived(
builder, cors_status, redirect_response, GetSecurityOrigin(),
request_context_);
access_control_error_description = builder.ToString();
+ } else {
+ MeasureAccessControlAllowOrigin(redirect_response);
}
}
@@ -733,6 +735,8 @@ void DocumentThreadableLoader::HandlePreflightResponse(
builder, cors_status, response, GetSecurityOrigin(), request_context_);
HandlePreflightFailure(response.Url().GetString(), builder.ToString());
return;
+ } else {
+ MeasureAccessControlAllowOrigin(response);
}
CrossOriginAccessControl::PreflightStatus preflight_status =
@@ -852,6 +856,8 @@ void DocumentThreadableLoader::HandleResponse(
ResourceError(kErrorDomainBlinkInternal, 0,
response.Url().GetString(), builder.ToString()));
return;
+ } else {
+ MeasureAccessControlAllowOrigin(response);
}
}
@@ -1162,6 +1168,30 @@ Document* DocumentThreadableLoader::GetDocument() const {
return loading_context_->GetLoadingDocument();
}
+void DocumentThreadableLoader::MeasureAccessControlAllowOrigin(
+ const ResourceResponse& response) const {
+ DEFINE_STATIC_LOCAL(AtomicString, null_token, ("null"));
+ const AtomicString& acao =
+ response.HttpHeaderField(HTTPNames::Access_Control_Allow_Origin);
+ if (acao == null_token && EffectiveAllowCredentials()) {
+ loading_context_->RecordUseCount(
+ UseCounter::kAccessControlAllowOriginNullWithCredentials);
+ }
+ if (SecurityOrigin::IsSecure(response.Url()) &&
+ !GetSecurityOrigin()->IsPotentiallyTrustworthy()) {
+ if (acao == g_star_atom) {
+ loading_context_->RecordUseCount(
+ UseCounter::kAccessControlAllowOriginInsecureStarFromHTTPS);
+ } else if (acao == null_token) {
+ loading_context_->RecordUseCount(
+ UseCounter::kAccessControlAllowOriginInsecureNullFromHTTPS);
+ } else {
+ loading_context_->RecordUseCount(
+ UseCounter::kAccessControlAllowOriginInsecureExplicitFromHTTPS);
+ }
+ }
+}
+
DEFINE_TRACE(DocumentThreadableLoader) {
visitor->Trace(resource_);
visitor->Trace(loading_context_);
« no previous file with comments | « third_party/WebKit/Source/core/loader/DocumentThreadableLoader.h ('k') | tools/metrics/histograms/enums.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698