OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 EXTENSIONS_COMMON_USER_SCRIPT_H_ | 5 #ifndef EXTENSIONS_COMMON_USER_SCRIPT_H_ |
6 #define EXTENSIONS_COMMON_USER_SCRIPT_H_ | 6 #define EXTENSIONS_COMMON_USER_SCRIPT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 static const char kFileExtension[]; | 28 static const char kFileExtension[]; |
29 | 29 |
30 // Check if a URL should be treated as a user script and converted to an | 30 // Check if a URL should be treated as a user script and converted to an |
31 // extension. | 31 // extension. |
32 static bool IsURLUserScript(const GURL& url, const std::string& mime_type); | 32 static bool IsURLUserScript(const GURL& url, const std::string& mime_type); |
33 | 33 |
34 // Get the valid user script schemes for the current process. If | 34 // Get the valid user script schemes for the current process. If |
35 // canExecuteScriptEverywhere is true, this will return ALL_SCHEMES. | 35 // canExecuteScriptEverywhere is true, this will return ALL_SCHEMES. |
36 static int ValidUserScriptSchemes(bool canExecuteScriptEverywhere = false); | 36 static int ValidUserScriptSchemes(bool canExecuteScriptEverywhere = false); |
37 | 37 |
| 38 // TODO(rdevlin.cronin) This and RunLocataion don't really belong here, since |
| 39 // they are used for more than UserScripts (e.g., tabs.executeScript()). |
| 40 // The type of injected script. |
| 41 enum InjectionType { |
| 42 // A content script specified in the extension's manifest. |
| 43 CONTENT_SCRIPT, |
| 44 // A script injected via, e.g. tabs.executeScript(). |
| 45 PROGRAMMATIC_SCRIPT |
| 46 }; |
| 47 // The last type of injected script; used for enum verification in IPC. |
| 48 // Update this if you add more injected script types! |
| 49 static const InjectionType INJECTION_TYPE_LAST = PROGRAMMATIC_SCRIPT; |
| 50 |
38 // Locations that user scripts can be run inside the document. | 51 // Locations that user scripts can be run inside the document. |
39 enum RunLocation { | 52 enum RunLocation { |
40 UNDEFINED, | 53 UNDEFINED, |
41 DOCUMENT_START, // After the documentElement is created, but before | 54 DOCUMENT_START, // After the documentElement is created, but before |
42 // anything else happens. | 55 // anything else happens. |
43 DOCUMENT_END, // After the entire document is parsed. Same as | 56 DOCUMENT_END, // After the entire document is parsed. Same as |
44 // DOMContentLoaded. | 57 // DOMContentLoaded. |
45 DOCUMENT_IDLE, // Sometime after DOMContentLoaded, as soon as the document | 58 DOCUMENT_IDLE, // Sometime after DOMContentLoaded, as soon as the document |
46 // is "idle". Currently this uses the simple heuristic of: | 59 // is "idle". Currently this uses the simple heuristic of: |
47 // min(DOM_CONTENT_LOADED + TIMEOUT, ONLOAD), but no | 60 // min(DOM_CONTENT_LOADED + TIMEOUT, ONLOAD), but no |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 282 |
270 // True if the script should be injected into an incognito tab. | 283 // True if the script should be injected into an incognito tab. |
271 bool incognito_enabled_; | 284 bool incognito_enabled_; |
272 }; | 285 }; |
273 | 286 |
274 typedef std::vector<UserScript> UserScriptList; | 287 typedef std::vector<UserScript> UserScriptList; |
275 | 288 |
276 } // namespace extensions | 289 } // namespace extensions |
277 | 290 |
278 #endif // EXTENSIONS_COMMON_USER_SCRIPT_H_ | 291 #endif // EXTENSIONS_COMMON_USER_SCRIPT_H_ |
OLD | NEW |