OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All |
7 * rights reserved. | 7 * rights reserved. |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 return false; | 359 return false; |
360 | 360 |
361 // rule (d) above | 361 // rule (d) above |
362 CharDecompositionType decompType = decompositionType(c); | 362 CharDecompositionType decompType = decompositionType(c); |
363 if (decompType == DecompositionFont || decompType == DecompositionCompat) | 363 if (decompType == DecompositionFont || decompType == DecompositionCompat) |
364 return false; | 364 return false; |
365 | 365 |
366 return true; | 366 return true; |
367 } | 367 } |
368 | 368 |
369 static bool shouldInheritSecurityOriginFromOwner(const KURL& url) { | |
370 // http://www.whatwg.org/specs/web-apps/current-work/#origin-0 | |
371 // | |
372 // If a Document has the address "about:blank" | |
373 // The origin of the Document is the origin it was assigned when its | |
374 // browsing context was created. | |
375 // | |
376 // Note: We generalize this to all "blank" URLs and invalid URLs because we | |
377 // treat all of these URLs as about:blank. | |
378 // | |
379 return url.isEmpty() || url.protocolIsAbout(); | |
380 } | |
381 | |
382 static Widget* widgetForElement(const Element& focusedElement) { | 369 static Widget* widgetForElement(const Element& focusedElement) { |
383 LayoutObject* layoutObject = focusedElement.layoutObject(); | 370 LayoutObject* layoutObject = focusedElement.layoutObject(); |
384 if (!layoutObject || !layoutObject->isLayoutPart()) | 371 if (!layoutObject || !layoutObject->isLayoutPart()) |
385 return 0; | 372 return 0; |
386 return toLayoutPart(layoutObject)->widget(); | 373 return toLayoutPart(layoutObject)->widget(); |
387 } | 374 } |
388 | 375 |
389 static bool acceptsEditingFocus(const Element& element) { | 376 static bool acceptsEditingFocus(const Element& element) { |
390 DCHECK(hasEditableStyle(element)); | 377 DCHECK(hasEditableStyle(element)); |
391 | 378 |
(...skipping 5076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5468 enforceSuborigin(*getSecurityOrigin()->suborigin()); | 5455 enforceSuborigin(*getSecurityOrigin()->suborigin()); |
5469 } | 5456 } |
5470 | 5457 |
5471 void Document::initContentSecurityPolicy(ContentSecurityPolicy* csp) { | 5458 void Document::initContentSecurityPolicy(ContentSecurityPolicy* csp) { |
5472 setContentSecurityPolicy(csp ? csp : ContentSecurityPolicy::create()); | 5459 setContentSecurityPolicy(csp ? csp : ContentSecurityPolicy::create()); |
5473 if (m_frame && m_frame->tree().parent() && | 5460 if (m_frame && m_frame->tree().parent() && |
5474 m_frame->tree().parent()->isLocalFrame()) { | 5461 m_frame->tree().parent()->isLocalFrame()) { |
5475 ContentSecurityPolicy* parentCSP = toLocalFrame(m_frame->tree().parent()) | 5462 ContentSecurityPolicy* parentCSP = toLocalFrame(m_frame->tree().parent()) |
5476 ->document() | 5463 ->document() |
5477 ->contentSecurityPolicy(); | 5464 ->contentSecurityPolicy(); |
5478 if (shouldInheritSecurityOriginFromOwner(m_url)) { | 5465 |
| 5466 // We inherit the parent frame's CSP for documents with "local" schemes: |
| 5467 // 'about', 'blob', 'data', and 'filesystem'. We also inherit the parent |
| 5468 // frame's CSP for documents with empty/invalid URLs because we treat |
| 5469 // those URLs as 'about:blank' in Blink. |
| 5470 // |
| 5471 // https://w3c.github.io/webappsec-csp/#initialize-document-csp |
| 5472 if (m_url.isEmpty() || m_url.protocolIsAbout() || m_url.protocolIsData() || |
| 5473 m_url.protocolIs("blob") || m_url.protocolIs("filesystem")) { |
5479 contentSecurityPolicy()->copyStateFrom(parentCSP); | 5474 contentSecurityPolicy()->copyStateFrom(parentCSP); |
5480 } else if (isPluginDocument()) { | 5475 } else if (isPluginDocument()) { |
5481 // Per CSP2, plugin-types for plugin documents in nested browsing | 5476 // Per CSP2, plugin-types for plugin documents in nested browsing |
5482 // contexts gets inherited from the parent. | 5477 // contexts gets inherited from the parent. |
5483 contentSecurityPolicy()->copyPluginTypesFrom(parentCSP); | 5478 contentSecurityPolicy()->copyPluginTypesFrom(parentCSP); |
5484 } | 5479 } |
5485 } | 5480 } |
5486 contentSecurityPolicy()->bindToExecutionContext(this); | 5481 contentSecurityPolicy()->bindToExecutionContext(this); |
5487 } | 5482 } |
5488 | 5483 |
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6521 } | 6516 } |
6522 | 6517 |
6523 void showLiveDocumentInstances() { | 6518 void showLiveDocumentInstances() { |
6524 WeakDocumentSet& set = liveDocumentSet(); | 6519 WeakDocumentSet& set = liveDocumentSet(); |
6525 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6520 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
6526 for (Document* document : set) | 6521 for (Document* document : set) |
6527 fprintf(stderr, "- Document %p URL: %s\n", document, | 6522 fprintf(stderr, "- Document %p URL: %s\n", document, |
6528 document->url().getString().utf8().data()); | 6523 document->url().getString().utf8().data()); |
6529 } | 6524 } |
6530 #endif | 6525 #endif |
OLD | NEW |