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

Unified Diff: chrome/browser/extensions/shared_user_script_master.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: chrome/browser/extensions/shared_user_script_master.cc
diff --git a/chrome/browser/extensions/shared_user_script_master.cc b/chrome/browser/extensions/shared_user_script_master.cc
index 6a0dde4957736f3b9fd93535522f183094efaade..f1d6e7abc9a9a031dc9fac470261cc0be8c1519f 100644
--- a/chrome/browser/extensions/shared_user_script_master.cc
+++ b/chrome/browser/extensions/shared_user_script_master.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/extensions/shared_user_script_master.h"
+#include "base/memory/ptr_util.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h"
@@ -37,24 +38,25 @@ void SharedUserScriptMaster::OnExtensionUnloaded(
const UserScriptList& script_list =
ContentScriptsInfo::GetContentScripts(extension);
std::set<UserScriptIDPair> scripts_to_remove;
- for (const UserScript& script : script_list)
- scripts_to_remove.insert(UserScriptIDPair(script.id(), script.host_id()));
+ for (const std::unique_ptr<UserScript>& script : script_list)
+ scripts_to_remove.insert(UserScriptIDPair(script->id(), script->host_id()));
loader_.RemoveScripts(scripts_to_remove);
}
-const std::vector<UserScript> SharedUserScriptMaster::GetScriptsMetadata(
+std::unique_ptr<UserScriptList> SharedUserScriptMaster::GetScriptsMetadata(
const Extension* extension) {
bool incognito_enabled = util::IsIncognitoEnabled(extension->id(), profile_);
const UserScriptList& script_list =
ContentScriptsInfo::GetContentScripts(extension);
- std::vector<UserScript> scripts;
- scripts.reserve(script_list.size());
- for (const UserScript& script : script_list) {
- scripts.push_back(UserScript(script));
- scripts.back().set_incognito_enabled(incognito_enabled);
+ std::unique_ptr<UserScriptList> script_vector(new UserScriptList());
+ script_vector->reserve(script_list.size());
+ for (const std::unique_ptr<UserScript>& script : script_list) {
+ std::unique_ptr<UserScript> script_copy =
+ UserScript::CopyMetadataFrom(*script);
+ script_copy->set_incognito_enabled(incognito_enabled);
+ script_vector->push_back(std::move(script_copy));
}
-
- return scripts;
+ return script_vector;
}
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/shared_user_script_master.h ('k') | chrome/browser/extensions/user_script_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698