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

Side by Side Diff: third_party/WebKit/Source/core/loader/MixedContentChecker.cpp

Issue 2002003002: Generate CSP violation reports for 'block-all-mixed-content' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 308
309 // static 309 // static
310 bool MixedContentChecker::shouldBlockFetch(LocalFrame* frame, WebURLRequest::Req uestContext requestContext, WebURLRequest::FrameType frameType, const KURL& url, MixedContentChecker::ReportingStatus reportingStatus) 310 bool MixedContentChecker::shouldBlockFetch(LocalFrame* frame, WebURLRequest::Req uestContext requestContext, WebURLRequest::FrameType frameType, const KURL& url, MixedContentChecker::ReportingStatus reportingStatus)
311 { 311 {
312 Frame* effectiveFrame = effectiveFrameForFrameType(frame, frameType); 312 Frame* effectiveFrame = effectiveFrameForFrameType(frame, frameType);
313 Frame* mixedFrame = inWhichFrameIsContentMixed(effectiveFrame, frameType, ur l); 313 Frame* mixedFrame = inWhichFrameIsContentMixed(effectiveFrame, frameType, ur l);
314 if (!mixedFrame) 314 if (!mixedFrame)
315 return false; 315 return false;
316 316
317 MixedContentChecker::count(mixedFrame, requestContext); 317 MixedContentChecker::count(mixedFrame, requestContext);
318 if (ContentSecurityPolicy* policy = frame->securityContext()->contentSecurit yPolicy())
319 policy->reportMixedContent(url);
318 320
319 Settings* settings = mixedFrame->settings(); 321 Settings* settings = mixedFrame->settings();
320 // Use the current local frame's client; the embedder doesn't 322 // Use the current local frame's client; the embedder doesn't
321 // distinguish mixed content signals from different frames on the 323 // distinguish mixed content signals from different frames on the
322 // same page. 324 // same page.
323 FrameLoaderClient* client = frame->loader().client(); 325 FrameLoaderClient* client = frame->loader().client();
324 SecurityOrigin* securityOrigin = mixedFrame->securityContext()->getSecurityO rigin(); 326 SecurityOrigin* securityOrigin = mixedFrame->securityContext()->getSecurityO rigin();
325 bool allowed = false; 327 bool allowed = false;
326 328
327 // If we're in strict mode, we'll automagically fail everything, and intenti onally skip 329 // If we're in strict mode, we'll automagically fail everything, and intenti onally skip
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 400
399 // static 401 // static
400 bool MixedContentChecker::shouldBlockWebSocket(LocalFrame* frame, const KURL& ur l, MixedContentChecker::ReportingStatus reportingStatus) 402 bool MixedContentChecker::shouldBlockWebSocket(LocalFrame* frame, const KURL& ur l, MixedContentChecker::ReportingStatus reportingStatus)
401 { 403 {
402 Frame* mixedFrame = inWhichFrameIsContentMixed(frame, WebURLRequest::FrameTy peNone, url); 404 Frame* mixedFrame = inWhichFrameIsContentMixed(frame, WebURLRequest::FrameTy peNone, url);
403 if (!mixedFrame) 405 if (!mixedFrame)
404 return false; 406 return false;
405 407
406 UseCounter::count(mixedFrame, UseCounter::MixedContentPresent); 408 UseCounter::count(mixedFrame, UseCounter::MixedContentPresent);
407 UseCounter::count(mixedFrame, UseCounter::MixedContentWebSocket); 409 UseCounter::count(mixedFrame, UseCounter::MixedContentWebSocket);
410 if (ContentSecurityPolicy* policy = frame->securityContext()->contentSecurit yPolicy())
411 policy->reportMixedContent(url);
408 412
409 Settings* settings = mixedFrame->settings(); 413 Settings* settings = mixedFrame->settings();
410 // Use the current local frame's client; the embedder doesn't 414 // Use the current local frame's client; the embedder doesn't
411 // distinguish mixed content signals from different frames on the 415 // distinguish mixed content signals from different frames on the
412 // same page. 416 // same page.
413 FrameLoaderClient* client = frame->loader().client(); 417 FrameLoaderClient* client = frame->loader().client();
414 SecurityOrigin* securityOrigin = mixedFrame->securityContext()->getSecurityO rigin(); 418 SecurityOrigin* securityOrigin = mixedFrame->securityContext()->getSecurityO rigin();
415 bool allowed = false; 419 bool allowed = false;
416 420
417 // If we're in strict mode, we'll automagically fail everything, and intenti onally skip 421 // If we're in strict mode, we'll automagically fail everything, and intenti onally skip
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 517
514 // See comment in shouldBlockFetch() about loading the main resource of a su bframe. 518 // See comment in shouldBlockFetch() about loading the main resource of a su bframe.
515 if (request.frameType() == WebURLRequest::FrameTypeNested && !SchemeRegistry ::shouldTreatURLSchemeAsCORSEnabled(request.url().protocol())) { 519 if (request.frameType() == WebURLRequest::FrameTypeNested && !SchemeRegistry ::shouldTreatURLSchemeAsCORSEnabled(request.url().protocol())) {
516 return ContextTypeOptionallyBlockable; 520 return ContextTypeOptionallyBlockable;
517 } 521 }
518 522
519 return contextTypeFromContext(request.requestContext(), mixedFrame); 523 return contextTypeFromContext(request.requestContext(), mixedFrame);
520 } 524 }
521 525
522 } // namespace blink 526 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698