| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extension_frame_helper.h" | 5 #include "extensions/renderer/extension_frame_helper.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/timer/elapsed_timer.h" | 9 #include "base/timer/elapsed_timer.h" |
| 10 #include "content/public/renderer/render_frame.h" | 10 #include "content/public/renderer/render_frame.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 191 |
| 192 void ExtensionFrameHelper::DidStartProvisionalLoad() { | 192 void ExtensionFrameHelper::DidStartProvisionalLoad() { |
| 193 if (!delayed_main_world_script_initialization_) | 193 if (!delayed_main_world_script_initialization_) |
| 194 return; | 194 return; |
| 195 | 195 |
| 196 delayed_main_world_script_initialization_ = false; | 196 delayed_main_world_script_initialization_ = false; |
| 197 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); | 197 v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); |
| 198 v8::Local<v8::Context> context = | 198 v8::Local<v8::Context> context = |
| 199 render_frame()->GetWebFrame()->mainWorldScriptContext(); | 199 render_frame()->GetWebFrame()->mainWorldScriptContext(); |
| 200 v8::Context::Scope context_scope(context); | 200 v8::Context::Scope context_scope(context); |
| 201 extension_dispatcher_->DidCreateScriptContext( | 201 extension_dispatcher_->DidCreateScriptContext(render_frame()->GetWebFrame(), |
| 202 render_frame()->GetWebFrame(), context, 0, 0); | 202 context, 0); |
| 203 // TODO(devlin): Add constants for main world id, no extension group. | 203 // TODO(devlin): Add constants for main world id, no extension group. |
| 204 } | 204 } |
| 205 | 205 |
| 206 void ExtensionFrameHelper::DidCreateScriptContext( | 206 void ExtensionFrameHelper::DidCreateScriptContext( |
| 207 v8::Local<v8::Context> context, | 207 v8::Local<v8::Context> context, |
| 208 int extension_group, | |
| 209 int world_id) { | 208 int world_id) { |
| 210 if (context == render_frame()->GetWebFrame()->mainWorldScriptContext() && | 209 if (context == render_frame()->GetWebFrame()->mainWorldScriptContext() && |
| 211 render_frame()->IsBrowserSideNavigationPending()) { | 210 render_frame()->IsBrowserSideNavigationPending()) { |
| 212 DCHECK_EQ(0, extension_group); | |
| 213 DCHECK_EQ(0, world_id); | 211 DCHECK_EQ(0, world_id); |
| 214 DCHECK(!delayed_main_world_script_initialization_); | 212 DCHECK(!delayed_main_world_script_initialization_); |
| 215 // Defer initializing the extensions script context now because it depends | 213 // Defer initializing the extensions script context now because it depends |
| 216 // on having the URL of the provisional load which isn't available at this | 214 // on having the URL of the provisional load which isn't available at this |
| 217 // point with PlzNavigate. | 215 // point with PlzNavigate. |
| 218 delayed_main_world_script_initialization_ = true; | 216 delayed_main_world_script_initialization_ = true; |
| 219 } else { | 217 } else { |
| 220 extension_dispatcher_->DidCreateScriptContext( | 218 extension_dispatcher_->DidCreateScriptContext(render_frame()->GetWebFrame(), |
| 221 render_frame()->GetWebFrame(), context, extension_group, world_id); | 219 context, world_id); |
| 222 } | 220 } |
| 223 } | 221 } |
| 224 | 222 |
| 225 void ExtensionFrameHelper::WillReleaseScriptContext( | 223 void ExtensionFrameHelper::WillReleaseScriptContext( |
| 226 v8::Local<v8::Context> context, | 224 v8::Local<v8::Context> context, |
| 227 int world_id) { | 225 int world_id) { |
| 228 extension_dispatcher_->WillReleaseScriptContext( | 226 extension_dispatcher_->WillReleaseScriptContext( |
| 229 render_frame()->GetWebFrame(), context, world_id); | 227 render_frame()->GetWebFrame(), context, world_id); |
| 230 } | 228 } |
| 231 | 229 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 const base::ListValue& args) { | 318 const base::ListValue& args) { |
| 321 extension_dispatcher_->InvokeModuleSystemMethod( | 319 extension_dispatcher_->InvokeModuleSystemMethod( |
| 322 render_frame(), extension_id, module_name, function_name, args); | 320 render_frame(), extension_id, module_name, function_name, args); |
| 323 } | 321 } |
| 324 | 322 |
| 325 void ExtensionFrameHelper::OnDestruct() { | 323 void ExtensionFrameHelper::OnDestruct() { |
| 326 delete this; | 324 delete this; |
| 327 } | 325 } |
| 328 | 326 |
| 329 } // namespace extensions | 327 } // namespace extensions |
| OLD | NEW |