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

Side by Side Diff: chrome/browser/extensions/extension.h

Issue 39285: Support loading extensions into the bookmark toolbar. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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
« no previous file with comments | « no previous file | chrome/browser/extensions/extension.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_BROWSER_EXTENSIONS_EXTENSION_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 24 matching lines...) Expand all
35 static const wchar_t* kFormatVersionKey; 35 static const wchar_t* kFormatVersionKey;
36 static const wchar_t* kIdKey; 36 static const wchar_t* kIdKey;
37 static const wchar_t* kJsKey; 37 static const wchar_t* kJsKey;
38 static const wchar_t* kMatchesKey; 38 static const wchar_t* kMatchesKey;
39 static const wchar_t* kNameKey; 39 static const wchar_t* kNameKey;
40 static const wchar_t* kRunAtKey; 40 static const wchar_t* kRunAtKey;
41 static const wchar_t* kVersionKey; 41 static const wchar_t* kVersionKey;
42 static const wchar_t* kZipHashKey; 42 static const wchar_t* kZipHashKey;
43 static const wchar_t* kPluginsDirKey; 43 static const wchar_t* kPluginsDirKey;
44 static const wchar_t* kThemeKey; 44 static const wchar_t* kThemeKey;
45 static const wchar_t* kToolstripKey;
45 46
46 // Some values expected in manifests. 47 // Some values expected in manifests.
47 static const char* kRunAtDocumentStartValue; 48 static const char* kRunAtDocumentStartValue;
48 static const char* kRunAtDocumentEndValue; 49 static const char* kRunAtDocumentEndValue;
49 50
50 // Error messages returned from InitFromValue(). 51 // Error messages returned from InitFromValue().
51 static const char* kInvalidContentScriptError; 52 static const char* kInvalidContentScriptError;
52 static const char* kInvalidContentScriptsListError; 53 static const char* kInvalidContentScriptsListError;
53 static const char* kInvalidDescriptionError; 54 static const char* kInvalidDescriptionError;
54 static const char* kInvalidFormatVersionError; 55 static const char* kInvalidFormatVersionError;
55 static const char* kInvalidIdError; 56 static const char* kInvalidIdError;
56 static const char* kInvalidJsCountError; 57 static const char* kInvalidJsCountError;
57 static const char* kInvalidJsError; 58 static const char* kInvalidJsError;
58 static const char* kInvalidJsListError; 59 static const char* kInvalidJsListError;
59 static const char* kInvalidManifestError; 60 static const char* kInvalidManifestError;
60 static const char* kInvalidMatchCountError; 61 static const char* kInvalidMatchCountError;
61 static const char* kInvalidMatchError; 62 static const char* kInvalidMatchError;
62 static const char* kInvalidMatchesError; 63 static const char* kInvalidMatchesError;
63 static const char* kInvalidNameError; 64 static const char* kInvalidNameError;
64 static const char* kInvalidRunAtError; 65 static const char* kInvalidRunAtError;
65 static const char* kInvalidVersionError; 66 static const char* kInvalidVersionError;
66 static const char* kInvalidZipHashError; 67 static const char* kInvalidZipHashError;
67 static const char* kInvalidPluginsDirError; 68 static const char* kInvalidPluginsDirError;
69 static const char* kInvalidToolstripError;
68 70
69 // The number of bytes in a legal id. 71 // The number of bytes in a legal id.
70 static const size_t kIdSize; 72 static const size_t kIdSize;
71 73
72 // Returns an absolute url to a resource inside of an extension. The 74 // Returns an absolute url to a resource inside of an extension. The
73 // |extension_url| argument should be the url() from an Extension object. The 75 // |extension_url| argument should be the url() from an Extension object. The
74 // |relative_path| can be untrusted user input. The returned URL will either 76 // |relative_path| can be untrusted user input. The returned URL will either
75 // be invalid() or a child of |extension_url|. 77 // be invalid() or a child of |extension_url|.
76 // NOTE: Static so that it can be used from multiple threads. 78 // NOTE: Static so that it can be used from multiple threads.
77 static GURL GetResourceURL(const GURL& extension_url, 79 static GURL GetResourceURL(const GURL& extension_url,
78 const std::string& relative_path); 80 const std::string& relative_path);
79 81
80 // Returns an absolute path to a resource inside of an extension. The 82 // Returns an absolute path to a resource inside of an extension. The
81 // |extension_path| argument should be the path() from an Extension object. 83 // |extension_path| argument should be the path() from an Extension object.
82 // The |relative_path| can be untrusted user input. The returned path will 84 // The |relative_path| can be untrusted user input. The returned path will
83 // either be empty or a child of extension_path. 85 // either be empty or a child of extension_path.
84 // NOTE: Static so that it can be used from multiple threads. 86 // NOTE: Static so that it can be used from multiple threads.
85 static FilePath GetResourcePath(const FilePath& extension_path, 87 static FilePath GetResourcePath(const FilePath& extension_path,
86 const std::string& relative_path); 88 const std::string& relative_path);
87 89
90 // Initialize the extension from a parsed manifest.
91 bool InitFromValue(const DictionaryValue& value, std::string* error);
92
88 // Returns an absolute path to a resource inside of an extension if the 93 // Returns an absolute path to a resource inside of an extension if the
89 // extension has a theme defined with the given |resource_id|. Otherwise 94 // extension has a theme defined with the given |resource_id|. Otherwise
90 // the path will be empty. Note that this method is not static as it is 95 // the path will be empty. Note that this method is not static as it is
91 // only intended to be called on an extension which has registered itself 96 // only intended to be called on an extension which has registered itself
92 // as providing a theme. 97 // as providing a theme.
93 FilePath GetThemeResourcePath(const int resource_id); 98 FilePath GetThemeResourcePath(const int resource_id);
94 99
95 // The path to the folder the extension is stored in.
96 const FilePath& path() const { return path_; } 100 const FilePath& path() const { return path_; }
101 const GURL& url() const { return extension_url_; }
102 const std::string& id() const { return id_; }
103 const Version* version() const { return version_.get(); }
104 // String representation of the version number.
105 const std::string VersionString() const;
106 const std::string& name() const { return name_; }
107 const std::string& description() const { return description_; }
108 const UserScriptList& content_scripts() const { return content_scripts_; }
109 const FilePath& plugins_dir() const { return plugins_dir_; }
110 const GURL& toolstrip_url() const { return toolstrip_url_; }
97 111
98 // The base URL for the extension. 112 private:
99 const GURL& url() const { return extension_url_; } 113 // The absolute path to the directory the extension is stored in.
114 FilePath path_;
115
116 // The base extension url for the extension.
117 GURL extension_url_;
100 118
101 // A human-readable ID for the extension. The convention is to use something 119 // A human-readable ID for the extension. The convention is to use something
102 // like 'com.example.myextension', but this is not currently enforced. An 120 // like 'com.example.myextension', but this is not currently enforced. An
103 // extension's ID is used in things like directory structures and URLs, and 121 // extension's ID is used in things like directory structures and URLs, and
104 // is expected to not change across versions. In the case of conflicts, 122 // is expected to not change across versions. In the case of conflicts,
105 // updates will only be allowed if the extension can be validated using the 123 // updates will only be allowed if the extension can be validated using the
106 // previous version's update key. 124 // previous version's update key.
107 const std::string& id() const { return id_; }
108
109 // The version number for the extension.
110 const Version* version() const { return version_.get(); }
111
112 // String representation of the version number.
113 const std::string VersionString() const;
114
115 // A human-readable name of the extension.
116 const std::string& name() const { return name_; }
117
118 // An optional longer description of the extension.
119 const std::string& description() const { return description_; }
120
121 // Paths to the content scripts that the extension contains.
122 const UserScriptList& content_scripts() const {
123 return content_scripts_;
124 }
125
126 // Path to the directory of NPAPI plugins that the extension contains.
127 const FilePath& plugins_dir() const {
128 return plugins_dir_;
129 }
130
131 // Initialize the extension from a parsed manifest.
132 bool InitFromValue(const DictionaryValue& value, std::string* error);
133
134 private:
135 // The path to the directory the extension is stored in.
136 FilePath path_;
137
138 // The base extension url for the extension.
139 GURL extension_url_;
140
141 // The extension's ID.
142 std::string id_; 125 std::string id_;
143 126
144 // The extension's version. 127 // The extension's version.
145 scoped_ptr<Version> version_; 128 scoped_ptr<Version> version_;
146 129
147 // The extension's human-readable name. 130 // The extension's human-readable name.
148 std::string name_; 131 std::string name_;
149 132
150 // An optional description for the extension. 133 // An optional longer description of the extension.
151 std::string description_; 134 std::string description_;
152 135
153 // Paths to the content scripts the extension contains. 136 // Paths to the content scripts the extension contains.
154 UserScriptList content_scripts_; 137 UserScriptList content_scripts_;
155 138
156 // Path to the directory of NPAPI plugins that the extension contains. 139 // Optional absolute path to the directory of NPAPI plugins that the extension
140 // contains.
157 FilePath plugins_dir_; 141 FilePath plugins_dir_;
158 142
143 // Optional URL of an HTML file to be displayed in the toolbar.
144 GURL toolstrip_url_;
145
159 // A SHA1 hash of the contents of the zip file. Note that this key is only 146 // A SHA1 hash of the contents of the zip file. Note that this key is only
160 // present in the manifest that's prepended to the zip. The inner manifest 147 // present in the manifest that's prepended to the zip. The inner manifest
161 // will not have this key. 148 // will not have this key.
162 std::string zip_hash_; 149 std::string zip_hash_;
163 150
164 // A map of resource id's to relative file paths. 151 // A map of resource id's to relative file paths.
165 std::map<const std::wstring, std::string> theme_paths_; 152 std::map<const std::wstring, std::string> theme_paths_;
166 153
167 // We implement copy, but not assign. 154 // We implement copy, but not assign.
168 void operator=(const Extension&); 155 void operator=(const Extension&);
169 }; 156 };
170 157
171 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_H_ 158 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698