Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Unified Diff: extensions/renderer/script_injection.cc

Issue 922403002: [Extensions] Adjust script injection reporting to the browser side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/renderer/script_injection.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/script_injection.cc
diff --git a/extensions/renderer/script_injection.cc b/extensions/renderer/script_injection.cc
index 94affa02ab23820adcc286a4cd30c98bd398152f..58cf3280b95c31fe0048a2a0197e4e6cdd59ecde 100644
--- a/extensions/renderer/script_injection.cc
+++ b/extensions/renderer/script_injection.cc
@@ -13,7 +13,6 @@
#include "content/public/child/v8_value_converter.h"
#include "content/public/renderer/render_view.h"
#include "extensions/common/extension_messages.h"
-#include "extensions/common/feature_switch.h"
#include "extensions/common/host_id.h"
#include "extensions/common/manifest_handlers/csp_info.h"
#include "extensions/renderer/dom_activity_logger.h"
@@ -41,10 +40,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) {
@@ -150,15 +145,14 @@ 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(injection_host, scripts_run_info);
return true; // We're done!
}
- // Some compilers don't realize that we always return from the switch() above.
- // Make them happy.
+ NOTREACHED();
return false;
}
@@ -173,14 +167,13 @@ bool ScriptInjection::OnPermissionGranted(const InjectionHost* injection_host,
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(),
host_id_.id(),
@@ -200,9 +193,8 @@ void ScriptInjection::Inject(const InjectionHost* injection_host,
DCHECK(scripts_run_info);
DCHECK(!complete_);
- if (ShouldNotifyBrowserOfInjections() &&
- injection_host->id().type() == HostID::EXTENSIONS)
- RequestPermission();
+ if (injection_host->ShouldNotifyBrowserOfInjection())
+ SendInjectionMessage(false /* don't request permission */);
std::vector<blink::WebFrame*> frame_vector;
frame_vector.push_back(web_frame_);
« no previous file with comments | « extensions/renderer/script_injection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698