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

Side by Side Diff: Source/bindings/core/v8/V8DOMConfiguration.cpp

Issue 413393003: Blink-in-JS: Implement internal APIs exposed only to private scripts (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/core/v8/V8DOMConfiguration.h ('k') | Source/bindings/scripts/v8_attributes.py » ('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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 24 matching lines...) Expand all
35 namespace blink { 35 namespace blink {
36 36
37 void V8DOMConfiguration::installAttributes(v8::Handle<v8::ObjectTemplate> instan ceTemplate, v8::Handle<v8::ObjectTemplate> prototype, const AttributeConfigurati on* attributes, size_t attributeCount, v8::Isolate* isolate) 37 void V8DOMConfiguration::installAttributes(v8::Handle<v8::ObjectTemplate> instan ceTemplate, v8::Handle<v8::ObjectTemplate> prototype, const AttributeConfigurati on* attributes, size_t attributeCount, v8::Isolate* isolate)
38 { 38 {
39 for (size_t i = 0; i < attributeCount; ++i) 39 for (size_t i = 0; i < attributeCount; ++i)
40 installAttribute(instanceTemplate, prototype, attributes[i], isolate); 40 installAttribute(instanceTemplate, prototype, attributes[i], isolate);
41 } 41 }
42 42
43 void V8DOMConfiguration::installAccessors(v8::Handle<v8::ObjectTemplate> prototy pe, v8::Handle<v8::Signature> signature, const AccessorConfiguration* accessors, size_t accessorCount, v8::Isolate* isolate) 43 void V8DOMConfiguration::installAccessors(v8::Handle<v8::ObjectTemplate> prototy pe, v8::Handle<v8::Signature> signature, const AccessorConfiguration* accessors, size_t accessorCount, v8::Isolate* isolate)
44 { 44 {
45 bool isMainWorld = DOMWrapperWorld::current(isolate).isMainWorld(); 45 DOMWrapperWorld& world = DOMWrapperWorld::current(isolate);
46 for (size_t i = 0; i < accessorCount; ++i) { 46 for (size_t i = 0; i < accessorCount; ++i) {
47 if (accessors[i].exposeConfiguration == OnlyExposedToPrivateScript && !w orld.isPrivateScriptIsolatedWorld())
48 continue;
49
47 v8::FunctionCallback getterCallback = accessors[i].getter; 50 v8::FunctionCallback getterCallback = accessors[i].getter;
48 v8::FunctionCallback setterCallback = accessors[i].setter; 51 v8::FunctionCallback setterCallback = accessors[i].setter;
49 if (isMainWorld) { 52 if (world.isMainWorld()) {
50 if (accessors[i].getterForMainWorld) 53 if (accessors[i].getterForMainWorld)
51 getterCallback = accessors[i].getterForMainWorld; 54 getterCallback = accessors[i].getterForMainWorld;
52 if (accessors[i].setterForMainWorld) 55 if (accessors[i].setterForMainWorld)
53 setterCallback = accessors[i].setterForMainWorld; 56 setterCallback = accessors[i].setterForMainWorld;
54 } 57 }
55 58
56 v8::Local<v8::FunctionTemplate> getter; 59 v8::Local<v8::FunctionTemplate> getter;
57 if (getterCallback) { 60 if (getterCallback) {
58 getter = v8::FunctionTemplate::New(isolate, getterCallback, v8::Exte rnal::New(isolate, const_cast<WrapperTypeInfo*>(accessors[i].data)), signature, 0); 61 getter = v8::FunctionTemplate::New(isolate, getterCallback, v8::Exte rnal::New(isolate, const_cast<WrapperTypeInfo*>(accessors[i].data)), signature, 0);
59 getter->RemovePrototype(); 62 getter->RemovePrototype();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 prototype->Set(constantName, v8::String::NewFromUtf8(isolate, consta nt->svalue), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete)); 96 prototype->Set(constantName, v8::String::NewFromUtf8(isolate, consta nt->svalue), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
94 break; 97 break;
95 default: 98 default:
96 ASSERT_NOT_REACHED(); 99 ASSERT_NOT_REACHED();
97 } 100 }
98 } 101 }
99 } 102 }
100 103
101 void V8DOMConfiguration::installMethods(v8::Handle<v8::ObjectTemplate> prototype , v8::Handle<v8::Signature> signature, v8::PropertyAttribute attributes, const M ethodConfiguration* callbacks, size_t callbackCount, v8::Isolate* isolate) 104 void V8DOMConfiguration::installMethods(v8::Handle<v8::ObjectTemplate> prototype , v8::Handle<v8::Signature> signature, v8::PropertyAttribute attributes, const M ethodConfiguration* callbacks, size_t callbackCount, v8::Isolate* isolate)
102 { 105 {
103 bool isMainWorld = DOMWrapperWorld::current(isolate).isMainWorld(); 106 DOMWrapperWorld& world = DOMWrapperWorld::current(isolate);
104 for (size_t i = 0; i < callbackCount; ++i) { 107 for (size_t i = 0; i < callbackCount; ++i) {
108 if (callbacks[i].exposeConfiguration == OnlyExposedToPrivateScript && !w orld.isPrivateScriptIsolatedWorld())
109 continue;
110
105 v8::FunctionCallback callback = callbacks[i].callback; 111 v8::FunctionCallback callback = callbacks[i].callback;
106 if (isMainWorld && callbacks[i].callbackForMainWorld) 112 if (world.isMainWorld() && callbacks[i].callbackForMainWorld)
107 callback = callbacks[i].callbackForMainWorld; 113 callback = callbacks[i].callbackForMainWorld;
108 v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate: :New(isolate, callback, v8Undefined(), signature, callbacks[i].length); 114 v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate: :New(isolate, callback, v8Undefined(), signature, callbacks[i].length);
109 functionTemplate->RemovePrototype(); 115 functionTemplate->RemovePrototype();
110 prototype->Set(v8AtomicString(isolate, callbacks[i].name), functionTempl ate, attributes); 116 prototype->Set(v8AtomicString(isolate, callbacks[i].name), functionTempl ate, attributes);
111 } 117 }
112 } 118 }
113 119
114 v8::Local<v8::Signature> V8DOMConfiguration::installDOMClassTemplate(v8::Handle< v8::FunctionTemplate> functionDescriptor, const char* interfaceName, v8::Handle< v8::FunctionTemplate> parentClass, size_t fieldCount, 120 v8::Local<v8::Signature> V8DOMConfiguration::installDOMClassTemplate(v8::Handle< v8::FunctionTemplate> functionDescriptor, const char* interfaceName, v8::Handle< v8::FunctionTemplate> parentClass, size_t fieldCount,
115 const AttributeConfiguration* attributes, size_t attributeCount, 121 const AttributeConfiguration* attributes, size_t attributeCount,
116 const AccessorConfiguration* accessors, size_t accessorCount, 122 const AccessorConfiguration* accessors, size_t accessorCount,
(...skipping 30 matching lines...) Expand all
147 return result; 153 return result;
148 154
149 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "BuildDOMTemplate"); 155 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "BuildDOMTemplate");
150 result = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidCons tructorMode); 156 result = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidCons tructorMode);
151 configureDOMClassTemplate(result, isolate); 157 configureDOMClassTemplate(result, isolate);
152 data->setDOMTemplate(wrapperTypeInfo, result); 158 data->setDOMTemplate(wrapperTypeInfo, result);
153 return result; 159 return result;
154 } 160 }
155 161
156 } // namespace blink 162 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/V8DOMConfiguration.h ('k') | Source/bindings/scripts/v8_attributes.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698