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

Unified Diff: extensions/browser/guest_view/web_view/web_view_content_script_manager.cc

Issue 2227193002: Make UserScript non-copyable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync @tott Created 4 years, 4 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/browser/guest_view/web_view/web_view_content_script_manager.cc
diff --git a/extensions/browser/guest_view/web_view/web_view_content_script_manager.cc b/extensions/browser/guest_view/web_view/web_view_content_script_manager.cc
index d08769f6534c7caba1974b17a9d8cda91a0d6602..032ea7a4a1cd81405e086a67bfc8b1213a8ab044 100644
--- a/extensions/browser/guest_view/web_view/web_view_content_script_manager.cc
+++ b/extensions/browser/guest_view/web_view/web_view_content_script_manager.cc
@@ -46,7 +46,7 @@ void WebViewContentScriptManager::AddContentScripts(
content::RenderFrameHost* render_frame_host,
int view_instance_id,
const HostID& host_id,
- const UserScriptList& scripts) {
+ std::unique_ptr<UserScriptList> scripts) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DeclarativeUserScriptMaster* master =
@@ -72,8 +72,8 @@ void WebViewContentScriptManager::AddContentScripts(
// Step 2: updates the guest_content_script_map_.
ContentScriptMap& map = iter->second;
std::set<UserScriptIDPair> to_delete;
- for (const UserScript& script : scripts) {
- auto map_iter = map.find(script.name());
+ for (const std::unique_ptr<UserScript>& script : *scripts) {
+ auto map_iter = map.find(script->name());
// If a content script has the same name as the new one, remove the old
// script first, and insert the new one.
if (map_iter != map.end()) {
@@ -81,9 +81,10 @@ void WebViewContentScriptManager::AddContentScripts(
map.erase(map_iter);
}
map.insert(std::pair<std::string, UserScriptIDPair>(
- script.name(), UserScriptIDPair(script.id(), script.host_id())));
- ids_to_add.insert(script.id());
+ script->name(), UserScriptIDPair(script->id(), script->host_id())));
+ ids_to_add.insert(script->id());
}
+
if (!to_delete.empty())
master->RemoveScripts(to_delete);
@@ -95,7 +96,7 @@ void WebViewContentScriptManager::AddContentScripts(
user_script_loader_observer_.Add(loader);
// Step 4: adds new scripts to the master.
- master->AddScripts(scripts, embedder_process_id,
+ master->AddScripts(std::move(scripts), embedder_process_id,
render_frame_host->GetRoutingID());
// Step 5: creates an entry in |webview_host_id_map_| for the given
« no previous file with comments | « extensions/browser/guest_view/web_view/web_view_content_script_manager.h ('k') | extensions/browser/user_script_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698