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

Unified Diff: extensions/renderer/user_script_set.cc

Issue 1140173003: Allow whitelisted content scripts to be injected in WebViews. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@document_has_focus
Patch Set: Created 5 years, 7 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
Index: extensions/renderer/user_script_set.cc
diff --git a/extensions/renderer/user_script_set.cc b/extensions/renderer/user_script_set.cc
index 58e9de17cc89bb0fd72d755af79f92e4ff474aba..2404d7441e362447adee399f8f5f72ea1cd11934 100644
--- a/extensions/renderer/user_script_set.cc
+++ b/extensions/renderer/user_script_set.cc
@@ -9,6 +9,7 @@
#include "content/public/renderer/render_thread.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_set.h"
+#include "extensions/common/extensions_client.h"
#include "extensions/common/permissions/permissions_data.h"
#include "extensions/renderer/extension_injection_host.h"
#include "extensions/renderer/extensions_renderer_client.h"
@@ -86,7 +87,8 @@ void UserScriptSet::GetInjections(
}
bool UserScriptSet::UpdateUserScripts(base::SharedMemoryHandle shared_memory,
- const std::set<HostID>& changed_hosts) {
+ const std::set<HostID>& changed_hosts,
+ bool whitelisted_only) {
bool only_inject_incognito =
ExtensionsRendererClient::Get()->IsIncognitoProcess();
@@ -140,6 +142,15 @@ bool UserScriptSet::UpdateUserScripts(base::SharedMemoryHandle shared_memory,
if (only_inject_incognito && !script->is_incognito_enabled())
continue; // This script shouldn't run in an incognito tab.
+ if (whitelisted_only) {
+ const ExtensionsClient::ScriptingWhitelist& whitelist =
+ ExtensionsClient::Get()->GetScriptingWhitelist();
+ if (std::find(whitelist.begin(), whitelist.end(),
+ script->extension_id()) == whitelist.end()) {
+ continue;
+ }
+ }
+
scripts_.push_back(script.release());
}

Powered by Google App Engine
This is Rietveld 408576698