Add injection key for programmatic CSS injections
This builds on crrev.com/c/877663
For programmatic CSS injections via tabs.insertCSS, we calculate an
"injection key" deterministically based on either the file URL or the
code string. This enables us to later remove the injected CSS by the
same parameters that were used to inject it.
Changes:
1. ExtensionMsg_ExecuteCode_Params has a new member called
injection_key of type base::Optional<std::string>
2. ScriptExecutor::ExecuteScript now calculates an injection key for
CSS injections; this is a combination of the type (file or code),
the host ID, and the hash digest (base::Hash) of either the file
URL, if available, or the the code string
3. ScriptInjector has a new method called GetInjectionKey;
UserScriptInjector always returns null, whereas
ProgrammaticScriptInjector returns the value passed to it via
ExtensionMsg_ExecuteCode_Params
4. ScriptInjection::InjectCss now passes the actual injection key to
WebDocument::InsertStyleSheet
BUG=608854
Change-Id: I91a3983682cc61d739d3c31a11e8f58dabb8e12c
Reviewed-on: https://chromium-review.googlesource.com/913628
Reviewed-by: Devlin <[email protected]>
Reviewed-by: Kinuko Yasuda <[email protected]>
Commit-Queue: Manish Jethani <[email protected]>
Cr-Commit-Position: refs/heads/master@{#538722}
diff --git a/extensions/renderer/user_script_injector.cc b/extensions/renderer/user_script_injector.cc
index 972d47a..3e69ab0 100644
--- a/extensions/renderer/user_script_injector.cc
+++ b/extensions/renderer/user_script_injector.cc
@@ -149,6 +149,10 @@
return base::nullopt;
}
+const base::Optional<std::string> UserScriptInjector::GetInjectionKey() const {
+ return base::nullopt;
+}
+
bool UserScriptInjector::ShouldInjectJs(
UserScript::RunLocation run_location,
const std::set<std::string>& executing_scripts) const {