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

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

Issue 267051: Minimize dependency of user scripts.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 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 17 matching lines...) Expand all
28 // anything else happens. 28 // anything else happens.
29 DOCUMENT_END, // After the entire document is parsed. Same as 29 DOCUMENT_END, // After the entire document is parsed. Same as
30 // DOMContentLoaded. 30 // DOMContentLoaded.
31 31
32 RUN_LOCATION_LAST // Leave this as the last item. 32 RUN_LOCATION_LAST // Leave this as the last item.
33 }; 33 };
34 34
35 // Holds actual script file info. 35 // Holds actual script file info.
36 class File { 36 class File {
37 public: 37 public:
38 File(const ExtensionResource& resource, const GURL& url): 38 File(const FilePath& extension_root, const FilePath& relative_path,
39 resource_(resource), 39 const GURL& url):
40 url_(url) { 40 extension_root_(extension_root),
41 relative_path_(relative_path),
42 url_(url) {
41 } 43 }
42 File() {} 44 File() {}
43 45
44 const ExtensionResource& resource() const { return resource_; } 46 const FilePath& extension_root() const { return extension_root_; }
45 void set_resource(const ExtensionResource& resource) { 47 const FilePath& relative_path() const { return relative_path_; }
46 resource_ = resource;
47 }
48 48
49 const GURL& url() const { return url_; } 49 const GURL& url() const { return url_; }
50 void set_url(const GURL& url) { url_ = url; } 50 void set_url(const GURL& url) { url_ = url; }
51 51
52 // If external_content_ is set returns it as content otherwise it returns 52 // If external_content_ is set returns it as content otherwise it returns
53 // content_ 53 // content_
54 const base::StringPiece GetContent() const { 54 const base::StringPiece GetContent() const {
55 if (external_content_.data()) 55 if (external_content_.data())
56 return external_content_; 56 return external_content_;
57 else 57 else
58 return content_; 58 return content_;
59 } 59 }
60 void set_external_content(const base::StringPiece& content) { 60 void set_external_content(const base::StringPiece& content) {
61 external_content_ = content; 61 external_content_ = content;
62 } 62 }
63 const void set_content(const base::StringPiece& content) { 63 const void set_content(const base::StringPiece& content) {
64 content_.assign(content.begin(), content.end()); 64 content_.assign(content.begin(), content.end());
65 } 65 }
66 66
67 // Serialization support. The content and resource_ member will not be 67 // Serialization support. The content and FilePath members will not be
68 // serialized! 68 // serialized!
69 void Pickle(::Pickle* pickle) const; 69 void Pickle(::Pickle* pickle) const;
70 void Unpickle(const ::Pickle& pickle, void** iter); 70 void Unpickle(const ::Pickle& pickle, void** iter);
71 71
72 private: 72 private:
73 // Where the script file lives on the disk. 73 // Where the script file lives on the disk. We keep the path split so that
74 ExtensionResource resource_; 74 // it can be localized at will.
75 FilePath extension_root_;
76 FilePath relative_path_;
75 77
76 // The url to this scipt file. 78 // The url to this scipt file.
77 GURL url_; 79 GURL url_;
78 80
79 // The script content. It can be set to either loaded_content_ or 81 // The script content. It can be set to either loaded_content_ or
80 // externally allocated string. 82 // externally allocated string.
81 base::StringPiece external_content_; 83 base::StringPiece external_content_;
82 84
83 // Set when the content is loaded by LoadContent 85 // Set when the content is loaded by LoadContent
84 std::string content_; 86 std::string content_;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 FileList css_scripts_; 155 FileList css_scripts_;
154 156
155 // The ID of the extension this script is a part of, if any. Can be empty if 157 // The ID of the extension this script is a part of, if any. Can be empty if
156 // the script is a "standlone" user script. 158 // the script is a "standlone" user script.
157 std::string extension_id_; 159 std::string extension_id_;
158 }; 160 };
159 161
160 typedef std::vector<UserScript> UserScriptList; 162 typedef std::vector<UserScript> UserScriptList;
161 163
162 #endif // CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_ 164 #endif // CHROME_COMMON_EXTENSIONS_USER_SCRIPT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698