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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 1373773003: Implement 'window.isSecureContext'. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: document. Created 5 years, 2 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) 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 r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 5633 matching lines...) Expand 10 before | Expand all | Expand 10 after
5644 5644
5645 v8::Local<v8::Object> Document::associateWithWrapper(v8::Isolate* isolate, const WrapperTypeInfo* wrapperType, v8::Local<v8::Object> wrapper) 5645 v8::Local<v8::Object> Document::associateWithWrapper(v8::Isolate* isolate, const WrapperTypeInfo* wrapperType, v8::Local<v8::Object> wrapper)
5646 { 5646 {
5647 wrapper = V8DOMWrapper::associateObjectWithWrapper(isolate, this, wrapperTyp e, wrapper); 5647 wrapper = V8DOMWrapper::associateObjectWithWrapper(isolate, this, wrapperTyp e, wrapper);
5648 DOMWrapperWorld& world = DOMWrapperWorld::current(isolate); 5648 DOMWrapperWorld& world = DOMWrapperWorld::current(isolate);
5649 if (world.isMainWorld() && frame()) 5649 if (world.isMainWorld() && frame())
5650 frame()->script().windowProxy(world)->updateDocumentWrapper(wrapper); 5650 frame()->script().windowProxy(world)->updateDocumentWrapper(wrapper);
5651 return wrapper; 5651 return wrapper;
5652 } 5652 }
5653 5653
5654 bool Document::isPrivilegedContext(String& errorMessage, const PrivilegeContextC heck privilegeContextCheck) const 5654 bool Document::isSecureContext(String& errorMessage, const SecureContextCheck pr ivilegeContextCheck) const
5655 { 5655 {
5656 if (SecurityContext::isSandboxed(SandboxOrigin)) { 5656 if (SecurityContext::isSandboxed(SandboxOrigin)) {
5657 if (!SecurityOrigin::create(url())->isPotentiallyTrustworthy(errorMessag e)) 5657 if (!SecurityOrigin::create(url())->isPotentiallyTrustworthy(errorMessag e))
5658 return false; 5658 return false;
5659 } else { 5659 } else {
5660 if (!securityOrigin()->isPotentiallyTrustworthy(errorMessage)) 5660 if (!securityOrigin()->isPotentiallyTrustworthy(errorMessage))
5661 return false; 5661 return false;
5662 } 5662 }
5663 5663
5664 if (privilegeContextCheck == StandardPrivilegeCheck) { 5664 if (privilegeContextCheck == StandardSecureContextCheck) {
5665 Document* context = parentDocument(); 5665 Document* context = parentDocument();
5666 while (context) { 5666 while (context) {
5667 // Skip to the next ancestor if it's a srcdoc. 5667 // Skip to the next ancestor if it's a srcdoc.
5668 if (!context->isSrcdocDocument()) { 5668 if (!context->isSrcdocDocument()) {
5669 if (context->securityContext().isSandboxed(SandboxOrigin)) { 5669 if (context->securityContext().isSandboxed(SandboxOrigin)) {
5670 // For a sandboxed origin, use the document's URL. 5670 // For a sandboxed origin, use the document's URL.
5671 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(conte xt->url()); 5671 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(conte xt->url());
5672 if (!origin->isPotentiallyTrustworthy(errorMessage)) 5672 if (!origin->isPotentiallyTrustworthy(errorMessage))
5673 return false; 5673 return false;
5674 } else { 5674 } else {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
5754 #ifndef NDEBUG 5754 #ifndef NDEBUG
5755 using namespace blink; 5755 using namespace blink;
5756 void showLiveDocumentInstances() 5756 void showLiveDocumentInstances()
5757 { 5757 {
5758 Document::WeakDocumentSet& set = Document::liveDocumentSet(); 5758 Document::WeakDocumentSet& set = Document::liveDocumentSet();
5759 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5759 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5760 for (Document* document : set) 5760 for (Document* document : set)
5761 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5761 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5762 } 5762 }
5763 #endif 5763 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/dom/ExecutionContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698