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

Side by Side Diff: Source/bindings/core/v8/V8DOMWrapper.h

Issue 1262353002: Add access checks to V8WrapperInstationScope. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update Created 5 years, 3 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
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8DOMWrapper.cpp » ('j') | 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef V8DOMWrapper_h 31 #ifndef V8DOMWrapper_h
32 #define V8DOMWrapper_h 32 #define V8DOMWrapper_h
33 33
34 #include "bindings/core/v8/BindingSecurity.h"
34 #include "bindings/core/v8/DOMDataStore.h" 35 #include "bindings/core/v8/DOMDataStore.h"
35 #include "bindings/core/v8/ScriptWrappable.h" 36 #include "bindings/core/v8/ScriptWrappable.h"
37 #include "bindings/core/v8/V8Binding.h"
36 #include "wtf/PassRefPtr.h" 38 #include "wtf/PassRefPtr.h"
37 #include "wtf/RawPtr.h" 39 #include "wtf/RawPtr.h"
38 #include "wtf/text/AtomicString.h" 40 #include "wtf/text/AtomicString.h"
39 #include <v8.h> 41 #include <v8.h>
40 42
41 namespace blink { 43 namespace blink {
42 44
43 class Node; 45 class Node;
44 struct WrapperTypeInfo; 46 struct WrapperTypeInfo;
45 47
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 setNativeInfo(wrapper, wrapperTypeInfo, ScriptWrappable::fromNode(node)) ; 103 setNativeInfo(wrapper, wrapperTypeInfo, ScriptWrappable::fromNode(node)) ;
102 ASSERT(hasInternalFieldsSet(wrapper)); 104 ASSERT(hasInternalFieldsSet(wrapper));
103 } 105 }
104 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(toScriptWrappable(wrapper) == Scrip tWrappable::fromNode(node)); 106 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(toScriptWrappable(wrapper) == Scrip tWrappable::fromNode(node));
105 return wrapper; 107 return wrapper;
106 } 108 }
107 109
108 class V8WrapperInstantiationScope { 110 class V8WrapperInstantiationScope {
109 STACK_ALLOCATED(); 111 STACK_ALLOCATED();
110 public: 112 public:
111 V8WrapperInstantiationScope(v8::Local<v8::Object> creationContext, v8::Isola te* isolate) 113 V8WrapperInstantiationScope(v8::Local<v8::Object> creationContext, v8::Isola te* isolate, bool withSecurityCheck = true)
112 : m_didEnterContext(false) 114 : m_didEnterContext(false)
113 , m_context(isolate->GetCurrentContext()) 115 , m_context(isolate->GetCurrentContext())
114 { 116 {
115 // creationContext should not be empty. Because if we have an 117 // creationContext should not be empty. Because if we have an
116 // empty creationContext, we will end up creating 118 // empty creationContext, we will end up creating
117 // a new object in the context currently entered. This is wrong. 119 // a new object in the context currently entered. This is wrong.
118 RELEASE_ASSERT(!creationContext.IsEmpty()); 120 RELEASE_ASSERT(!creationContext.IsEmpty());
119 v8::Local<v8::Context> contextForWrapper = creationContext->CreationCont ext(); 121 v8::Local<v8::Context> contextForWrapper = creationContext->CreationCont ext();
120 // For performance, we enter the context only if the currently running c ontext 122 // For performance, we enter the context only if the currently running c ontext
121 // is different from the context that we are about to enter. 123 // is different from the context that we are about to enter.
122 if (contextForWrapper == m_context) 124 if (contextForWrapper == m_context)
haraken 2015/12/22 07:17:51 epertoso@ and jochen@: I'm getting a bit confused.
123 return; 125 return;
126 if (withSecurityCheck)
127 SecurityCheck(isolate, contextForWrapper);
124 m_context = v8::Local<v8::Context>::New(isolate, contextForWrapper); 128 m_context = v8::Local<v8::Context>::New(isolate, contextForWrapper);
125 m_didEnterContext = true; 129 m_didEnterContext = true;
126 m_context->Enter(); 130 m_context->Enter();
127 } 131 }
128 132
129 ~V8WrapperInstantiationScope() 133 ~V8WrapperInstantiationScope()
130 { 134 {
131 if (!m_didEnterContext) 135 if (!m_didEnterContext)
132 return; 136 return;
133 m_context->Exit(); 137 m_context->Exit();
134 } 138 }
135 139
136 v8::Local<v8::Context> context() const { return m_context; } 140 v8::Local<v8::Context> context() const { return m_context; }
137 141
138 private: 142 private:
143 void SecurityCheck(v8::Isolate*, v8::Local<v8::Context> contextForWrapper);
144
139 bool m_didEnterContext; 145 bool m_didEnterContext;
140 v8::Local<v8::Context> m_context; 146 v8::Local<v8::Context> m_context;
141 }; 147 };
142 148
143 } // namespace blink 149 } // namespace blink
144 150
145 #endif // V8DOMWrapper_h 151 #endif // V8DOMWrapper_h
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8DOMWrapper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698