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

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

Issue 1415923015: Downgrade lock icon for broken-HTTPS subresources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missing #incldue Created 5 years 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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 if (frameType == WebURLRequest::FrameTypeNested) { 451 if (frameType == WebURLRequest::FrameTypeNested) {
452 // FIXME: Deal with RemoteFrames. 452 // FIXME: Deal with RemoteFrames.
453 Frame* parentFrame = effectiveFrame->tree().parent(); 453 Frame* parentFrame = effectiveFrame->tree().parent();
454 ASSERT(parentFrame); 454 ASSERT(parentFrame);
455 if (parentFrame->isLocalFrame()) 455 if (parentFrame->isLocalFrame())
456 effectiveFrame = toLocalFrame(parentFrame); 456 effectiveFrame = toLocalFrame(parentFrame);
457 } 457 }
458 return effectiveFrame; 458 return effectiveFrame;
459 } 459 }
460 460
461 void MixedContentChecker::handleCertificateError(LocalFrame* frame, const Resour ceRequest& request, const ResourceResponse& response)
462 {
463 WebURLRequest::FrameType frameType = request.frameType();
464 LocalFrame* effectiveFrame = effectiveFrameForFrameType(frame, frameType);
465 if (frameType == WebURLRequest::FrameTypeTopLevel || !effectiveFrame)
466 return;
467
468 FrameLoaderClient* client = effectiveFrame->loader().client();
469 WebURLRequest::RequestContext requestContext = request.requestContext();
470 ContextType contextType = MixedContentChecker::contextTypeFromContext(reques tContext, frame);
471 logToConsoleAboutCertificateError(effectiveFrame, response.url(), requestCon text);
472 if (contextType == ContextTypeBlockable) {
473 client->didRunContentWithCertificateErrors(response.url(), response.getS ecurityInfo(), effectiveFrame->document()->url(), effectiveFrame->loader().docum entLoader()->response().getSecurityInfo());
474 } else {
475 // contextTypeFromContext() never returns NotMixedContent (it
476 // computes the type of mixed content, given that the content is
477 // mixed).
478 ASSERT(contextType != ContextTypeNotMixedContent);
479 client->didDisplayContentWithCertificateErrors(response.url(), response. getSecurityInfo(), effectiveFrame->document()->url(), effectiveFrame->loader().d ocumentLoader()->response().getSecurityInfo());
480 }
481 }
482
483 // static
484 void MixedContentChecker::logToConsoleAboutCertificateError(LocalFrame* frame, c onst KURL& url, WebURLRequest::RequestContext requestContext)
485 {
486 String message = String::format(
487 "Invalid certificate: The page at '%s' loaded a %s with certificate erro rs from '%s'.",
488 frame->document()->url().elidedString().utf8().data(), typeNameFromConte xt(requestContext), url.elidedString().utf8().data());
489 frame->document()->addConsoleMessage(ConsoleMessage::create(SecurityMessageS ource, WarningMessageLevel, message));
490 }
491
461 MixedContentChecker::ContextType MixedContentChecker::contextTypeForInspector(Lo calFrame* frame, const ResourceRequest& request) 492 MixedContentChecker::ContextType MixedContentChecker::contextTypeForInspector(Lo calFrame* frame, const ResourceRequest& request)
462 { 493 {
463 LocalFrame* effectiveFrame = effectiveFrameForFrameType(frame, request.frame Type()); 494 LocalFrame* effectiveFrame = effectiveFrameForFrameType(frame, request.frame Type());
464 495
465 LocalFrame* mixedFrame = inWhichFrameIsContentMixed(effectiveFrame, request. frameType(), request.url()); 496 LocalFrame* mixedFrame = inWhichFrameIsContentMixed(effectiveFrame, request. frameType(), request.url());
466 if (!mixedFrame) 497 if (!mixedFrame)
467 return ContextTypeNotMixedContent; 498 return ContextTypeNotMixedContent;
468 499
469 // See comment in shouldBlockFetch() about loading the main resource of a su bframe. 500 // See comment in shouldBlockFetch() about loading the main resource of a su bframe.
470 if (request.frameType() == WebURLRequest::FrameTypeNested && !SchemeRegistry ::shouldTreatURLSchemeAsCORSEnabled(request.url().protocol())) { 501 if (request.frameType() == WebURLRequest::FrameTypeNested && !SchemeRegistry ::shouldTreatURLSchemeAsCORSEnabled(request.url().protocol())) {
471 return ContextTypeOptionallyBlockable; 502 return ContextTypeOptionallyBlockable;
472 } 503 }
473 504
474 return contextTypeFromContext(request.requestContext(), mixedFrame); 505 return contextTypeFromContext(request.requestContext(), mixedFrame);
475 } 506 }
476 507
477 } // namespace blink 508 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698