Index: chrome/common/extensions/user_script.h |
diff --git a/chrome/common/extensions/user_script.h b/chrome/common/extensions/user_script.h |
index 28b3aaec1928117c1bcda7f21f49eb41a688ddf0..6180b679f225680c20d8fc9019f7cb5757461340 100644 |
--- a/chrome/common/extensions/user_script.h |
+++ b/chrome/common/extensions/user_script.h |
@@ -22,6 +22,13 @@ class UserScript { |
public: |
typedef std::vector<URLPattern> PatternList; |
+ // The file extension for standalone user scripts. |
+ static const char kFileExtension[]; |
+ |
+ // Check if a file or URL has the user script file extension. |
+ static bool HasUserScriptFileExtension(const GURL& url); |
+ static bool HasUserScriptFileExtension(const FilePath& path); |
+ |
// Locations that user scripts can be run inside the document. |
enum RunLocation { |
DOCUMENT_START, // After the documentElemnet is created, but before |
@@ -90,17 +97,43 @@ class UserScript { |
// Constructor. Default the run location to document end, which is like |
// Greasemonkey and probably more useful for typical scripts. |
- UserScript() : run_location_(DOCUMENT_END) {} |
+ UserScript() |
+ : run_location_(DOCUMENT_END), emulate_greasemonkey_(false) { |
+ } |
+ |
+ const std::string& name_space() const { return name_space_; } |
+ void set_name_space(const std::string& name_space) { |
+ name_space_ = name_space; |
+ } |
+ |
+ const std::string& name() const { return name_; } |
+ void set_name(const std::string& name) { name_ = name; } |
+ |
+ const std::string& description() const { return description_; } |
+ void set_description(const std::string& description) { |
+ description_ = description; |
+ } |
// The place in the document to run the script. |
RunLocation run_location() const { return run_location_; } |
void set_run_location(RunLocation location) { run_location_ = location; } |
+ // Whether to emulate greasemonkey when running this script. |
+ bool emulate_greasemonkey() const { return emulate_greasemonkey_; } |
+ void set_emulate_greasemonkey(bool val) { emulate_greasemonkey_ = val; } |
+ |
// The globs, if any, that determine which pages this script runs against. |
// These are only used with "standalone" Greasemonkey-like user scripts. |
const std::vector<std::string>& globs() const { return globs_; } |
void add_glob(const std::string& glob) { globs_.push_back(glob); } |
void clear_globs() { globs_.clear(); } |
+ const std::vector<std::string>& exclude_globs() const { |
+ return exclude_globs_; |
+ } |
+ void add_exclude_glob(const std::string& glob) { |
+ exclude_globs_.push_back(glob); |
+ } |
+ void clear_exclude_globs() { exclude_globs_.clear(); } |
// The URLPatterns, if any, that determine which pages this script runs |
// against. |
@@ -140,9 +173,20 @@ class UserScript { |
// The location to run the script inside the document. |
RunLocation run_location_; |
+ // The namespace of the script. This is used by Greasemonkey in the same way |
+ // as XML namespaces. Only used when parsing Greasemonkey-style scripts. |
+ std::string name_space_; |
+ |
+ // The script's name. Only used when parsing Greasemonkey-style scripts. |
+ std::string name_; |
+ |
+ // A longer description. Only used when parsing Greasemonkey-style scripts. |
+ std::string description_; |
+ |
// Greasemonkey-style globs that determine pages to inject the script into. |
// These are only used with standalone scripts. |
std::vector<std::string> globs_; |
+ std::vector<std::string> exclude_globs_; |
// URLPatterns that determine pages to inject the script into. These are |
// only used with scripts that are part of extensions. |
@@ -157,6 +201,10 @@ class UserScript { |
// The ID of the extension this script is a part of, if any. Can be empty if |
// the script is a "standlone" user script. |
std::string extension_id_; |
+ |
+ // Whether we should try to emulate Greasemonkey's APIs when running this |
+ // script. |
+ bool emulate_greasemonkey_; |
}; |
typedef std::vector<UserScript> UserScriptList; |