| Index: chrome/renderer/extensions/user_script_scheduler.cc
|
| diff --git a/chrome/renderer/extensions/user_script_scheduler.cc b/chrome/renderer/extensions/user_script_scheduler.cc
|
| index f3ef86f615be1fcbe9eda9f136be08e96f69ad55..558ada07830d5ac657c167d03355910a6b558e6a 100644
|
| --- a/chrome/renderer/extensions/user_script_scheduler.cc
|
| +++ b/chrome/renderer/extensions/user_script_scheduler.cc
|
| @@ -11,6 +11,7 @@
|
| #include "chrome/common/extensions/extension_messages.h"
|
| #include "chrome/common/extensions/permissions/permissions_data.h"
|
| #include "chrome/renderer/chrome_render_process_observer.h"
|
| +#include "chrome/renderer/extensions/chrome_v8_context.h"
|
| #include "chrome/renderer/extensions/dispatcher.h"
|
| #include "chrome/renderer/extensions/dom_activity_logger.h"
|
| #include "chrome/renderer/extensions/extension_groups.h"
|
| @@ -199,12 +200,11 @@ void UserScriptScheduler::ExecuteCodeImpl(
|
| }
|
|
|
| WebScriptSource source(WebString::fromUTF8(params.code));
|
| - v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| - v8::HandleScope scope(isolate);
|
| + v8::HandleScope scope;
|
|
|
| scoped_ptr<content::V8ValueConverter> v8_converter(
|
| content::V8ValueConverter::create());
|
| - v8::Handle<v8::Value> script_value;
|
| + v8::Local<v8::Value> script_value;
|
|
|
| if (params.in_main_world) {
|
| DOMActivityLogger::AttachToWorld(
|
| @@ -232,15 +232,17 @@ void UserScriptScheduler::ExecuteCodeImpl(
|
| if (results.size() == 1 && !results[0].IsEmpty())
|
| script_value = results[0];
|
| }
|
| - if (!script_value.IsEmpty()) {
|
| - v8::Local<v8::Context> context = v8::Context::New(isolate);
|
| - base::Value* base_val =
|
| - v8_converter->FromV8Value(script_value, context);
|
| +
|
| + if (params.wants_result && !script_value.IsEmpty()) {
|
| + // It's safe to always use the main world context when converting here.
|
| + // V8ValueConverterImpl shouldn't actually care about the context scope,
|
| + // and it switches to v8::Object's creation context when encountered.
|
| + v8::Local<v8::Context> context = child_frame->mainWorldScriptContext();
|
| + base::Value* result = v8_converter->FromV8Value(script_value, context);
|
| // Always append an execution result (i.e. no result == null result) so
|
| // that |execution_results| lines up with the frames.
|
| - execution_results.Append(base_val ? base_val :
|
| - base::Value::CreateNullValue());
|
| - script_value.Clear();
|
| + execution_results.Append(
|
| + result ? result : base::Value::CreateNullValue());
|
| }
|
| } else {
|
| child_frame->document().insertUserStyleSheet(
|
|
|