Extract SIGPIPE ignoring code to a common place.
[chromium-blink-merge.git] / chrome / common / extensions / extension_constants.cc
blob48baffe81391e77312a0b3eaea930ed3f10dcc24
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
3 // found in the LICENSE file.
5 #include "chrome/common/extensions/extension_constants.h"
6 #include "chrome/common/extensions/extension_manifest_constants.h"
8 #include <vector>
10 #include "base/command_line.h"
11 #include "base/string_util.h"
12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/net/url_util.h"
15 namespace extension_urls {
17 std::string GetWebstoreLaunchURL() {
18 std::string gallery_prefix = kGalleryBrowsePrefix;
19 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAppsGalleryURL))
20 gallery_prefix = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
21 switches::kAppsGalleryURL);
22 if (EndsWith(gallery_prefix, "/", true))
23 gallery_prefix = gallery_prefix.substr(0, gallery_prefix.length() - 1);
24 return gallery_prefix;
27 std::string GetExtensionGalleryURL() {
28 return GetWebstoreLaunchURL() + "/category/extensions";
31 std::string GetWebstoreItemDetailURLPrefix() {
32 return GetWebstoreLaunchURL() + "/detail/";
35 GURL GetWebstoreIntentQueryURL(const std::string& action,
36 const std::string& type) {
37 const char kIntentsCategoryPath[] = "category/collection/webintent_apps";
39 GURL url(std::string(kGalleryBrowsePrefix) + "/");
40 url = url.Resolve(kIntentsCategoryPath);
41 url = chrome_common_net::AppendQueryParameter(url, "_wi", action);
42 url = chrome_common_net::AppendQueryParameter(url, "_mt", type);
44 return url;
47 GURL GetWebstoreItemJsonDataURL(const std::string& extension_id) {
48 return GURL(GetWebstoreLaunchURL() + "/inlineinstall/detail/" + extension_id);
51 const char kGalleryUpdateHttpsUrl[] =
52 "https://clients2.google.com/service/update2/crx";
53 // TODO(battre): Delete the HTTP URL once the blacklist is downloaded via HTTPS.
54 const char kExtensionBlocklistUrlPrefix[] =
55 "http://www.gstatic.com/chrome/extensions/blacklist";
56 const char kExtensionBlocklistHttpsUrlPrefix[] =
57 "https://www.gstatic.com/chrome/extensions/blacklist";
59 GURL GetWebstoreUpdateUrl() {
60 CommandLine* cmdline = CommandLine::ForCurrentProcess();
61 if (cmdline->HasSwitch(switches::kAppsGalleryUpdateURL))
62 return GURL(cmdline->GetSwitchValueASCII(switches::kAppsGalleryUpdateURL));
63 else
64 return GURL(kGalleryUpdateHttpsUrl);
67 bool IsWebstoreUpdateUrl(const GURL& update_url) {
68 GURL store_url = GetWebstoreUpdateUrl();
69 if (update_url == store_url) {
70 return true;
71 } else {
72 return (update_url.host() == store_url.host() &&
73 update_url.path() == store_url.path());
77 bool IsBlacklistUpdateUrl(const GURL& url) {
78 // The extension blacklist URL is returned from the update service and
79 // therefore not determined by Chromium. If the location of the blacklist file
80 // ever changes, we need to update this function. A DCHECK in the
81 // ExtensionUpdater ensures that we notice a change. This is the full URL
82 // of a blacklist:
83 // http://www.gstatic.com/chrome/extensions/blacklist/l_0_0_0_7.txt
84 return StartsWithASCII(url.spec(), kExtensionBlocklistUrlPrefix, true) ||
85 StartsWithASCII(url.spec(), kExtensionBlocklistHttpsUrlPrefix, true);
88 const char kGalleryBrowsePrefix[] = "https://chrome.google.com/webstore";
90 } // namespace extension_urls
92 namespace extension_filenames {
94 const char kTempExtensionName[] = "CRX_INSTALL";
96 // The file to write our decoded images to, relative to the extension_path.
97 const char kDecodedImagesFilename[] = "DECODED_IMAGES";
99 // The file to write our decoded message catalogs to, relative to the
100 // extension_path.
101 const char kDecodedMessageCatalogsFilename[] = "DECODED_MESSAGE_CATALOGS";
103 const char kGeneratedBackgroundPageFilename[] =
104 "_generated_background_page.html";
107 // These must match the values expected by the chrome.management extension API.
108 namespace extension_info_keys {
109 const char kDescriptionKey[] = "description";
110 const char kEnabledKey[] = "enabled";
111 const char kHomepageUrlKey[] = "homepageUrl";
112 const char kIdKey[] = "id";
113 const char kNameKey[] = "name";
114 const char kOfflineEnabledKey[] = "offlineEnabled";
115 const char kOptionsUrlKey[] = "optionsUrl";
116 const char kDetailsUrlKey[] = "detailsUrl";
117 const char kVersionKey[] = "version";
118 const char kPackagedAppKey[] = "packagedApp";
120 } // namespace extension_filenames
122 namespace extension_misc {
123 const char kBookmarkManagerId[] = "eemcgdkfndhakfknompkggombfjjjeno";
124 const char kCitrixReceiverAppId[] = "haiffjcadagjlijoggckpgfnoeiflnem";
125 const char kCitrixReceiverAppBetaId[] = "gnedhmakppccajfpfiihfcdlnpgomkcf";
126 const char kCitrixReceiverAppDevId[] = "fjcibdnjlbfnbfdjneajpipnlcppleek";
127 const char kEnterpriseWebStoreAppId[] = "afchcafgojfnemjkcbhfekplkmjaldaa";
128 const char kHTermAppId[] = "pnhechapfaindjhompbnflcldabbghjo";
129 const char kHTermDevAppId[] = "okddffdblfhhnmhodogpojmfkjmhinfp";
130 const char kCroshBuiltinAppId[] = "nkoccljplnhpfnfiajclkommnmllphnl";
131 const char kWebStoreAppId[] = "ahfgeienlihckogmohjhadlkjgocpleb";
132 const char kCloudPrintAppId[] = "mfehgcgbbipciphmccgaenjidiccnmng";
133 const char kChromeAppId[] = "mgndgikekgjfcpckkfioiadnlibdjbkf";
134 const char kAppLaunchHistogram[] = "Extensions.AppLaunch";
135 #if defined(OS_CHROMEOS)
136 const char kAccessExtensionPath[] =
137 "/usr/share/chromeos-assets/accessibility/extensions";
138 const char kChromeVoxDirectoryName[] = "access_chromevox";
139 const char kWallpaperManagerId[] = "obklkkbkpaoaejdabbfldmcfplpdgolj";
140 #endif
142 const char kAppStateNotInstalled[] = "not_installed";
143 const char kAppStateInstalled[] = "installed";
144 const char kAppStateDisabled[] = "disabled";
145 const char kAppStateRunning[] = "running";
146 const char kAppStateCannotRun[] = "cannot_run";
147 const char kAppStateReadyToRun[] = "ready_to_run";
149 const char kMediaFileSystemPathPart[] = "_";
151 const char kAppNotificationsIncognitoError[] =
152 "This API is not accessible by 'split' mode "
153 "extensions in incognito windows.";
155 const int kExtensionIconSizes[] = {
156 EXTENSION_ICON_GIGANTOR, // 512
157 EXTENSION_ICON_EXTRA_LARGE, // 256
158 EXTENSION_ICON_LARGE, // 128
159 EXTENSION_ICON_MEDIUM, // 48
160 EXTENSION_ICON_SMALL, // 32
161 EXTENSION_ICON_SMALLISH, // 24
162 EXTENSION_ICON_BITTY // 16
165 const size_t kNumExtensionIconSizes =
166 arraysize(kExtensionIconSizes);
168 const int kExtensionActionIconSizes[] = {
169 EXTENSION_ICON_ACTION, // 19,
170 2 * EXTENSION_ICON_ACTION // 38
173 const size_t kNumExtensionActionIconSizes =
174 arraysize(kExtensionActionIconSizes);
176 const int kScriptBadgeIconSizes[] = {
177 EXTENSION_ICON_BITTY, // 16
178 2 * EXTENSION_ICON_BITTY // 32
181 const size_t kNumScriptBadgeIconSizes =
182 arraysize(kScriptBadgeIconSizes);
184 } // namespace extension_misc