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