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

Side by Side Diff: Source/core/dom/DocumentInit.cpp

Issue 845303003: Tag SecurityContext objects as being hosted in reserved IP ranges. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Skip 'about:blank', 'swappedout://', etc. Created 5 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
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, 2010, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 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) 2010 Nokia Corporation and/or its subsidiary(-ies) 8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
9 * Copyright (C) 2013 Google Inc. All rights reserved. 9 * Copyright (C) 2013 Google Inc. All rights reserved.
10 * 10 *
(...skipping 15 matching lines...) Expand all
26 */ 26 */
27 27
28 #include "config.h" 28 #include "config.h"
29 #include "core/dom/DocumentInit.h" 29 #include "core/dom/DocumentInit.h"
30 30
31 #include "core/dom/Document.h" 31 #include "core/dom/Document.h"
32 #include "core/dom/custom/CustomElementRegistrationContext.h" 32 #include "core/dom/custom/CustomElementRegistrationContext.h"
33 #include "core/frame/LocalFrame.h" 33 #include "core/frame/LocalFrame.h"
34 #include "core/html/HTMLFrameOwnerElement.h" 34 #include "core/html/HTMLFrameOwnerElement.h"
35 #include "core/html/imports/HTMLImportsController.h" 35 #include "core/html/imports/HTMLImportsController.h"
36 #include "core/loader/DocumentLoader.h"
36 #include "platform/RuntimeEnabledFeatures.h" 37 #include "platform/RuntimeEnabledFeatures.h"
38 #include "public/platform/Platform.h"
37 39
38 namespace blink { 40 namespace blink {
39 41
40 // FIXME: Broken with OOPI. 42 // FIXME: Broken with OOPI.
41 static Document* parentDocument(LocalFrame* frame) 43 static Document* parentDocument(LocalFrame* frame)
42 { 44 {
43 if (!frame) 45 if (!frame)
44 return 0; 46 return 0;
45 Element* ownerElement = frame->deprecatedLocalOwner(); 47 Element* ownerElement = frame->deprecatedLocalOwner();
46 if (!ownerElement) 48 if (!ownerElement)
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 ASSERT(frameForSecurityContext()); 118 ASSERT(frameForSecurityContext());
117 return frameForSecurityContext()->loader().effectiveSandboxFlags(); 119 return frameForSecurityContext()->loader().effectiveSandboxFlags();
118 } 120 }
119 121
120 bool DocumentInit::shouldEnforceStrictMixedContentChecking() const 122 bool DocumentInit::shouldEnforceStrictMixedContentChecking() const
121 { 123 {
122 ASSERT(frameForSecurityContext()); 124 ASSERT(frameForSecurityContext());
123 return frameForSecurityContext()->loader().shouldEnforceStrictMixedContentCh ecking(); 125 return frameForSecurityContext()->loader().shouldEnforceStrictMixedContentCh ecking();
124 } 126 }
125 127
128 bool DocumentInit::isHostedInReservedIPRange() const
129 {
130 if (LocalFrame* frame = frameForSecurityContext()) {
131 // TODO: Fix the platform API to drop the KURL construction.
jochen (gone - plz use gerrit) 2015/01/13 15:04:55 it's FIXME in blink
Mike West 2015/01/13 15:35:38 Done.
132 if (DocumentLoader* loader = frame->loader().provisionalDocumentLoader() ? frame->loader().provisionalDocumentLoader() : frame->loader().documentLoader( )) {
133 if (!loader->response().remoteIPAddress().isEmpty()) {
134 KURL documentIP(ParsedURLString, "http://" + loader->response(). remoteIPAddress());
jochen (gone - plz use gerrit) 2015/01/13 15:04:54 https:// - be a good role model :) otoh, why does
Mike West 2015/01/13 15:35:38 Ha! Done.
135 return Platform::current()->isReservedIPAddress(documentIP);
136 }
137 }
138 }
139 return false;
140 }
141
126 Settings* DocumentInit::settings() const 142 Settings* DocumentInit::settings() const
127 { 143 {
128 ASSERT(frameForSecurityContext()); 144 ASSERT(frameForSecurityContext());
129 return frameForSecurityContext()->settings(); 145 return frameForSecurityContext()->settings();
130 } 146 }
131 147
132 KURL DocumentInit::parentBaseURL() const 148 KURL DocumentInit::parentBaseURL() const
133 { 149 {
134 return m_parent->baseURL(); 150 return m_parent->baseURL();
135 } 151 }
(...skipping 28 matching lines...) Expand all
164 return m_contextDocument; 180 return m_contextDocument;
165 } 181 }
166 182
167 DocumentInit DocumentInit::fromContext(WeakPtrWillBeRawPtr<Document> contextDocu ment, const KURL& url) 183 DocumentInit DocumentInit::fromContext(WeakPtrWillBeRawPtr<Document> contextDocu ment, const KURL& url)
168 { 184 {
169 return DocumentInit(url, 0, contextDocument, 0); 185 return DocumentInit(url, 0, contextDocument, 0);
170 } 186 }
171 187
172 } // namespace blink 188 } // namespace blink
173 189
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698