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

Unified Diff: extensions/common/user_script.h

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
« no previous file with comments | « extensions/browser/web_ui_user_script_loader.cc ('k') | extensions/common/user_script.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/user_script.h
diff --git a/extensions/common/user_script.h b/extensions/common/user_script.h
index 44a2d671f08e914bdecbae317562438fe37477e4..0573eb662f8b92f3f31da9e00c6a9a926b8181fc 100644
--- a/extensions/common/user_script.h
+++ b/extensions/common/user_script.h
@@ -73,7 +73,7 @@ class UserScript {
RUN_LOCATION_LAST // Leave this as the last item.
};
- // Holds actual script file info.
+ // Holds script file info.
class File {
public:
File(const base::FilePath& extension_root,
@@ -126,7 +126,7 @@ class UserScript {
std::string content_;
};
- typedef std::vector<File> FileList;
+ using FileList = std::vector<std::unique_ptr<File>>;
// Type of a API consumer instance that user scripts will be injected on.
enum ConsumerInstanceType { TAB, WEBVIEW };
@@ -134,9 +134,11 @@ class UserScript {
// Constructor. Default the run location to document end, which is like
// Greasemonkey and probably more useful for typical scripts.
UserScript();
- UserScript(const UserScript& other);
~UserScript();
+ // Peforms a copy of all fields except file contents.
+ static std::unique_ptr<UserScript> CopyMetadataFrom(const UserScript& other);
+
const std::string& name_space() const { return name_space_; }
void set_name_space(const std::string& name_space) {
name_space_ = name_space;
@@ -217,6 +219,9 @@ class UserScript {
int id() const { return user_script_id_; }
void set_id(int id) { user_script_id_ = id; }
+ // TODO(lazyboy): Incognito information is extension specific, it doesn't
+ // belong here. We should be able to determine this in the renderer/ where it
+ // is used.
bool is_incognito_enabled() const { return incognito_enabled_; }
void set_incognito_enabled(bool enabled) { incognito_enabled_ = enabled; }
@@ -224,11 +229,11 @@ class UserScript {
// otherwise.
bool MatchesURL(const GURL& url) const;
- // Serialize the UserScript into a pickle. The content of the scripts and
+ // Serializes the UserScript into a pickle. The content of the scripts and
// paths to UserScript::Files will not be serialized!
void Pickle(base::Pickle* pickle) const;
- // Deserialize the script from a pickle. Note that this always succeeds
+ // Deserializes the script from a pickle. Note that this always succeeds
// because presumably we were the one that pickled it, and we did it
// correctly.
void Unpickle(const base::Pickle& pickle, base::PickleIterator* iter);
@@ -315,6 +320,8 @@ class UserScript {
// True if the script should be injected into an incognito tab.
bool incognito_enabled_;
+
+ DISALLOW_COPY_AND_ASSIGN(UserScript);
};
// Information we need while removing scripts from a UserScriptLoader.
@@ -326,12 +333,9 @@ struct UserScriptIDPair {
HostID host_id;
};
-// For storing UserScripts with unique IDs in sets.
-bool operator<(const UserScript& script1, const UserScript& script2);
-
bool operator<(const UserScriptIDPair& a, const UserScriptIDPair& b);
-typedef std::vector<UserScript> UserScriptList;
+using UserScriptList = std::vector<std::unique_ptr<UserScript>>;
} // namespace extensions
« no previous file with comments | « extensions/browser/web_ui_user_script_loader.cc ('k') | extensions/common/user_script.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698