Chromium Code Reviews| 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 return false; | 357 return false; |
| 358 | 358 |
| 359 // rule (d) above | 359 // rule (d) above |
| 360 CharDecompositionType decompType = decompositionType(c); | 360 CharDecompositionType decompType = decompositionType(c); |
| 361 if (decompType == DecompositionFont || decompType == DecompositionCompat) | 361 if (decompType == DecompositionFont || decompType == DecompositionCompat) |
| 362 return false; | 362 return false; |
| 363 | 363 |
| 364 return true; | 364 return true; |
| 365 } | 365 } |
| 366 | 366 |
| 367 static bool shouldInheritSecurityOriginFromOwner(const KURL& url) { | |
| 368 // http://www.whatwg.org/specs/web-apps/current-work/#origin-0 | |
| 369 // | |
| 370 // If a Document has the address "about:blank" | |
| 371 // The origin of the Document is the origin it was assigned when its | |
| 372 // browsing context was created. | |
| 373 // | |
| 374 // Note: We generalize this to all "blank" URLs and invalid URLs because we | |
| 375 // treat all of these URLs as about:blank. | |
| 376 // | |
| 377 return url.isEmpty() || url.protocolIsAbout(); | |
| 378 } | |
| 379 | |
| 380 static Widget* widgetForElement(const Element& focusedElement) { | 367 static Widget* widgetForElement(const Element& focusedElement) { |
| 381 LayoutObject* layoutObject = focusedElement.layoutObject(); | 368 LayoutObject* layoutObject = focusedElement.layoutObject(); |
| 382 if (!layoutObject || !layoutObject->isLayoutPart()) | 369 if (!layoutObject || !layoutObject->isLayoutPart()) |
| 383 return 0; | 370 return 0; |
| 384 return toLayoutPart(layoutObject)->widget(); | 371 return toLayoutPart(layoutObject)->widget(); |
| 385 } | 372 } |
| 386 | 373 |
| 387 static bool acceptsEditingFocus(const Element& element) { | 374 static bool acceptsEditingFocus(const Element& element) { |
| 388 DCHECK(hasEditableStyle(element)); | 375 DCHECK(hasEditableStyle(element)); |
| 389 | 376 |
| (...skipping 5036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5426 enforceSuborigin(*getSecurityOrigin()->suborigin()); | 5413 enforceSuborigin(*getSecurityOrigin()->suborigin()); |
| 5427 } | 5414 } |
| 5428 | 5415 |
| 5429 void Document::initContentSecurityPolicy(ContentSecurityPolicy* csp) { | 5416 void Document::initContentSecurityPolicy(ContentSecurityPolicy* csp) { |
| 5430 setContentSecurityPolicy(csp ? csp : ContentSecurityPolicy::create()); | 5417 setContentSecurityPolicy(csp ? csp : ContentSecurityPolicy::create()); |
| 5431 if (m_frame && m_frame->tree().parent() && | 5418 if (m_frame && m_frame->tree().parent() && |
| 5432 m_frame->tree().parent()->isLocalFrame()) { | 5419 m_frame->tree().parent()->isLocalFrame()) { |
| 5433 ContentSecurityPolicy* parentCSP = toLocalFrame(m_frame->tree().parent()) | 5420 ContentSecurityPolicy* parentCSP = toLocalFrame(m_frame->tree().parent()) |
| 5434 ->document() | 5421 ->document() |
| 5435 ->contentSecurityPolicy(); | 5422 ->contentSecurityPolicy(); |
| 5436 if (shouldInheritSecurityOriginFromOwner(m_url)) { | 5423 |
| 5424 // We inherit the parent frame's CSP for documents with "local" schemes: | |
| 5425 // 'about', 'blob', 'data', and 'filesystem'. We also inherit the parent | |
| 5426 // frame's CSP for documents with empty/invalid URLs because we treat | |
| 5427 // those URLs as 'about:blank' in Blink. | |
|
dcheng
2016/11/04 18:11:28
So I'm not sure what we /should/ do, but some inte
Mike West
2016/11/18 11:06:23
As currently specified, I think we'd end up inheri
| |
| 5428 // | |
| 5429 // https://w3c.github.io/webappsec-csp/#initialize-document-csp | |
| 5430 if (m_url.isEmpty() || m_url.protocolIsAbout() || m_url.protocolIsData() || | |
| 5431 m_url.protocolIs("blob") || m_url.protocolIs("data")) { | |
|
dcheng
2016/11/04 18:11:27
I notice filesystem isn't in this list, though it'
Mike West
2016/11/18 11:06:23
I had `data:` twice, though, so that's got to coun
| |
| 5437 contentSecurityPolicy()->copyStateFrom(parentCSP); | 5432 contentSecurityPolicy()->copyStateFrom(parentCSP); |
| 5438 } else if (isPluginDocument()) { | 5433 } else if (isPluginDocument()) { |
| 5439 // Per CSP2, plugin-types for plugin documents in nested browsing | 5434 // Per CSP2, plugin-types for plugin documents in nested browsing |
| 5440 // contexts gets inherited from the parent. | 5435 // contexts gets inherited from the parent. |
| 5441 contentSecurityPolicy()->copyPluginTypesFrom(parentCSP); | 5436 contentSecurityPolicy()->copyPluginTypesFrom(parentCSP); |
| 5442 } | 5437 } |
| 5443 } | 5438 } |
| 5444 contentSecurityPolicy()->bindToExecutionContext(this); | 5439 contentSecurityPolicy()->bindToExecutionContext(this); |
| 5445 } | 5440 } |
| 5446 | 5441 |
| (...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6477 } | 6472 } |
| 6478 | 6473 |
| 6479 void showLiveDocumentInstances() { | 6474 void showLiveDocumentInstances() { |
| 6480 WeakDocumentSet& set = liveDocumentSet(); | 6475 WeakDocumentSet& set = liveDocumentSet(); |
| 6481 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6476 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 6482 for (Document* document : set) | 6477 for (Document* document : set) |
| 6483 fprintf(stderr, "- Document %p URL: %s\n", document, | 6478 fprintf(stderr, "- Document %p URL: %s\n", document, |
| 6484 document->url().getString().utf8().data()); | 6479 document->url().getString().utf8().data()); |
| 6485 } | 6480 } |
| 6486 #endif | 6481 #endif |
| OLD | NEW |