OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/script_injection_manager.h" | 5 #include "extensions/renderer/script_injection_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "content/public/renderer/render_view.h" | 10 #include "content/public/renderer/render_view.h" |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 pending_injections_.push_back(injection.release()); | 314 pending_injections_.push_back(injection.release()); |
315 } | 315 } |
316 } | 316 } |
317 | 317 |
318 scripts_run_info.LogRun(frame, run_location); | 318 scripts_run_info.LogRun(frame, run_location); |
319 } | 319 } |
320 | 320 |
321 void ScriptInjectionManager::HandleExecuteCode( | 321 void ScriptInjectionManager::HandleExecuteCode( |
322 const ExtensionMsg_ExecuteCode_Params& params, | 322 const ExtensionMsg_ExecuteCode_Params& params, |
323 content::RenderView* render_view) { | 323 content::RenderView* render_view) { |
324 blink::WebFrame* main_frame = render_view->GetWebView()->mainFrame(); | 324 // TODO(dcheng): Not sure how this can happen today. In an OOPI world, it |
| 325 // would indicate a logic error--the browser must direct this request to the |
| 326 // right renderer process to begin with. |
| 327 blink::WebLocalFrame* main_frame = |
| 328 render_view->GetWebView()->mainFrame()->toWebLocalFrame(); |
325 if (!main_frame) { | 329 if (!main_frame) { |
326 render_view->Send( | 330 render_view->Send( |
327 new ExtensionHostMsg_ExecuteCodeFinished(render_view->GetRoutingID(), | 331 new ExtensionHostMsg_ExecuteCodeFinished(render_view->GetRoutingID(), |
328 params.request_id, | 332 params.request_id, |
329 "No main frame", | 333 "No main frame", |
330 GURL(std::string()), | 334 GURL(std::string()), |
331 base::ListValue())); | 335 base::ListValue())); |
332 return; | 336 return; |
333 } | 337 } |
334 | 338 |
(...skipping 15 matching lines...) Expand all Loading... |
350 } | 354 } |
351 } | 355 } |
352 | 356 |
353 void ScriptInjectionManager::HandleExecuteDeclarativeScript( | 357 void ScriptInjectionManager::HandleExecuteDeclarativeScript( |
354 blink::WebFrame* web_frame, | 358 blink::WebFrame* web_frame, |
355 int tab_id, | 359 int tab_id, |
356 const ExtensionId& extension_id, | 360 const ExtensionId& extension_id, |
357 int script_id, | 361 int script_id, |
358 const GURL& url) { | 362 const GURL& url) { |
359 const Extension* extension = extensions_->GetByID(extension_id); | 363 const Extension* extension = extensions_->GetByID(extension_id); |
| 364 // TODO(dcheng): This function signature should really be a WebLocalFrame, |
| 365 // rather than trying to coerce it here. |
360 scoped_ptr<ScriptInjection> injection = | 366 scoped_ptr<ScriptInjection> injection = |
361 user_script_set_manager_->GetInjectionForDeclarativeScript( | 367 user_script_set_manager_->GetInjectionForDeclarativeScript( |
362 script_id, | 368 script_id, |
363 web_frame, | 369 web_frame->toWebLocalFrame(), |
364 tab_id, | 370 tab_id, |
365 url, | 371 url, |
366 extension); | 372 extension); |
367 if (injection.get()) { | 373 if (injection.get()) { |
368 ScriptsRunInfo scripts_run_info; | 374 ScriptsRunInfo scripts_run_info; |
369 // TODO(markdittmer): Use return value of TryToInject for error handling. | 375 // TODO(markdittmer): Use return value of TryToInject for error handling. |
370 injection->TryToInject(UserScript::BROWSER_DRIVEN, | 376 injection->TryToInject(UserScript::BROWSER_DRIVEN, |
371 extension, | 377 extension, |
372 &scripts_run_info); | 378 &scripts_run_info); |
373 scripts_run_info.LogRun(web_frame, UserScript::BROWSER_DRIVEN); | 379 scripts_run_info.LogRun(web_frame, UserScript::BROWSER_DRIVEN); |
(...skipping 20 matching lines...) Expand all Loading... |
394 | 400 |
395 ScriptsRunInfo scripts_run_info; | 401 ScriptsRunInfo scripts_run_info; |
396 if (injection->OnPermissionGranted(extensions_->GetByID( | 402 if (injection->OnPermissionGranted(extensions_->GetByID( |
397 injection->extension_id()), | 403 injection->extension_id()), |
398 &scripts_run_info)) { | 404 &scripts_run_info)) { |
399 scripts_run_info.LogRun(injection->web_frame(), UserScript::RUN_DEFERRED); | 405 scripts_run_info.LogRun(injection->web_frame(), UserScript::RUN_DEFERRED); |
400 } | 406 } |
401 } | 407 } |
402 | 408 |
403 } // namespace extensions | 409 } // namespace extensions |
OLD | NEW |