Chromium Code Reviews| Index: extensions/renderer/dispatcher.cc |
| diff --git a/extensions/renderer/dispatcher.cc b/extensions/renderer/dispatcher.cc |
| index d52d1505c06bfe2a7da38acde2639c831bf5fa29..20acee89b1e235a4ba292e463007f46cb595f6fd 100644 |
| --- a/extensions/renderer/dispatcher.cc |
| +++ b/extensions/renderer/dispatcher.cc |
| @@ -219,7 +219,9 @@ bool Dispatcher::IsExtensionActive(const std::string& extension_id) const { |
| return is_active; |
| } |
| -std::string Dispatcher::GetExtensionID(const WebFrame* frame, int world_id) { |
| +std::string Dispatcher::GetExtensionID(const WebFrame* frame, |
| + int world_id, |
| + bool use_effective_url) { |
| if (world_id != 0) { |
| // Isolated worlds (content script). |
| return ScriptInjection::GetExtensionIdForIsolatedWorld(world_id); |
| @@ -231,6 +233,8 @@ std::string Dispatcher::GetExtensionID(const WebFrame* frame, int world_id) { |
| // Extension pages (chrome-extension:// URLs). |
| GURL frame_url = ScriptContext::GetDataSourceURLForFrame(frame); |
| + frame_url = ScriptContext::GetEffectiveDocumentURL( |
| + frame, frame_url, use_effective_url); |
| return extensions_.GetExtensionOrAppIDByURL(frame_url); |
| } |
| @@ -243,7 +247,7 @@ void Dispatcher::DidCreateScriptContext( |
| return; |
| #endif |
| - std::string extension_id = GetExtensionID(frame, world_id); |
| + std::string extension_id = GetExtensionID(frame, world_id, false); |
| const Extension* extension = extensions_.GetByID(extension_id); |
|
Devlin
2014/09/03 22:09:16
This is unnecessarily complicated. We should just
Marijn Kruisselbrink
2014/09/03 23:54:07
Done, although I'm not entirely sure if it really
Devlin
2014/09/04 19:15:10
Good point, so I don't really feel too strongly ei
Marijn Kruisselbrink
2014/09/04 23:41:11
Actually I kind of like having this GetExtensionFr
|
| if (!extension && !extension_id.empty()) { |
| @@ -260,15 +264,28 @@ void Dispatcher::DidCreateScriptContext( |
| extension_id = ""; |
| } |
| + extension_id = GetExtensionID(frame, world_id, true); |
| + const Extension* effective_extension = extensions_.GetByID(extension_id); |
|
Devlin
2014/09/03 22:09:16
If I recall correctly, GetEffectiveDocumentURL() o
Marijn Kruisselbrink
2014/09/03 23:54:07
Yes, the ideal end state is to get rid of extensio
Devlin
2014/09/04 19:15:10
Ah. That's too bad. Okay.
|
| + |
| + GURL frame_url = ScriptContext::GetDataSourceURLForFrame(frame); |
| Feature::Context context_type = |
| ClassifyJavaScriptContext(extension, |
| extension_group, |
| - ScriptContext::GetDataSourceURLForFrame(frame), |
| + frame_url, |
| frame->document().securityOrigin()); |
| + Feature::Context effective_context_type = ClassifyJavaScriptContext( |
| + effective_extension, |
| + extension_group, |
| + ScriptContext::GetEffectiveDocumentURL(frame, frame_url, true), |
| + frame->document().securityOrigin()); |
| ScriptContext* context = |
| - delegate_->CreateScriptContext(v8_context, frame, extension, context_type) |
| - .release(); |
| + delegate_->CreateScriptContext(v8_context, |
| + frame, |
| + extension, |
| + context_type, |
| + effective_extension, |
| + effective_context_type).release(); |
| script_context_set_.Add(context); |
| // Initialize origin permissions for content scripts, which can't be |