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

Unified Diff: chrome/renderer/extensions/module_system.cc

Issue 23604050: Namespace internal extension JavaScript modules with extensions:: so that they (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Error Console Tests Fixed (uploaded by rdevlin.cronin) Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/extensions/module_system.cc
diff --git a/chrome/renderer/extensions/module_system.cc b/chrome/renderer/extensions/module_system.cc
index ffe446c74bba3848ff4b7239c0df54fb14153c26..f539d58a40a2c76b72737ca04492aee7985de1ab 100644
--- a/chrome/renderer/extensions/module_system.cc
+++ b/chrome/renderer/extensions/module_system.cc
@@ -210,7 +210,7 @@ v8::Handle<v8::Value> ModuleSystem::RequireForJsInner(
if (!exports->IsUndefined())
return handle_scope.Close(exports);
- std::string module_name_str = *v8::String::AsciiValue(module_name);
+ std::string module_name_str = *v8::String::Utf8Value(module_name);
v8::Handle<v8::Value> source(GetSource(module_name_str));
if (source.IsEmpty() || source->IsUndefined()) {
Fatal(context_, "No source for require(" + module_name_str + ")");
@@ -376,7 +376,7 @@ void ModuleSystem::LazyFieldGetterInner(
ModuleSystem* module_system = static_cast<ModuleSystem*>(
v8::Handle<v8::External>::Cast(module_system_value)->Value());
- std::string name = *v8::String::AsciiValue(
+ std::string name = *v8::String::Utf8Value(
parameters->Get(v8::String::New(kModuleName))->ToString());
// Switch to our v8 context because we need functions created while running
@@ -400,7 +400,7 @@ void ModuleSystem::LazyFieldGetterInner(
parameters->Get(v8::String::New(kModuleField))->ToString();
if (!module->Has(field)) {
- std::string field_str = *v8::String::AsciiValue(field);
+ std::string field_str = *v8::String::Utf8Value(field);
Fatal(module_system->context_,
"Lazy require of " + name + "." + field_str + " did not set the " +
field_str + " field");
@@ -468,10 +468,16 @@ v8::Handle<v8::Value> ModuleSystem::RunString(v8::Handle<v8::String> code,
v8::HandleScope handle_scope(GetIsolate());
v8::Context::Scope context_scope(context()->v8_context());
+ // Prepend extensions:: to |name| so that internal code can be differentiated
+ // from external code in stack traces. This has no effect on behaviour.
+ std::string internal_name = base::StringPrintf("extensions::%s",
+ *v8::String::Utf8Value(name));
+
WebKit::WebScopedMicrotaskSuppression suppression;
v8::TryCatch try_catch;
try_catch.SetCaptureMessage(true);
- v8::Handle<v8::Script> script(v8::Script::New(code, name));
+ v8::Handle<v8::Script> script(v8::Script::New(
+ code, v8::String::New(internal_name.c_str(), internal_name.size())));
if (try_catch.HasCaught()) {
HandleException(try_catch);
return v8::Undefined();
@@ -496,7 +502,7 @@ v8::Handle<v8::Value> ModuleSystem::GetSource(const std::string& module_name) {
void ModuleSystem::RequireNative(
const v8::FunctionCallbackInfo<v8::Value>& args) {
CHECK_EQ(1, args.Length());
- std::string native_name = *v8::String::AsciiValue(args[0]->ToString());
+ std::string native_name = *v8::String::Utf8Value(args[0]->ToString());
args.GetReturnValue().Set(RequireNativeFromString(native_name));
}
« no previous file with comments | « chrome/browser/extensions/error_console/error_console_browsertest.cc ('k') | extensions/common/extension_urls.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698