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

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

Issue 1617043002: Introduce AncestorThrottle, which will process 'X-Frame-Options' headers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@block-response
Patch Set: Fix. Created 4 years, 8 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) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 memoryCache()->remove(m_mainResource.get()); 382 memoryCache()->remove(m_mainResource.get());
383 383
384 m_contentSecurityPolicy = ContentSecurityPolicy::create(); 384 m_contentSecurityPolicy = ContentSecurityPolicy::create();
385 m_contentSecurityPolicy->setOverrideURLForSelf(response.url()); 385 m_contentSecurityPolicy->setOverrideURLForSelf(response.url());
386 m_contentSecurityPolicy->didReceiveHeaders(ContentSecurityPolicyResponseHead ers(response)); 386 m_contentSecurityPolicy->didReceiveHeaders(ContentSecurityPolicyResponseHead ers(response));
387 if (!m_contentSecurityPolicy->allowAncestors(m_frame, response.url())) { 387 if (!m_contentSecurityPolicy->allowAncestors(m_frame, response.url())) {
388 cancelLoadAfterXFrameOptionsOrCSPDenied(response); 388 cancelLoadAfterXFrameOptionsOrCSPDenied(response);
389 return; 389 return;
390 } 390 }
391 391
392 // 'frame-ancestors' obviates 'x-frame-options': https://w3c.github.io/webap psec/specs/content-security-policy/#frame-ancestors-and-frame-options
393 if (!m_contentSecurityPolicy->isFrameAncestorsEnforced()) {
394 HTTPHeaderMap::const_iterator it = response.httpHeaderFields().find(HTTP Names::X_Frame_Options);
395 if (it != response.httpHeaderFields().end()) {
396 String content = it->value;
397 if (frameLoader()->shouldInterruptLoadForXFrameOptions(content, resp onse.url(), mainResourceIdentifier())) {
398 String message = "Refused to display '" + response.url().elidedS tring() + "' in a frame because it set 'X-Frame-Options' to '" + content + "'.";
399 ConsoleMessage* consoleMessage = ConsoleMessage::create(Security MessageSource, ErrorMessageLevel, message);
400 consoleMessage->setRequestIdentifier(mainResourceIdentifier());
401 frame()->document()->addConsoleMessage(consoleMessage);
402
403 cancelLoadAfterXFrameOptionsOrCSPDenied(response);
404 return;
405 }
406 }
407 }
408
409 ASSERT(!m_frame->page()->defersLoading()); 392 ASSERT(!m_frame->page()->defersLoading());
410 393
411 m_response = response; 394 m_response = response;
412 395
413 if (isArchiveMIMEType(m_response.mimeType()) && m_mainResource->getDataBuffe ringPolicy() != BufferData) 396 if (isArchiveMIMEType(m_response.mimeType()) && m_mainResource->getDataBuffe ringPolicy() != BufferData)
414 m_mainResource->setDataBufferingPolicy(BufferData); 397 m_mainResource->setDataBufferingPolicy(BufferData);
415 398
416 if (!shouldContinueForResponse()) { 399 if (!shouldContinueForResponse()) {
417 InspectorInstrumentation::continueWithPolicyIgnore(m_frame, this, m_main Resource->identifier(), m_response); 400 InspectorInstrumentation::continueWithPolicyIgnore(m_frame, this, m_main Resource->identifier(), m_response);
418 m_fetcher->stopFetching(); 401 m_fetcher->stopFetching();
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 { 675 {
693 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding() : emptyAtom, true, ForceSynchronousParsing); 676 m_writer = createWriterFor(init, mimeType(), m_writer ? m_writer->encoding() : emptyAtom, true, ForceSynchronousParsing);
694 if (!source.isNull()) 677 if (!source.isNull())
695 m_writer->appendReplacingData(source); 678 m_writer->appendReplacingData(source);
696 endWriting(m_writer.get()); 679 endWriting(m_writer.get());
697 } 680 }
698 681
699 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader); 682 DEFINE_WEAK_IDENTIFIER_MAP(DocumentLoader);
700 683
701 } // namespace blink 684 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698