OLD | NEW |
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/v8_schema_registry.h" | 5 #include "extensions/renderer/v8_schema_registry.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 v8::Context::Scope context_scope(context); | 97 v8::Context::Scope context_scope(context); |
98 | 98 |
99 const base::DictionaryValue* schema = | 99 const base::DictionaryValue* schema = |
100 ExtensionAPI::GetSharedInstance()->GetSchema(api); | 100 ExtensionAPI::GetSharedInstance()->GetSchema(api); |
101 CHECK(schema) << api; | 101 CHECK(schema) << api; |
102 scoped_ptr<V8ValueConverter> v8_value_converter(V8ValueConverter::create()); | 102 scoped_ptr<V8ValueConverter> v8_value_converter(V8ValueConverter::create()); |
103 v8::Local<v8::Value> value = v8_value_converter->ToV8Value(schema, context); | 103 v8::Local<v8::Value> value = v8_value_converter->ToV8Value(schema, context); |
104 CHECK(!value.IsEmpty()); | 104 CHECK(!value.IsEmpty()); |
105 | 105 |
106 v8::Local<v8::Object> v8_schema(v8::Local<v8::Object>::Cast(value)); | 106 v8::Local<v8::Object> v8_schema(v8::Local<v8::Object>::Cast(value)); |
| 107 v8_schema->SetIntegrityLevel(context, v8::IntegrityLevel::kFrozen); |
107 schema_cache_->Set(api, v8_schema); | 108 schema_cache_->Set(api, v8_schema); |
108 | 109 |
109 return handle_scope.Escape(v8_schema); | 110 return handle_scope.Escape(v8_schema); |
110 } | 111 } |
111 | 112 |
112 v8::Local<v8::Context> V8SchemaRegistry::GetOrCreateContext( | 113 v8::Local<v8::Context> V8SchemaRegistry::GetOrCreateContext( |
113 v8::Isolate* isolate) { | 114 v8::Isolate* isolate) { |
114 // It's ok to create local handles in this function, since this is only called | 115 // It's ok to create local handles in this function, since this is only called |
115 // when we have a HandleScope. | 116 // when we have a HandleScope. |
116 if (!context_holder_) { | 117 if (!context_holder_) { |
117 context_holder_.reset(new gin::ContextHolder(isolate)); | 118 context_holder_.reset(new gin::ContextHolder(isolate)); |
118 context_holder_->SetContext(v8::Context::New(isolate)); | 119 context_holder_->SetContext(v8::Context::New(isolate)); |
119 schema_cache_.reset(new SchemaCache(isolate)); | 120 schema_cache_.reset(new SchemaCache(isolate)); |
120 return context_holder_->context(); | 121 return context_holder_->context(); |
121 } | 122 } |
122 return context_holder_->context(); | 123 return context_holder_->context(); |
123 } | 124 } |
124 | 125 |
125 } // namespace extensions | 126 } // namespace extensions |
OLD | NEW |