OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/string_piece.h" | 12 #include "base/string_piece.h" |
13 #include "extensions/common/url_pattern.h" | 13 #include "extensions/common/url_pattern.h" |
14 #include "extensions/common/url_pattern_set.h" | 14 #include "extensions/common/url_pattern_set.h" |
15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
16 | 16 |
17 class Pickle; | 17 class Pickle; |
18 class PickleIterator; | 18 class PickleIterator; |
19 | 19 |
20 namespace extensions { | 20 namespace extensions { |
21 | 21 |
22 // Represents a user script, either a standalone one, or one that is part of an | 22 // Represents a user script, either a standalone one, or one that is part of an |
23 // extension. | 23 // extension. |
24 class UserScript { | 24 class UserScript { |
25 public: | 25 public: |
26 // The file extension for standalone user scripts. | 26 // The file extension for standalone user scripts. |
27 static const char kFileExtension[]; | 27 static const char kFileExtension[]; |
28 | 28 |
29 // The bitmask for valid user script injectable schemes used by URLPattern. | 29 // The bitmask for valid user script injectable schemes used by URLPattern. |
30 enum { | 30 enum { |
Matt Perry
2013/03/19 17:49:32
Move this into the .cc file so no one accidentally
aboxhall
2013/03/20 22:04:59
Done.
| |
31 kValidUserScriptSchemes = URLPattern::SCHEME_HTTP | | 31 kValidUserScriptSchemes = URLPattern::SCHEME_CHROMEUI | |
32 URLPattern::SCHEME_HTTP | | |
32 URLPattern::SCHEME_HTTPS | | 33 URLPattern::SCHEME_HTTPS | |
33 URLPattern::SCHEME_FILE | | 34 URLPattern::SCHEME_FILE | |
34 URLPattern::SCHEME_FTP | 35 URLPattern::SCHEME_FTP |
35 }; | 36 }; |
36 | 37 |
37 // Check if a URL should be treated as a user script and converted to an | 38 // Check if a URL should be treated as a user script and converted to an |
38 // extension. | 39 // extension. |
39 static bool IsURLUserScript(const GURL& url, const std::string& mime_type); | 40 static bool IsURLUserScript(const GURL& url, const std::string& mime_type); |
40 | 41 |
42 static int ValidUserScriptSchemes(bool canExecuteScriptEverywhere); | |
Matt Perry
2013/03/19 17:49:32
Comment this.
aboxhall
2013/03/20 22:04:59
Done.
| |
43 | |
41 // Locations that user scripts can be run inside the document. | 44 // Locations that user scripts can be run inside the document. |
42 enum RunLocation { | 45 enum RunLocation { |
43 UNDEFINED, | 46 UNDEFINED, |
44 DOCUMENT_START, // After the documentElemnet is created, but before | 47 DOCUMENT_START, // After the documentElemnet is created, but before |
45 // anything else happens. | 48 // anything else happens. |
46 DOCUMENT_END, // After the entire document is parsed. Same as | 49 DOCUMENT_END, // After the entire document is parsed. Same as |
47 // DOMContentLoaded. | 50 // DOMContentLoaded. |
48 DOCUMENT_IDLE, // Sometime after DOMContentLoaded, as soon as the document | 51 DOCUMENT_IDLE, // Sometime after DOMContentLoaded, as soon as the document |
49 // is "idle". Currently this uses the simple heuristic of: | 52 // is "idle". Currently this uses the simple heuristic of: |
50 // min(DOM_CONTENT_LOADED + TIMEOUT, ONLOAD), but no | 53 // min(DOM_CONTENT_LOADED + TIMEOUT, ONLOAD), but no |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 | 258 |
256 // True if the script should be injected into an incognito tab. | 259 // True if the script should be injected into an incognito tab. |
257 bool incognito_enabled_; | 260 bool incognito_enabled_; |
258 }; | 261 }; |
259 | 262 |
260 typedef std::vector<UserScript> UserScriptList; | 263 typedef std::vector<UserScript> UserScriptList; |
261 | 264 |
262 } // namespace extensions | 265 } // namespace extensions |
263 | 266 |
264 #endif // CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_ | 267 #endif // CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_ |
OLD | NEW |