extension_constants.cc revision 4a5e2dc747d50c653511c68ccb2cfbfb740bd5a7
1// Copyright (c) 2010 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/common/extensions/extension_constants.h"
6
7namespace extension_manifest_keys {
8
9const char* kAllFrames = "all_frames";
10const char* kApp = "app";
11const char* kBackground = "background_page";
12const char* kBrowserAction = "browser_action";
13const char* kChromeURLOverrides = "chrome_url_overrides";
14const char* kContentScripts = "content_scripts";
15const char* kConvertedFromUserScript = "converted_from_user_script";
16const char* kCss = "css";
17const char* kCurrentLocale = "current_locale";
18const char* kDefaultLocale = "default_locale";
19const char* kDescription = "description";
20const char* kDevToolsPage = "devtools_page";
21const char* kExcludeGlobs = "exclude_globs";
22const char* kHomepageURL = "homepage_url";
23const char* kIcons = "icons";
24const char* kIncognito = "incognito";
25const char* kIncludeGlobs = "include_globs";
26const char* kJs = "js";
27const char* kLaunch = "app.launch";
28const char* kLaunchContainer = "app.launch.container";
29const char* kLaunchHeight = "app.launch.height";
30const char* kLaunchLocalPath = "app.launch.local_path";
31const char* kLaunchWebURL = "app.launch.web_url";
32const char* kLaunchWidth = "app.launch.width";
33const char* kMatches = "matches";
34const char* kMinimumChromeVersion = "minimum_chrome_version";
35const char* kName = "name";
36const char* kOmnibox = "omnibox";
37const char* kOmniboxKeyword = "omnibox.keyword";
38const char* kOptionsPage = "options_page";
39const char* kPageAction = "page_action";
40const char* kPageActionDefaultIcon = "default_icon";
41const char* kPageActionDefaultPopup = "default_popup";
42const char* kPageActionDefaultTitle = "default_title";
43const char* kPageActionIcons = "icons";
44const char* kPageActionId = "id";
45const char* kPageActionPopup = "popup";
46const char* kPageActionPopupHeight = "height";
47const char* kPageActionPopupPath = "path";
48const char* kPageActions = "page_actions";
49const char* kPermissions = "permissions";
50const char* kPlugins = "plugins";
51const char* kPluginsPath = "path";
52const char* kPluginsPublic = "public";
53const char* kPublicKey = "key";
54const char* kRunAt = "run_at";
55const char* kSignature = "signature";
56const char* kTheme = "theme";
57const char* kThemeColors = "colors";
58const char* kThemeDisplayProperties = "properties";
59const char* kThemeImages = "images";
60const char* kThemeTints = "tints";
61const char* kToolstripPath = "path";
62const char* kToolstrips = "toolstrips";
63const char* kType = "type";
64const char* kUpdateURL = "update_url";
65const char* kVersion = "version";
66const char* kWebURLs = "app.urls";
67}  // namespace extension_manifest_keys
68
69namespace extension_manifest_values {
70const char* kIncognitoSplit = "split";
71const char* kIncognitoSpanning = "spanning";
72const char* kRunAtDocumentStart = "document_start";
73const char* kRunAtDocumentEnd = "document_end";
74const char* kRunAtDocumentIdle = "document_idle";
75const char* kPageActionTypeTab = "tab";
76const char* kPageActionTypePermanent = "permanent";
77const char* kLaunchContainerPanel = "panel";
78const char* kLaunchContainerTab = "tab";
79const char* kLaunchContainerWindow = "window";
80}  // namespace extension_manifest_values
81
82// Extension-related error messages. Some of these are simple patterns, where a
83// '*' is replaced at runtime with a specific value. This is used instead of
84// printf because we want to unit test them and scanf is hard to make
85// cross-platform.
86namespace extension_manifest_errors {
87const char* kAppsNotEnabled =
88    "Apps are not enabled.";
89const char* kCannotAccessPage =
90    "Cannot access contents of url \"*\". "
91    "Extension manifest must request permission to access this host.";
92const char* kCannotScriptGallery =
93    "The extensions gallery cannot be scripted.";
94const char* kChromeVersionTooLow =
95    "This extension requires * version * or greater.";
96const char* kDisabledByPolicy =
97    "This extension has been disabled by your administrator.";
98const char* kDevToolsExperimental =
99    "You must request the 'experimental' permission in order to use the"
100    " DevTools API.";
101const char* kHostedAppsCannotIncludeExtensionFeatures =
102    "Hosted apps cannot use extension features.";
103const char* kInvalidAllFrames =
104    "Invalid value for 'content_scripts[*].all_frames'.";
105const char* kInvalidBackground =
106    "Invalid value for 'background_page'.";
107const char* kInvalidBrowserAction =
108    "Invalid value for 'browser_action'.";
109const char* kInvalidChromeURLOverrides =
110    "Invalid value for 'chrome_url_overrides'.";
111const char* kInvalidContentScript =
112    "Invalid value for 'content_scripts[*]'.";
113const char* kInvalidContentScriptsList =
114    "Invalid value for 'content_scripts'.";
115const char* kInvalidCss =
116    "Invalid value for 'content_scripts[*].css[*]'.";
117const char* kInvalidCssList =
118    "Required value 'content_scripts[*].css' is invalid.";
119const char* kInvalidDefaultLocale =
120    "Invalid value for default locale - locale name must be a string.";
121const char* kInvalidDescription =
122    "Invalid value for 'description'.";
123const char* kInvalidDevToolsPage =
124    "Invalid value for 'devtools_page'.";
125const char* kInvalidGlob =
126    "Invalid value for 'content_scripts[*].*[*]'.";
127const char* kInvalidGlobList =
128    "Invalid value for 'content_scripts[*].*'.";
129const char* kInvalidHomepageURL =
130    "Invalid value for homepage url: '[*]'.";
131const char* kInvalidIconPath =
132    "Invalid value for 'icons[\"*\"]'.";
133const char* kInvalidIcons =
134    "Invalid value for 'icons'.";
135const char* kInvalidIncognitoBehavior =
136    "Invalid value for 'incognito'.";
137const char* kInvalidJs =
138    "Invalid value for 'content_scripts[*].js[*]'.";
139const char* kInvalidJsList =
140    "Required value 'content_scripts[*].js' is invalid.";
141const char* kInvalidKey =
142    "Value 'key' is missing or invalid.";
143const char* kInvalidLaunchContainer =
144    "Invalid value for 'app.launch.container'.";
145const char* kInvalidLaunchHeight =
146    "Invalid value for 'app.launch.height'.";
147const char* kInvalidLaunchHeightContainer =
148    "Invalid container type for 'app.launch.height'.";
149const char* kInvalidLaunchLocalPath =
150    "Invalid value for 'app.launch.local_path'.";
151const char* kInvalidLaunchWebURL =
152    "Invalid value for 'app.launch.web_url'.";
153const char* kInvalidLaunchWidth =
154    "Invalid value for 'app.launch.width'.";
155const char* kInvalidLaunchWidthContainer =
156    "Invalid container type for 'app.launch.width'.";
157const char* kInvalidManifest =
158    "Manifest file is invalid.";
159const char* kInvalidMatch =
160    "Invalid value for 'content_scripts[*].matches[*]'.";
161const char* kInvalidMatchCount =
162    "Invalid value for 'content_scripts[*].matches'. There must be at least"
163    "one match specified.";
164const char* kInvalidMatches =
165    "Required value 'content_scripts[*].matches' is missing or invalid.";
166const char* kInvalidMinimumChromeVersion =
167    "Invalid value for 'minimum_chrome_version'.";
168const char* kInvalidName =
169    "Required value 'name' is missing or invalid.";
170const char* kInvalidOmniboxKeyword =
171    "Invalid value for 'omnibox.keyword'.";
172const char* kInvalidOptionsPage =
173    "Invalid value for 'options_page'.";
174const char* kInvalidOptionsPageExpectUrlInPackage =
175    "Invalid value for 'options_page'.  Value must be a relative path.";
176const char* kInvalidOptionsPageInHostedApp =
177    "Invalid value for 'options_page'. Hosted apps must specify an "
178    "absolute URL.";
179const char* kInvalidPageAction =
180    "Invalid value for 'page_action'.";
181const char* kInvalidPageActionDefaultTitle =
182    "Invalid value for 'default_title'.";
183const char* kInvalidPageActionIconPath =
184    "Invalid value for 'page_action.default_icon'.";
185const char* kInvalidPageActionId =
186    "Required value 'id' is missing or invalid.";
187const char* kInvalidPageActionName =
188    "Invalid value for 'page_action.name'.";
189const char* kInvalidPageActionOldAndNewKeys =
190    "Key \"*\" is deprecated.  Key \"*\" has the same meaning.  You can not "
191    "use both.";
192const char* kInvalidPageActionPopup =
193    "Invalid type for page action popup.";
194const char* kInvalidPageActionPopupHeight =
195    "Invalid value for page action popup height [*].";
196const char* kInvalidPageActionPopupPath =
197    "Invalid value for page action popup path [*].";
198const char* kInvalidPageActionsList =
199    "Invalid value for 'page_actions'.";
200const char* kInvalidPageActionsListSize =
201    "Invalid value for 'page_actions'. There can be at most one page action.";
202const char* kInvalidPageActionTypeValue =
203    "Invalid value for 'page_actions[*].type', expected 'tab' or 'permanent'.";
204const char* kInvalidPermission =
205    "Invalid value for 'permissions[*]'.";
206const char* kInvalidPermissions =
207    "Required value 'permissions' is missing or invalid.";
208const char* kInvalidPermissionScheme =
209    "Invalid scheme for 'permissions[*]'.";
210const char* kInvalidPlugins =
211    "Invalid value for 'plugins'.";
212const char* kInvalidPluginsPath =
213    "Invalid value for 'plugins[*].path'.";
214const char* kInvalidPluginsPublic =
215    "Invalid value for 'plugins[*].public'.";
216const char* kInvalidRunAt =
217    "Invalid value for 'content_scripts[*].run_at'.";
218const char* kInvalidSignature =
219    "Value 'signature' is missing or invalid.";
220const char* kInvalidTheme =
221    "Invalid value for 'theme'.";
222const char* kInvalidThemeColors =
223    "Invalid value for theme colors - colors must be integers";
224const char* kInvalidThemeImages =
225    "Invalid value for theme images - images must be strings.";
226const char* kInvalidThemeImagesMissing =
227    "An image specified in the theme is missing.";
228const char* kInvalidThemeTints =
229    "Invalid value for theme images - tints must be decimal numbers.";
230const char* kInvalidToolstrip =
231    "Invalid value for 'toolstrips[*]'";
232const char* kInvalidToolstrips =
233    "Invalid value for 'toolstrips'.";
234const char* kInvalidUpdateURL =
235    "Invalid value for update url: '[*]'.";
236const char* kInvalidVersion =
237    "Required value 'version' is missing or invalid. It must be between 1-4 "
238    "dot-separated integers each between 0 and 65536.";
239const char* kInvalidWebURL =
240    "Invalid value for 'app.urls[*]'.";
241const char* kInvalidWebURLs =
242    "Invalid value for 'app.urls'.";
243const char* kInvalidZipHash =
244    "Required key 'zip_hash' is missing or invalid.";
245const char* kLaunchPathAndURLAreExclusive =
246    "The 'app.launch.local_path' and 'launch.web_url' keys cannot both be set.";
247const char* kLaunchURLRequired =
248    "Either 'app.launch.local_path' or 'app.launch.web_url' is required.";
249const char* kLocalesMessagesFileMissing =
250    "Messages file is missing for locale.";
251const char* kLocalesNoDefaultLocaleSpecified =
252    "Localization used, but default_locale wasn't specified in the manifest.";
253const char* kLocalesNoDefaultMessages =
254    "Default locale is defined but default data couldn't be loaded.";
255const char* kLocalesNoValidLocaleNamesListed =
256    "No valid locale name could be found in _locales directory.";
257const char* kLocalesTreeMissing =
258    "Default locale was specified, but _locales subtree is missing.";
259const char* kManifestParseError =
260    "Manifest is not valid JSON.";
261const char* kManifestUnreadable =
262    "Manifest file is missing or unreadable.";
263const char* kMissingFile =
264    "At least one js or css file is required for 'content_scripts[*]'.";
265const char* kMultipleOverrides =
266    "An extension cannot override more than one page.";
267const char* kOneUISurfaceOnly =
268    "Only one of 'browser_action', 'page_action', and 'app' can be specified.";
269const char* kReservedMessageFound =
270    "Reserved key * found in message catalog.";
271const char* kThemesCannotContainExtensions =
272    "A theme cannot contain extensions code.";
273#if defined(OS_CHROMEOS)
274const char* kIllegalPlugins =
275    "Extensions cannot install plugins on Chrome OS";
276#endif
277}  // namespace extension_manifest_errors
278
279namespace extension_urls {
280const char* kGalleryBrowsePrefix = "https://chrome.google.com/extensions";
281const char* kGalleryDownloadPrefix =
282    "https://clients2.googleusercontent.com/crx/download";
283const char* kGalleryUpdateHttpUrl =
284    "http://clients2.google.com/service/update2/crx";
285const char* kGalleryUpdateHttpsUrl =
286    "https://clients2.google.com/service/update2/crx";
287const char* kMiniGalleryBrowsePrefix = "https://tools.google.com/chrome/";
288const char* kMiniGalleryDownloadPrefix = "https://dl-ssl.google.com/chrome/";
289}
290
291namespace extension_filenames {
292const char* kTempExtensionName = "CRX_INSTALL";
293
294// The file to write our decoded images to, relative to the extension_path.
295const char* kDecodedImagesFilename = "DECODED_IMAGES";
296
297// The file to write our decoded message catalogs to, relative to the
298// extension_path.
299const char* kDecodedMessageCatalogsFilename = "DECODED_MESSAGE_CATALOGS";
300}
301
302namespace extension_misc {
303const char* kBookmarkManagerId = "eemcgdkfndhakfknompkggombfjjjeno";
304const char* kWebStoreAppId = "ahfgeienlihckogmohjhadlkjgocpleb";
305const char* kAppsPromoHistogram = "Extensions.AppsPromo";
306}
307