Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1538)

Side by Side Diff: chrome/common/extensions/user_script.h

Issue 12792005: Allow extensions on chrome:// URLs, when flag is set and permission is explicitly requested (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reinstate original pickle order; add scripts clause to content_script_chrome_url_invalid.json to av… Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.
30 enum {
31 kValidUserScriptSchemes = URLPattern::SCHEME_HTTP |
32 URLPattern::SCHEME_HTTPS |
33 URLPattern::SCHEME_FILE |
34 URLPattern::SCHEME_FTP
35 };
36
37 // Check if a URL should be treated as a user script and converted to an 29 // Check if a URL should be treated as a user script and converted to an
38 // extension. 30 // extension.
39 static bool IsURLUserScript(const GURL& url, const std::string& mime_type); 31 static bool IsURLUserScript(const GURL& url, const std::string& mime_type);
40 32
33 // Get the valid user script schemes for the current process. If
34 // canExecuteScriptEverywhere is true, this will return ALL_SCHEMES.
35 static int ValidUserScriptSchemes(bool canExecuteScriptEverywhere = false);
36
41 // Locations that user scripts can be run inside the document. 37 // Locations that user scripts can be run inside the document.
42 enum RunLocation { 38 enum RunLocation {
43 UNDEFINED, 39 UNDEFINED,
44 DOCUMENT_START, // After the documentElemnet is created, but before 40 DOCUMENT_START, // After the documentElemnet is created, but before
45 // anything else happens. 41 // anything else happens.
46 DOCUMENT_END, // After the entire document is parsed. Same as 42 DOCUMENT_END, // After the entire document is parsed. Same as
47 // DOMContentLoaded. 43 // DOMContentLoaded.
48 DOCUMENT_IDLE, // Sometime after DOMContentLoaded, as soon as the document 44 DOCUMENT_IDLE, // Sometime after DOMContentLoaded, as soon as the document
49 // is "idle". Currently this uses the simple heuristic of: 45 // is "idle". Currently this uses the simple heuristic of:
50 // min(DOM_CONTENT_LOADED + TIMEOUT, ONLOAD), but no 46 // min(DOM_CONTENT_LOADED + TIMEOUT, ONLOAD), but no
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 251
256 // True if the script should be injected into an incognito tab. 252 // True if the script should be injected into an incognito tab.
257 bool incognito_enabled_; 253 bool incognito_enabled_;
258 }; 254 };
259 255
260 typedef std::vector<UserScript> UserScriptList; 256 typedef std::vector<UserScript> UserScriptList;
261 257
262 } // namespace extensions 258 } // namespace extensions
263 259
264 #endif // CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_ 260 #endif // CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698