| Index: extensions/renderer/script_injection.cc
|
| diff --git a/extensions/renderer/script_injection.cc b/extensions/renderer/script_injection.cc
|
| index 9f3236f9d20d0a14ebb43803edca2d1294724213..52d08cca10887555dd93f624d70cde0f5ebd0efa 100644
|
| --- a/extensions/renderer/script_injection.cc
|
| +++ b/extensions/renderer/script_injection.cc
|
| @@ -14,7 +14,6 @@
|
| #include "content/public/renderer/render_view.h"
|
| #include "extensions/common/extension.h"
|
| #include "extensions/common/extension_messages.h"
|
| -#include "extensions/common/feature_switch.h"
|
| #include "extensions/common/manifest_handlers/csp_info.h"
|
| #include "extensions/renderer/dom_activity_logger.h"
|
| #include "extensions/renderer/extension_groups.h"
|
| @@ -40,10 +39,6 @@ const int64 kInvalidRequestId = -1;
|
| // The id of the next pending injection.
|
| int64 g_next_pending_id = 0;
|
|
|
| -bool ShouldNotifyBrowserOfInjections() {
|
| - return !FeatureSwitch::scripts_require_action()->IsEnabled();
|
| -}
|
| -
|
| // Append all the child frames of |parent_frame| to |frames_vector|.
|
| void AppendAllChildFrames(blink::WebFrame* parent_frame,
|
| std::vector<blink::WebFrame*>* frames_vector) {
|
| @@ -152,7 +147,7 @@ bool ScriptInjection::TryToInject(UserScript::RunLocation current_location,
|
| NotifyWillNotInject(ScriptInjector::NOT_ALLOWED);
|
| return true; // We're done.
|
| case PermissionsData::ACCESS_WITHHELD:
|
| - RequestPermission();
|
| + SendInjectionMessage(true /* request permission */);
|
| return false; // Wait around for permission.
|
| case PermissionsData::ACCESS_ALLOWED:
|
| Inject(extension, scripts_run_info);
|
| @@ -175,14 +170,13 @@ bool ScriptInjection::OnPermissionGranted(const Extension* extension,
|
| return true;
|
| }
|
|
|
| -void ScriptInjection::RequestPermission() {
|
| +void ScriptInjection::SendInjectionMessage(bool request_permission) {
|
| content::RenderView* render_view =
|
| content::RenderView::FromWebView(web_frame()->top()->view());
|
|
|
| // If we are just notifying the browser of the injection, then send an
|
| // invalid request (which is treated like a notification).
|
| - request_id_ = ShouldNotifyBrowserOfInjections() ? kInvalidRequestId
|
| - : g_next_pending_id++;
|
| + request_id_ = request_permission ? g_next_pending_id++ : kInvalidRequestId;
|
| render_view->Send(new ExtensionHostMsg_RequestScriptInjectionPermission(
|
| render_view->GetRoutingID(),
|
| extension_id_,
|
| @@ -196,14 +190,25 @@ void ScriptInjection::NotifyWillNotInject(
|
| injector_->OnWillNotInject(reason);
|
| }
|
|
|
| +void ScriptInjection::NotifyBrowserOfInjection(const Extension* extension) {
|
| + // We notify the browser of any injection if the extension has no withheld
|
| + // permissions (i.e., the permissions weren't restricted), but would have
|
| + // otherwise been affected by the scripts-require-action feature.
|
| + if (extension->permissions_data()->withheld_permissions()->IsEmpty() &&
|
| + PermissionsData::ScriptsMayRequireActionForExtension(
|
| + extension,
|
| + extension->permissions_data()->active_permissions().get())) {
|
| + SendInjectionMessage(false /* don't request permission */);
|
| + }
|
| +}
|
| +
|
| void ScriptInjection::Inject(const Extension* extension,
|
| ScriptsRunInfo* scripts_run_info) {
|
| DCHECK(extension);
|
| DCHECK(scripts_run_info);
|
| DCHECK(!complete_);
|
|
|
| - if (ShouldNotifyBrowserOfInjections())
|
| - RequestPermission();
|
| + NotifyBrowserOfInjection(extension);
|
|
|
| std::vector<blink::WebFrame*> frame_vector;
|
| frame_vector.push_back(web_frame_);
|
|
|