Chromium Code Reviews| Index: extensions/renderer/script_injection_manager.cc |
| diff --git a/extensions/renderer/script_injection_manager.cc b/extensions/renderer/script_injection_manager.cc |
| index 93862dd04bdfe1109bf23c223ccef4cb734ec90e..ca2f0178a18cf81610d0626295243202d7d5acc7 100644 |
| --- a/extensions/renderer/script_injection_manager.cc |
| +++ b/extensions/renderer/script_injection_manager.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/bind.h" |
| #include "base/memory/weak_ptr.h" |
| #include "base/values.h" |
| +#include "content/public/renderer/render_frame.h" |
| #include "content/public/renderer/render_thread.h" |
| #include "content/public/renderer/render_view.h" |
| #include "content/public/renderer/render_view_observer.h" |
| @@ -67,6 +68,29 @@ scoped_ptr<ExtensionInjectionHost> GetExtensionInjectionHost( |
| new ExtensionInjectionHost(extension)); |
| } |
| +// TODO(robwu): ScriptInjectionManager should use RenderFrame instead of |
| +// RenderView. Then the browser should direct messages to specific frames and |
| +// this check becomes redundant. |
| +blink::WebLocalFrame* GetFrameByFrameId(blink::WebFrame* parent_frame, |
|
nasko
2015/02/23 18:39:02
Since this is a new function trying to work on the
robwu
2015/02/23 18:59:53
RenderFrames definitely make more sense, but curre
|
| + int frame_id) { |
| + DCHECK(parent_frame); |
|
not at google - send to devlin
2015/02/23 20:41:24
This seems more like a CHECK situation to me.
robwu
2015/02/23 21:54:06
I've only put the DCHECK over there to document th
|
| + blink::WebLocalFrame* result = nullptr; |
| + for (blink::WebFrame* frame = parent_frame->firstChild(); !result && frame; |
|
not at google - send to devlin
2015/02/23 20:41:24
Pulling this comment out of the thread below: we a
robwu
2015/02/23 21:54:06
This one: https://cs.chromium.org/AppendAllChildFr
not at google - send to devlin
2015/02/23 22:04:15
That's it. Its call site would be nicer with an it
|
| + frame = frame->nextSibling()) { |
|
dcheng
2015/02/23 16:16:01
We definitely shouldn't be looping through all the
not at google - send to devlin
2015/02/23 16:50:17
This is a project unto itself. I just filed crbug.
dcheng
2015/02/23 16:56:42
I realize this is going to be a non-trivial amount
robwu
2015/02/23 17:13:40
Even after fixing the IPC, this feature will still
robwu
2015/02/23 17:44:36
I'd take the 32 least significant bits. This trunc
|
| + content::RenderFrame* rf = content::RenderFrame::FromWebFrame(frame); |
| + if (rf && rf->GetRoutingID() == frame_id) { |
| + // TODO(robwu): This does not work with OOPIF. That doesn't really matter |
| + // for now, because ScriptInjectionManager is not OOPIF-friendly anyway. |
| + // This helper function will be obsolete when this class is converted to |
| + // RenderFrame. |
| + result = frame->toWebLocalFrame(); |
| + } else { |
| + result = GetFrameByFrameId(frame, frame_id); |
| + } |
| + } |
| + return result; |
| +} |
| + |
| } // namespace |
| class ScriptInjectionManager::RVOHelper : public content::RenderViewObserver { |
| @@ -418,16 +442,18 @@ void ScriptInjectionManager::InjectScripts( |
| void ScriptInjectionManager::HandleExecuteCode( |
| const ExtensionMsg_ExecuteCode_Params& params, |
| content::RenderView* render_view) { |
| + blink::WebLocalFrame* main_frame = |
| + render_view->GetWebView()->mainFrame()->toWebLocalFrame(); |
|
nasko
2015/02/23 18:39:02
This will definitely fail with --site-per-process.
robwu
2015/02/23 18:59:53
This whole class does not work with OOPIF at the m
|
| + if (main_frame && params.frame_id > 0) |
| + main_frame = GetFrameByFrameId(main_frame, params.frame_id); |
| // TODO(dcheng): Not sure how this can happen today. In an OOPI world, it |
| // would indicate a logic error--the browser must direct this request to the |
| // right renderer process to begin with. |
| - blink::WebLocalFrame* main_frame = |
| - render_view->GetWebView()->mainFrame()->toWebLocalFrame(); |
| if (!main_frame) { |
| render_view->Send( |
| new ExtensionHostMsg_ExecuteCodeFinished(render_view->GetRoutingID(), |
| params.request_id, |
| - "No main frame", |
| + "Frame not found.", |
| GURL(std::string()), |
| base::ListValue())); |
| return; |