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/module_system.h" | 5 #include "extensions/renderer/module_system.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 } | 611 } |
612 v8::Local<v8::Object> obj = args[0].As<v8::Object>(); | 612 v8::Local<v8::Object> obj = args[0].As<v8::Object>(); |
613 v8::Local<v8::Value> privates; | 613 v8::Local<v8::Value> privates; |
614 if (!GetPrivate(obj, "privates", &privates) || !privates->IsObject()) { | 614 if (!GetPrivate(obj, "privates", &privates) || !privates->IsObject()) { |
615 privates = v8::Object::New(args.GetIsolate()); | 615 privates = v8::Object::New(args.GetIsolate()); |
616 if (privates.IsEmpty()) { | 616 if (privates.IsEmpty()) { |
617 GetIsolate()->ThrowException( | 617 GetIsolate()->ThrowException( |
618 ToV8StringUnsafe(GetIsolate(), "Failed to create privates")); | 618 ToV8StringUnsafe(GetIsolate(), "Failed to create privates")); |
619 return; | 619 return; |
620 } | 620 } |
| 621 v8::Maybe<bool> maybe = |
| 622 privates.As<v8::Object>()->SetPrototype(context()->v8_context(), |
| 623 v8::Null(args.GetIsolate())); |
| 624 CHECK(maybe.IsJust() && maybe.FromJust()); |
621 SetPrivate(obj, "privates", privates); | 625 SetPrivate(obj, "privates", privates); |
622 } | 626 } |
623 args.GetReturnValue().Set(privates); | 627 args.GetReturnValue().Set(privates); |
624 } | 628 } |
625 | 629 |
626 v8::Local<v8::Value> ModuleSystem::LoadModule(const std::string& module_name) { | 630 v8::Local<v8::Value> ModuleSystem::LoadModule(const std::string& module_name) { |
627 v8::EscapableHandleScope handle_scope(GetIsolate()); | 631 v8::EscapableHandleScope handle_scope(GetIsolate()); |
628 v8::Local<v8::Context> v8_context = context()->v8_context(); | 632 v8::Local<v8::Context> v8_context = context()->v8_context(); |
629 v8::Context::Scope context_scope(v8_context); | 633 v8::Context::Scope context_scope(v8_context); |
630 | 634 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 | 751 |
748 void ModuleSystem::ClobberExistingNativeHandler(const std::string& name) { | 752 void ModuleSystem::ClobberExistingNativeHandler(const std::string& name) { |
749 NativeHandlerMap::iterator existing_handler = native_handler_map_.find(name); | 753 NativeHandlerMap::iterator existing_handler = native_handler_map_.find(name); |
750 if (existing_handler != native_handler_map_.end()) { | 754 if (existing_handler != native_handler_map_.end()) { |
751 clobbered_native_handlers_.push_back(std::move(existing_handler->second)); | 755 clobbered_native_handlers_.push_back(std::move(existing_handler->second)); |
752 native_handler_map_.erase(existing_handler); | 756 native_handler_map_.erase(existing_handler); |
753 } | 757 } |
754 } | 758 } |
755 | 759 |
756 } // namespace extensions | 760 } // namespace extensions |
OLD | NEW |