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

Side by Side Diff: extensions/renderer/object_backed_native_handler.cc

Issue 1880933002: Begin to enable extension APIs in Extension Service Worker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments - 3 Created 4 years, 8 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/renderer/object_backed_native_handler.h" 5 #include "extensions/renderer/object_backed_native_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 // static 157 // static
158 bool ObjectBackedNativeHandler::ContextCanAccessObject( 158 bool ObjectBackedNativeHandler::ContextCanAccessObject(
159 const v8::Local<v8::Context>& context, 159 const v8::Local<v8::Context>& context,
160 const v8::Local<v8::Object>& object, 160 const v8::Local<v8::Object>& object,
161 bool allow_null_context) { 161 bool allow_null_context) {
162 if (object->IsNull()) 162 if (object->IsNull())
163 return true; 163 return true;
164 if (context == object->CreationContext()) 164 if (context == object->CreationContext())
165 return true; 165 return true;
166 // TODO(lazyboy): ScriptContextSet isn't available on worker threads. We
167 // should probably use WorkerScriptContextSet somehow.
166 ScriptContext* other_script_context = 168 ScriptContext* other_script_context =
167 ScriptContextSet::GetContextByObject(object); 169 content::WorkerThread::GetCurrentId() == 0
170 ? ScriptContextSet::GetContextByObject(object)
171 : nullptr;
lazyboy 2016/04/18 18:42:14 FYI, I had to add this b/c accessing ScriptContext
168 if (!other_script_context || !other_script_context->web_frame()) 172 if (!other_script_context || !other_script_context->web_frame())
169 return allow_null_context; 173 return allow_null_context;
170 174
171 return blink::WebFrame::scriptCanAccess(other_script_context->web_frame()); 175 return blink::WebFrame::scriptCanAccess(other_script_context->web_frame());
172 } 176 }
173 177
174 void ObjectBackedNativeHandler::SetPrivate(v8::Local<v8::Object> obj, 178 void ObjectBackedNativeHandler::SetPrivate(v8::Local<v8::Object> obj,
175 const char* key, 179 const char* key,
176 v8::Local<v8::Value> value) { 180 v8::Local<v8::Value> value) {
177 SetPrivate(context_->v8_context(), obj, key, value); 181 SetPrivate(context_->v8_context(), obj, key, value);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 v8::Local<v8::Object> obj, 221 v8::Local<v8::Object> obj,
218 const char* key) { 222 const char* key) {
219 obj->DeletePrivate(context, 223 obj->DeletePrivate(context,
220 v8::Private::ForApi( 224 v8::Private::ForApi(
221 context->GetIsolate(), 225 context->GetIsolate(),
222 v8::String::NewFromUtf8(context->GetIsolate(), key))) 226 v8::String::NewFromUtf8(context->GetIsolate(), key)))
223 .FromJust(); 227 .FromJust();
224 } 228 }
225 229
226 } // namespace extensions 230 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698