OLD | NEW |
1 // Copyright 2009 The Chromium Authors. All rights reserved. | 1 // Copyright 2009 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 | 7 |
8 #include <vector> | 8 #include <vector> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // Set when the content is loaded by LoadContent | 95 // Set when the content is loaded by LoadContent |
96 std::string content_; | 96 std::string content_; |
97 }; | 97 }; |
98 | 98 |
99 typedef std::vector<File> FileList; | 99 typedef std::vector<File> FileList; |
100 | 100 |
101 // Constructor. Default the run location to document end, which is like | 101 // Constructor. Default the run location to document end, which is like |
102 // Greasemonkey and probably more useful for typical scripts. | 102 // Greasemonkey and probably more useful for typical scripts. |
103 UserScript() | 103 UserScript() |
104 : run_location_(DOCUMENT_IDLE), emulate_greasemonkey_(false), | 104 : run_location_(DOCUMENT_IDLE), emulate_greasemonkey_(false), |
105 match_all_frames_(false) { | 105 match_all_frames_(false), incognito_enabled_(false) { |
106 } | 106 } |
107 | 107 |
108 const std::string& name_space() const { return name_space_; } | 108 const std::string& name_space() const { return name_space_; } |
109 void set_name_space(const std::string& name_space) { | 109 void set_name_space(const std::string& name_space) { |
110 name_space_ = name_space; | 110 name_space_ = name_space; |
111 } | 111 } |
112 | 112 |
113 const std::string& name() const { return name_; } | 113 const std::string& name() const { return name_; } |
114 void set_name(const std::string& name) { name_ = name; } | 114 void set_name(const std::string& name) { name_ = name; } |
115 | 115 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 FileList& js_scripts() { return js_scripts_; } | 155 FileList& js_scripts() { return js_scripts_; } |
156 const FileList& js_scripts() const { return js_scripts_; } | 156 const FileList& js_scripts() const { return js_scripts_; } |
157 | 157 |
158 // List of css scripts for this user script | 158 // List of css scripts for this user script |
159 FileList& css_scripts() { return css_scripts_; } | 159 FileList& css_scripts() { return css_scripts_; } |
160 const FileList& css_scripts() const { return css_scripts_; } | 160 const FileList& css_scripts() const { return css_scripts_; } |
161 | 161 |
162 const std::string& extension_id() const { return extension_id_; } | 162 const std::string& extension_id() const { return extension_id_; } |
163 void set_extension_id(const std::string& id) { extension_id_ = id; } | 163 void set_extension_id(const std::string& id) { extension_id_ = id; } |
164 | 164 |
| 165 bool is_incognito_enabled() const { return incognito_enabled_; } |
| 166 void set_incognito_enabled(bool enabled) { incognito_enabled_ = enabled; } |
| 167 |
165 bool is_standalone() const { return extension_id_.empty(); } | 168 bool is_standalone() const { return extension_id_.empty(); } |
166 | 169 |
167 // Returns true if the script should be applied to the specified URL, false | 170 // Returns true if the script should be applied to the specified URL, false |
168 // otherwise. | 171 // otherwise. |
169 bool MatchesUrl(const GURL& url) const; | 172 bool MatchesUrl(const GURL& url) const; |
170 | 173 |
171 // Serialize the UserScript into a pickle. The content of the scripts and | 174 // Serialize the UserScript into a pickle. The content of the scripts and |
172 // paths to UserScript::Files will not be serialized! | 175 // paths to UserScript::Files will not be serialized! |
173 void Pickle(::Pickle* pickle) const; | 176 void Pickle(::Pickle* pickle) const; |
174 | 177 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 // the script is a "standlone" user script. | 213 // the script is a "standlone" user script. |
211 std::string extension_id_; | 214 std::string extension_id_; |
212 | 215 |
213 // Whether we should try to emulate Greasemonkey's APIs when running this | 216 // Whether we should try to emulate Greasemonkey's APIs when running this |
214 // script. | 217 // script. |
215 bool emulate_greasemonkey_; | 218 bool emulate_greasemonkey_; |
216 | 219 |
217 // Whether the user script should run in all frames, or only just the top one. | 220 // Whether the user script should run in all frames, or only just the top one. |
218 // Defaults to false. | 221 // Defaults to false. |
219 bool match_all_frames_; | 222 bool match_all_frames_; |
| 223 |
| 224 // True if the script should be injected into an incognito tab. |
| 225 bool incognito_enabled_; |
220 }; | 226 }; |
221 | 227 |
222 typedef std::vector<UserScript> UserScriptList; | 228 typedef std::vector<UserScript> UserScriptList; |
223 | 229 |
224 #endif // CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_ | 230 #endif // CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_ |
OLD | NEW |