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

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

Issue 1748943002: [Extensions] Harden against bindings interception (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // background page keeps reference to chrome object in a closed popup). 244 // background page keeps reference to chrome object in a closed popup).
245 v8::Local<v8::Value> modules_value; 245 v8::Local<v8::Value> modules_value;
246 if (!GetPrivate(global, kModulesField, &modules_value) || 246 if (!GetPrivate(global, kModulesField, &modules_value) ||
247 modules_value->IsUndefined()) { 247 modules_value->IsUndefined()) {
248 Warn(GetIsolate(), "Extension view no longer exists"); 248 Warn(GetIsolate(), "Extension view no longer exists");
249 return v8::Undefined(GetIsolate()); 249 return v8::Undefined(GetIsolate());
250 } 250 }
251 251
252 v8::Local<v8::Object> modules(v8::Local<v8::Object>::Cast(modules_value)); 252 v8::Local<v8::Object> modules(v8::Local<v8::Object>::Cast(modules_value));
253 v8::Local<v8::Value> exports; 253 v8::Local<v8::Value> exports;
254 if (!GetProperty(v8_context, modules, module_name, &exports) || 254 if (!GetPrivateProperty(v8_context, modules, module_name, &exports) ||
255 !exports->IsUndefined()) 255 !exports->IsUndefined())
256 return handle_scope.Escape(exports); 256 return handle_scope.Escape(exports);
257 257
258 exports = LoadModule(*v8::String::Utf8Value(module_name)); 258 exports = LoadModule(*v8::String::Utf8Value(module_name));
259 SetProperty(v8_context, modules, module_name, exports); 259 SetPrivateProperty(v8_context, modules, module_name, exports);
260 return handle_scope.Escape(exports); 260 return handle_scope.Escape(exports);
261 } 261 }
262 262
263 v8::Local<v8::Value> ModuleSystem::CallModuleMethod( 263 v8::Local<v8::Value> ModuleSystem::CallModuleMethod(
264 const std::string& module_name, 264 const std::string& module_name,
265 const std::string& method_name) { 265 const std::string& method_name) {
266 v8::EscapableHandleScope handle_scope(GetIsolate()); 266 v8::EscapableHandleScope handle_scope(GetIsolate());
267 v8::Local<v8::Value> no_args; 267 v8::Local<v8::Value> no_args;
268 return handle_scope.Escape( 268 return handle_scope.Escape(
269 CallModuleMethod(module_name, method_name, 0, &no_args)); 269 CallModuleMethod(module_name, method_name, 0, &no_args));
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 745
746 void ModuleSystem::ClobberExistingNativeHandler(const std::string& name) { 746 void ModuleSystem::ClobberExistingNativeHandler(const std::string& name) {
747 NativeHandlerMap::iterator existing_handler = native_handler_map_.find(name); 747 NativeHandlerMap::iterator existing_handler = native_handler_map_.find(name);
748 if (existing_handler != native_handler_map_.end()) { 748 if (existing_handler != native_handler_map_.end()) {
749 clobbered_native_handlers_.push_back(std::move(existing_handler->second)); 749 clobbered_native_handlers_.push_back(std::move(existing_handler->second));
750 native_handler_map_.erase(existing_handler); 750 native_handler_map_.erase(existing_handler);
751 } 751 }
752 } 752 }
753 753
754 } // namespace extensions 754 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/bindings/function_interceptions.html ('k') | extensions/renderer/v8_helpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698