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

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: remove browser/renderer specific file impl as it is not helping much 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/common/user_script.h
diff --git a/extensions/common/user_script.h b/extensions/common/user_script.h
index 44a2d671f08e914bdecbae317562438fe37477e4..f919e1d4c208e334a80c8f716c60658e39a04f53 100644
--- a/extensions/common/user_script.h
+++ b/extensions/common/user_script.h
@@ -24,6 +24,10 @@ namespace extensions {
// Represents a user script, either a standalone one, or one that is part of an
// extension.
+// Contains information related to user scripts, either a standalone one, or one
+// that is part of an extension.
+// This class also contains script file (JS/CSS) related information, but not
+// their file contents.
Devlin 2016/08/17 16:39:31 outdated, right?
lazyboy 2016/08/17 18:55:52 Yes, fixed.
class UserScript {
public:
// The file extension for standalone user scripts.
@@ -73,7 +77,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 +130,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 +138,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.
+ static std::unique_ptr<UserScript> CopyFrom(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;
@@ -224,11 +230,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 +321,9 @@ class UserScript {
// True if the script should be injected into an incognito tab.
bool incognito_enabled_;
+
+ private:
Devlin 2016/08/17 16:39:31 this already is private:, right?
lazyboy 2016/08/17 18:55:52 Done.
+ DISALLOW_COPY_AND_ASSIGN(UserScript);
};
// Information we need while removing scripts from a UserScriptLoader.
@@ -326,12 +335,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

Powered by Google App Engine
This is Rietveld 408576698