Chromium Code Reviews| Index: extensions/renderer/script_injection.cc |
| diff --git a/extensions/renderer/script_injection.cc b/extensions/renderer/script_injection.cc |
| index 3c77f9af5ed88fb3c7794bb2f3ee4c4be1cf3ab8..a1ae1e27a478f2d1603a4b6c62cd1f0e754ee6de 100644 |
| --- a/extensions/renderer/script_injection.cc |
| +++ b/extensions/renderer/script_injection.cc |
| @@ -40,8 +40,8 @@ const int kInvalidRequestId = -1; |
| // The id of the next pending injection. |
| int64 g_next_pending_id = 0; |
| -bool ShouldDelayForPermission() { |
| - return FeatureSwitch::scripts_require_action()->IsEnabled(); |
| +bool NotifyBrowserOfInjections() { |
|
not at google - send to devlin
2014/06/27 23:24:34
this should start with Should otherwise it sounds
Devlin
2014/06/30 17:06:11
Done.
|
| + return !FeatureSwitch::scripts_require_action()->IsEnabled(); |
| } |
| // Append all the child frames of |parent_frame| to |frames_vector|. |
| @@ -145,15 +145,13 @@ bool ScriptInjection::TryToInject(UserScript::RunLocation current_location, |
| switch (injector_->CanExecuteOnFrame( |
| extension, web_frame_, tab_id_, web_frame_->top()->document().url())) { |
| - case ScriptInjector::DENY_ACCESS: |
| + case PermissionsData::DENY_ACCESS: |
| NotifyWillNotInject(ScriptInjector::NOT_ALLOWED); |
| return true; // We're done. |
| - case ScriptInjector::REQUEST_ACCESS: |
| + case PermissionsData::REQUEST_ACCESS: |
| RequestPermission(); |
| - if (ShouldDelayForPermission()) |
| - return false; // Wait around for permission. |
| - // else fall through |
| - case ScriptInjector::ALLOW_ACCESS: |
| + return false; // Wait around for permission. |
| + case PermissionsData::ALLOW_ACCESS: |
|
not at google - send to devlin
2014/06/27 23:24:34
I think it's fine if this class just interprets wh
Devlin
2014/06/30 17:06:11
Done.
|
| Inject(extension, scripts_run_info); |
| return true; // We're done! |
| } |
| @@ -178,13 +176,14 @@ void ScriptInjection::RequestPermission() { |
| content::RenderView* render_view = |
| content::RenderView::FromWebView(web_frame()->top()->view()); |
| - // If the feature to delay for permission isn't enabled, then just send an |
| + // If we are just notifying the browser of the injection, then send an |
| // invalid request (which is treated like a notification). |
| - request_id_ = |
| - ShouldDelayForPermission() ? g_next_pending_id++ : kInvalidRequestId; |
| + request_id_ = NotifyBrowserOfInjections() ? kInvalidRequestId |
| + : g_next_pending_id++; |
| render_view->Send(new ExtensionHostMsg_RequestScriptInjectionPermission( |
| render_view->GetRoutingID(), |
| extension_id_, |
| + injector_->script_type(), |
|
not at google - send to devlin
2014/06/27 23:24:34
I think that exposing the "script type" isn't quit
Devlin
2014/06/30 17:06:11
My thought was that it's not unlikely (and perhaps
not at google - send to devlin
2014/07/01 00:28:35
maybe. but we don't need it now, and like I said i
not at google - send to devlin
2014/07/01 02:56:50
I should explain more.
My "wrong idiom" comment i
Devlin
2014/07/01 16:27:05
Yeah, constants.h is kind of a "I give up" locatio
not at google - send to devlin
2014/07/01 17:02:11
ok, let's throw it in UserScript.
then maybe pull
Devlin
2014/07/01 18:34:08
Done.
|
| render_view->GetPageId(), |
| request_id_)); |
| } |
| @@ -201,6 +200,9 @@ void ScriptInjection::Inject(const Extension* extension, |
| DCHECK(scripts_run_info); |
| DCHECK(!complete_); |
| + if (NotifyBrowserOfInjections()) |
| + RequestPermission(); |
| + |
| std::vector<blink::WebFrame*> frame_vector; |
| frame_vector.push_back(web_frame_); |
| if (injector_->ShouldExecuteInChildFrames()) |
| @@ -230,7 +232,7 @@ void ScriptInjection::Inject(const Extension* extension, |
| // surface a request for a child frame. |
| // TODO(rdevlin.cronin): We should ask for permission somehow. |
| if (injector_->CanExecuteOnFrame(extension, frame, tab_id_, top_url) == |
| - ScriptInjector::DENY_ACCESS) { |
| + PermissionsData::DENY_ACCESS) { |
| DCHECK(frame->parent()); |
| continue; |
| } |