Chromium Code Reviews| Index: extensions/renderer/script_context.cc |
| diff --git a/extensions/renderer/script_context.cc b/extensions/renderer/script_context.cc |
| index a1af29591c3b6f497d9222a6e68e21d8995d9366..0bdf302d27ac12a999997e5ce9551112c5250c78 100644 |
| --- a/extensions/renderer/script_context.cc |
| +++ b/extensions/renderer/script_context.cc |
| @@ -33,24 +33,32 @@ namespace extensions { |
| ScriptContext::ScriptContext(const v8::Handle<v8::Context>& v8_context, |
| blink::WebFrame* web_frame, |
| const Extension* extension, |
| - Feature::Context context_type) |
| + Feature::Context context_type, |
| + const Extension* effective_extension, |
| + Feature::Context effective_context_type) |
| : v8_context_(v8_context), |
| web_frame_(web_frame), |
| extension_(extension), |
| context_type_(context_type), |
| + effective_extension_(effective_extension), |
| + effective_context_type_(effective_context_type), |
| safe_builtins_(this), |
| isolate_(v8_context->GetIsolate()) { |
| VLOG(1) << "Created context:\n" |
| << " extension id: " << GetExtensionID() << "\n" |
| << " frame: " << web_frame_ << "\n" |
| << " URL: " << GetURL() << "\n" |
| - << " context type: " << GetContextTypeDescription(); |
| + << " context type: " << GetContextTypeDescription() << "\n" |
| + << " effective extension id: " << GetEffectiveExtensionID() << "\n" |
| + << " effective context type: " |
| + << GetEffectiveContextTypeDescription(); |
| gin::PerContextData::From(v8_context)->set_runner(this); |
| } |
| ScriptContext::~ScriptContext() { |
| VLOG(1) << "Destroyed context for extension\n" |
| - << " extension id: " << GetExtensionID(); |
| + << " extension id: " << GetExtensionID() << "\n" |
| + << " effective extension id: " << GetEffectiveExtensionID(); |
| Invalidate(); |
| } |
| @@ -67,6 +75,11 @@ const std::string& ScriptContext::GetExtensionID() const { |
| return extension_.get() ? extension_->id() : base::EmptyString(); |
| } |
| +const std::string& ScriptContext::GetEffectiveExtensionID() const { |
| + return effective_extension_.get() ? effective_extension_->id() |
| + : base::EmptyString(); |
| +} |
| + |
| content::RenderView* ScriptContext::GetRenderView() const { |
| if (web_frame_ && web_frame_->view()) |
| return content::RenderView::FromWebView(web_frame_->view()); |
| @@ -132,8 +145,10 @@ void ScriptContext::DispatchOnUnloadEvent() { |
| module_system_->CallModuleMethod("unload_event", "dispatch"); |
| } |
| -std::string ScriptContext::GetContextTypeDescription() { |
| - switch (context_type_) { |
| +// static |
| +std::string ScriptContext::GetContextTypeDescription( |
|
Devlin
2014/09/03 22:09:16
Unless this is used elsewhere, I'd probably move i
Marijn Kruisselbrink
2014/09/03 23:54:07
Done.
|
| + Feature::Context context_type) { |
| + switch (context_type) { |
| case Feature::UNSPECIFIED_CONTEXT: |
| return "UNSPECIFIED"; |
| case Feature::BLESSED_EXTENSION_CONTEXT: |
| @@ -153,6 +168,14 @@ std::string ScriptContext::GetContextTypeDescription() { |
| return std::string(); |
| } |
| +std::string ScriptContext::GetContextTypeDescription() { |
| + return GetContextTypeDescription(context_type_); |
| +} |
| + |
| +std::string ScriptContext::GetEffectiveContextTypeDescription() { |
| + return GetContextTypeDescription(effective_context_type_); |
| +} |
| + |
| GURL ScriptContext::GetURL() const { |
| return web_frame() ? GetDataSourceURLForFrame(web_frame()) : GURL(); |
| } |