| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_ | 6 #define CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } | 145 } |
| 146 void add_exclude_glob(const std::string& glob) { | 146 void add_exclude_glob(const std::string& glob) { |
| 147 exclude_globs_.push_back(glob); | 147 exclude_globs_.push_back(glob); |
| 148 } | 148 } |
| 149 void clear_exclude_globs() { exclude_globs_.clear(); } | 149 void clear_exclude_globs() { exclude_globs_.clear(); } |
| 150 | 150 |
| 151 // The URLPatterns, if any, that determine which pages this script runs | 151 // The URLPatterns, if any, that determine which pages this script runs |
| 152 // against. | 152 // against. |
| 153 const PatternList& url_patterns() const { return url_patterns_; } | 153 const PatternList& url_patterns() const { return url_patterns_; } |
| 154 void add_url_pattern(const URLPattern& pattern); | 154 void add_url_pattern(const URLPattern& pattern); |
| 155 void clear_url_patterns(); | |
| 156 | 155 |
| 157 // List of js scripts for this user script | 156 // List of js scripts for this user script |
| 158 FileList& js_scripts() { return js_scripts_; } | 157 FileList& js_scripts() { return js_scripts_; } |
| 159 const FileList& js_scripts() const { return js_scripts_; } | 158 const FileList& js_scripts() const { return js_scripts_; } |
| 160 | 159 |
| 161 // List of css scripts for this user script | 160 // List of css scripts for this user script |
| 162 FileList& css_scripts() { return css_scripts_; } | 161 FileList& css_scripts() { return css_scripts_; } |
| 163 const FileList& css_scripts() const { return css_scripts_; } | 162 const FileList& css_scripts() const { return css_scripts_; } |
| 164 | 163 |
| 165 const std::string& extension_id() const { return extension_id_; } | 164 const std::string& extension_id() const { return extension_id_; } |
| 166 void set_extension_id(const std::string& id) { extension_id_ = id; } | 165 void set_extension_id(const std::string& id) { extension_id_ = id; } |
| 167 | 166 |
| 168 bool is_incognito_enabled() const { return incognito_enabled_; } | 167 bool is_incognito_enabled() const { return incognito_enabled_; } |
| 169 void set_incognito_enabled(bool enabled) { incognito_enabled_ = enabled; } | 168 void set_incognito_enabled(bool enabled) { incognito_enabled_ = enabled; } |
| 170 | 169 |
| 171 bool allow_file_access() const { return allow_file_access_; } | |
| 172 void set_allow_file_access(bool allowed) { allow_file_access_ = allowed; } | |
| 173 | |
| 174 bool is_standalone() const { return extension_id_.empty(); } | 170 bool is_standalone() const { return extension_id_.empty(); } |
| 175 | 171 |
| 176 // Returns true if the script should be applied to the specified URL, false | 172 // Returns true if the script should be applied to the specified URL, false |
| 177 // otherwise. | 173 // otherwise. |
| 178 bool MatchesUrl(const GURL& url) const; | 174 bool MatchesUrl(const GURL& url) const; |
| 179 | 175 |
| 180 // Serialize the UserScript into a pickle. The content of the scripts and | 176 // Serialize the UserScript into a pickle. The content of the scripts and |
| 181 // paths to UserScript::Files will not be serialized! | 177 // paths to UserScript::Files will not be serialized! |
| 182 void Pickle(::Pickle* pickle) const; | 178 void Pickle(::Pickle* pickle) const; |
| 183 | 179 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 // Whether we should try to emulate Greasemonkey's APIs when running this | 222 // Whether we should try to emulate Greasemonkey's APIs when running this |
| 227 // script. | 223 // script. |
| 228 bool emulate_greasemonkey_; | 224 bool emulate_greasemonkey_; |
| 229 | 225 |
| 230 // Whether the user script should run in all frames, or only just the top one. | 226 // Whether the user script should run in all frames, or only just the top one. |
| 231 // Defaults to false. | 227 // Defaults to false. |
| 232 bool match_all_frames_; | 228 bool match_all_frames_; |
| 233 | 229 |
| 234 // True if the script should be injected into an incognito tab. | 230 // True if the script should be injected into an incognito tab. |
| 235 bool incognito_enabled_; | 231 bool incognito_enabled_; |
| 236 | |
| 237 // True if the user agreed to allow this script access to file URLs. | |
| 238 bool allow_file_access_; | |
| 239 }; | 232 }; |
| 240 | 233 |
| 241 typedef std::vector<UserScript> UserScriptList; | 234 typedef std::vector<UserScript> UserScriptList; |
| 242 | 235 |
| 243 #endif // CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_ | 236 #endif // CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_ |
| OLD | NEW |