OLD | NEW |
1 // Copyright (c) 2011 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> |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 void set_external_content(const base::StringPiece& content) { | 75 void set_external_content(const base::StringPiece& content) { |
76 external_content_ = content; | 76 external_content_ = content; |
77 } | 77 } |
78 void set_content(const base::StringPiece& content) { | 78 void set_content(const base::StringPiece& content) { |
79 content_.assign(content.begin(), content.end()); | 79 content_.assign(content.begin(), content.end()); |
80 } | 80 } |
81 | 81 |
82 // Serialization support. The content and FilePath members will not be | 82 // Serialization support. The content and FilePath members will not be |
83 // serialized! | 83 // serialized! |
84 void Pickle(::Pickle* pickle) const; | 84 void Pickle(::Pickle* pickle) const; |
85 void Unpickle(const ::Pickle& pickle, void** iter); | 85 void Unpickle(const ::Pickle& pickle, PickleReader* iter); |
86 | 86 |
87 private: | 87 private: |
88 // Where the script file lives on the disk. We keep the path split so that | 88 // Where the script file lives on the disk. We keep the path split so that |
89 // it can be localized at will. | 89 // it can be localized at will. |
90 FilePath extension_root_; | 90 FilePath extension_root_; |
91 FilePath relative_path_; | 91 FilePath relative_path_; |
92 | 92 |
93 // The url to this scipt file. | 93 // The url to this scipt file. |
94 GURL url_; | 94 GURL url_; |
95 | 95 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // otherwise. | 180 // otherwise. |
181 bool MatchesURL(const GURL& url) const; | 181 bool MatchesURL(const GURL& url) const; |
182 | 182 |
183 // Serialize the UserScript into a pickle. The content of the scripts and | 183 // Serialize the UserScript into a pickle. The content of the scripts and |
184 // paths to UserScript::Files will not be serialized! | 184 // paths to UserScript::Files will not be serialized! |
185 void Pickle(::Pickle* pickle) const; | 185 void Pickle(::Pickle* pickle) const; |
186 | 186 |
187 // Deserialize the script from a pickle. Note that this always succeeds | 187 // Deserialize the script from a pickle. Note that this always succeeds |
188 // because presumably we were the one that pickled it, and we did it | 188 // because presumably we were the one that pickled it, and we did it |
189 // correctly. | 189 // correctly. |
190 void Unpickle(const ::Pickle& pickle, void** iter); | 190 void Unpickle(const ::Pickle& pickle, PickleReader* iter); |
191 | 191 |
192 private: | 192 private: |
193 // Pickle helper functions used to pickle the individual types of components. | 193 // Pickle helper functions used to pickle the individual types of components. |
194 void PickleGlobs(::Pickle* pickle, | 194 void PickleGlobs(::Pickle* pickle, |
195 const std::vector<std::string>& globs) const; | 195 const std::vector<std::string>& globs) const; |
196 void PickleURLPatternSet(::Pickle* pickle, | 196 void PickleURLPatternSet(::Pickle* pickle, |
197 const URLPatternSet& pattern_list) const; | 197 const URLPatternSet& pattern_list) const; |
198 void PickleScripts(::Pickle* pickle, const FileList& scripts) const; | 198 void PickleScripts(::Pickle* pickle, const FileList& scripts) const; |
199 | 199 |
200 // Unpickle helper functions used to unpickle individual types of components. | 200 // Unpickle helper functions used to unpickle individual types of components. |
201 void UnpickleGlobs(const ::Pickle& pickle, void** iter, | 201 void UnpickleGlobs(const ::Pickle& pickle, PickleReader* iter, |
202 std::vector<std::string>* globs); | 202 std::vector<std::string>* globs); |
203 void UnpickleURLPatternSet(const ::Pickle& pickle, void** iter, | 203 void UnpickleURLPatternSet(const ::Pickle& pickle, PickleReader* iter, |
204 URLPatternSet* pattern_list); | 204 URLPatternSet* pattern_list); |
205 void UnpickleScripts(const ::Pickle& pickle, void** iter, | 205 void UnpickleScripts(const ::Pickle& pickle, PickleReader* iter, |
206 FileList* scripts); | 206 FileList* scripts); |
207 | 207 |
208 // The location to run the script inside the document. | 208 // The location to run the script inside the document. |
209 RunLocation run_location_; | 209 RunLocation run_location_; |
210 | 210 |
211 // The namespace of the script. This is used by Greasemonkey in the same way | 211 // The namespace of the script. This is used by Greasemonkey in the same way |
212 // as XML namespaces. Only used when parsing Greasemonkey-style scripts. | 212 // as XML namespaces. Only used when parsing Greasemonkey-style scripts. |
213 std::string name_space_; | 213 std::string name_space_; |
214 | 214 |
215 // The script's name. Only used when parsing Greasemonkey-style scripts. | 215 // The script's name. Only used when parsing Greasemonkey-style scripts. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 // Defaults to false. | 250 // Defaults to false. |
251 bool match_all_frames_; | 251 bool match_all_frames_; |
252 | 252 |
253 // True if the script should be injected into an incognito tab. | 253 // True if the script should be injected into an incognito tab. |
254 bool incognito_enabled_; | 254 bool incognito_enabled_; |
255 }; | 255 }; |
256 | 256 |
257 typedef std::vector<UserScript> UserScriptList; | 257 typedef std::vector<UserScript> UserScriptList; |
258 | 258 |
259 #endif // CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_ | 259 #endif // CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_ |
OLD | NEW |