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

Side by Side Diff: Source/core/loader/FrameLoader.cpp

Issue 91353002: CSP 1.1: Implement the 'frame-ancestors' directive. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase. Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/frame/ContentSecurityPolicy.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> 7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com>
8 * Copyright (C) 2011 Google Inc. All rights reserved. 8 * Copyright (C) 2011 Google Inc. All rights reserved.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 if (!m_stateMachine.committedMultipleRealLoads() && m_loadType == FrameLoadT ypeStandard) 341 if (!m_stateMachine.committedMultipleRealLoads() && m_loadType == FrameLoadT ypeStandard)
342 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedMultipleRealL oads); 342 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedMultipleRealL oads);
343 343
344 m_client->dispatchDidCommitLoad(m_frame, m_currentItem.get(), loadTypeToComm itType(m_loadType, isStandardLoadWithValidURL)); 344 m_client->dispatchDidCommitLoad(m_frame, m_currentItem.get(), loadTypeToComm itType(m_loadType, isStandardLoadWithValidURL));
345 345
346 InspectorInstrumentation::didCommitLoad(m_frame, m_documentLoader.get()); 346 InspectorInstrumentation::didCommitLoad(m_frame, m_documentLoader.get());
347 m_frame->page()->didCommitLoad(m_frame); 347 m_frame->page()->didCommitLoad(m_frame);
348 dispatchDidClearWindowObjectsInAllWorlds(); 348 dispatchDidClearWindowObjectsInAllWorlds();
349 } 349 }
350 350
351 static void didFailContentSecurityPolicyCheck(FrameLoader* loader)
352 {
353 // load event and stopAllLoaders can detach the Frame, so protect it.
354 RefPtr<Frame> frame(loader->frame());
355
356 // Move the page to a unique origin, and cancel the load.
357 frame->document()->enforceSandboxFlags(SandboxOrigin);
358 loader->stopAllLoaders();
359
360 // Fire a load event, as timing attacks would otherwise reveal that the
361 // frame was blocked. This way, it looks like every other cross-origin
362 // page.
363 if (HTMLFrameOwnerElement* ownerElement = frame->ownerElement())
364 ownerElement->dispatchEvent(Event::create(EventTypeNames::load));
365 }
366
351 void FrameLoader::didBeginDocument(bool dispatch) 367 void FrameLoader::didBeginDocument(bool dispatch)
352 { 368 {
353 m_isComplete = false; 369 m_isComplete = false;
354 m_frame->document()->setReadyState(Document::Loading); 370 m_frame->document()->setReadyState(Document::Loading);
355 371
356 if (m_provisionalItem && m_loadType == FrameLoadTypeBackForward) 372 if (m_provisionalItem && m_loadType == FrameLoadTypeBackForward)
357 m_frame->domWindow()->statePopped(m_provisionalItem->stateObject()); 373 m_frame->domWindow()->statePopped(m_provisionalItem->stateObject());
358 374
359 if (dispatch) 375 if (dispatch)
360 dispatchDidClearWindowObjectsInAllWorlds(); 376 dispatchDidClearWindowObjectsInAllWorlds();
361 377
362 m_frame->document()->initContentSecurityPolicy(m_documentLoader ? ContentSec urityPolicyResponseHeaders(m_documentLoader->response()) : ContentSecurityPolicy ResponseHeaders()); 378 m_frame->document()->initContentSecurityPolicy(m_documentLoader ? ContentSec urityPolicyResponseHeaders(m_documentLoader->response()) : ContentSecurityPolicy ResponseHeaders());
363 379
380 if (!m_frame->document()->contentSecurityPolicy()->allowAncestors(m_frame)) {
381 didFailContentSecurityPolicyCheck(this);
382 return;
383 }
384
364 Settings* settings = m_frame->document()->settings(); 385 Settings* settings = m_frame->document()->settings();
365 if (settings) { 386 if (settings) {
366 m_frame->document()->fetcher()->setImagesEnabled(settings->imagesEnabled ()); 387 m_frame->document()->fetcher()->setImagesEnabled(settings->imagesEnabled ());
367 m_frame->document()->fetcher()->setAutoLoadImages(settings->loadsImagesA utomatically()); 388 m_frame->document()->fetcher()->setAutoLoadImages(settings->loadsImagesA utomatically());
368 } 389 }
369 390
370 if (m_documentLoader) { 391 if (m_documentLoader) {
371 const AtomicString& dnsPrefetchControl = m_documentLoader->response().ht tpHeaderField("X-DNS-Prefetch-Control"); 392 const AtomicString& dnsPrefetchControl = m_documentLoader->response().ht tpHeaderField("X-DNS-Prefetch-Control");
372 if (!dnsPrefetchControl.isEmpty()) 393 if (!dnsPrefetchControl.isEmpty())
373 m_frame->document()->parseDNSPrefetchControlHeader(dnsPrefetchContro l); 394 m_frame->document()->parseDNSPrefetchControlHeader(dnsPrefetchContro l);
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 { 1484 {
1464 SandboxFlags flags = m_forcedSandboxFlags; 1485 SandboxFlags flags = m_forcedSandboxFlags;
1465 if (Frame* parentFrame = m_frame->tree().parent()) 1486 if (Frame* parentFrame = m_frame->tree().parent())
1466 flags |= parentFrame->document()->sandboxFlags(); 1487 flags |= parentFrame->document()->sandboxFlags();
1467 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) 1488 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement())
1468 flags |= ownerElement->sandboxFlags(); 1489 flags |= ownerElement->sandboxFlags();
1469 return flags; 1490 return flags;
1470 } 1491 }
1471 1492
1472 } // namespace WebCore 1493 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/frame/ContentSecurityPolicy.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698