extension_constants.cc revision 90dce4d38c5ff5333bea97d859d4e484e27edf0c
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.
4
5#include "chrome/common/extensions/extension_constants.h"
6#include "chrome/common/extensions/extension_manifest_constants.h"
7
8#include <vector>
9
10#include "base/command_line.h"
11#include "base/string_util.h"
12#include "chrome/common/chrome_switches.h"
13#include "net/base/escape.h"
14#include "net/base/url_util.h"
15
16namespace extension_urls {
17
18std::string GetWebstoreLaunchURL() {
19  std::string gallery_prefix = kGalleryBrowsePrefix;
20  if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAppsGalleryURL))
21    gallery_prefix = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
22        switches::kAppsGalleryURL);
23  if (EndsWith(gallery_prefix, "/", true))
24    gallery_prefix = gallery_prefix.substr(0, gallery_prefix.length() - 1);
25  return gallery_prefix;
26}
27
28std::string GetExtensionGalleryURL() {
29  return GetWebstoreLaunchURL() + "/category/extensions";
30}
31
32std::string GetWebstoreItemDetailURLPrefix() {
33  return GetWebstoreLaunchURL() + "/detail/";
34}
35
36GURL GetWebstoreItemJsonDataURL(const std::string& extension_id) {
37  return GURL(GetWebstoreLaunchURL() + "/inlineinstall/detail/" + extension_id);
38}
39
40GURL GetWebstoreJsonSearchUrl(const std::string& query, const std::string& hl) {
41  GURL url(GetWebstoreLaunchURL() + "/jsonsearch");
42  url = net::AppendQueryParameter(url, "q", query);
43  url = net::AppendQueryParameter(url, "hl", hl);
44  return url;
45}
46
47GURL GetWebstoreSearchPageUrl(const std::string& query) {
48  return GURL(GetWebstoreLaunchURL() + "/search/" +
49              net::EscapeQueryParamValue(query, false));
50}
51
52const char kGalleryUpdateHttpsUrl[] =
53    "https://clients2.google.com/service/update2/crx";
54// TODO(battre): Delete the HTTP URL once the blacklist is downloaded via HTTPS.
55const char kExtensionBlocklistUrlPrefix[] =
56    "http://www.gstatic.com/chrome/extensions/blacklist";
57const char kExtensionBlocklistHttpsUrlPrefix[] =
58    "https://www.gstatic.com/chrome/extensions/blacklist";
59
60GURL GetWebstoreUpdateUrl() {
61  CommandLine* cmdline = CommandLine::ForCurrentProcess();
62  if (cmdline->HasSwitch(switches::kAppsGalleryUpdateURL))
63    return GURL(cmdline->GetSwitchValueASCII(switches::kAppsGalleryUpdateURL));
64  else
65    return GURL(kGalleryUpdateHttpsUrl);
66}
67
68bool IsWebstoreUpdateUrl(const GURL& update_url) {
69  GURL store_url = GetWebstoreUpdateUrl();
70  if (update_url == store_url) {
71    return true;
72  } else {
73    return (update_url.host() == store_url.host() &&
74            update_url.path() == store_url.path());
75  }
76}
77
78bool IsBlacklistUpdateUrl(const GURL& url) {
79  // The extension blacklist URL is returned from the update service and
80  // therefore not determined by Chromium. If the location of the blacklist file
81  // ever changes, we need to update this function. A DCHECK in the
82  // ExtensionUpdater ensures that we notice a change. This is the full URL
83  // of a blacklist:
84  // http://www.gstatic.com/chrome/extensions/blacklist/l_0_0_0_7.txt
85  return StartsWithASCII(url.spec(), kExtensionBlocklistUrlPrefix, true) ||
86      StartsWithASCII(url.spec(), kExtensionBlocklistHttpsUrlPrefix, true);
87}
88
89const char kGalleryBrowsePrefix[] = "https://chrome.google.com/webstore";
90
91}  // namespace extension_urls
92
93namespace extension_filenames {
94
95const char kTempExtensionName[] = "CRX_INSTALL";
96
97// The file to write our decoded images to, relative to the extension_path.
98const char kDecodedImagesFilename[] = "DECODED_IMAGES";
99
100// The file to write our decoded message catalogs to, relative to the
101// extension_path.
102const char kDecodedMessageCatalogsFilename[] = "DECODED_MESSAGE_CATALOGS";
103
104const char kGeneratedBackgroundPageFilename[] =
105    "_generated_background_page.html";
106
107const char kModulesDir[] = "_modules";
108
109}  // namespace extension_filenames
110
111// These must match the values expected by the chrome.management extension API.
112namespace extension_info_keys {
113  const char kDescriptionKey[] = "description";
114  const char kEnabledKey[] = "enabled";
115  const char kHomepageUrlKey[] = "homepageUrl";
116  const char kIdKey[] = "id";
117  const char kNameKey[] = "name";
118  const char kKioskEnabledKey[] = "kioskEnabled";
119  const char kOfflineEnabledKey[] = "offlineEnabled";
120  const char kOptionsUrlKey[] = "optionsUrl";
121  const char kDetailsUrlKey[] = "detailsUrl";
122  const char kVersionKey[] = "version";
123  const char kPackagedAppKey[] = "packagedApp";
124
125}  // namespace extension_filenames
126
127namespace extension_misc {
128
129const char kBookmarkManagerId[] = "eemcgdkfndhakfknompkggombfjjjeno";
130const char kChromeAppId[] = "mgndgikekgjfcpckkfioiadnlibdjbkf";
131const char kCitrixReceiverAppId[] = "haiffjcadagjlijoggckpgfnoeiflnem";
132const char kCitrixReceiverAppBetaId[] = "gnedhmakppccajfpfiihfcdlnpgomkcf";
133const char kCitrixReceiverAppDevId[] = "fjcibdnjlbfnbfdjneajpipnlcppleek";
134const char kCloudPrintAppId[] = "mfehgcgbbipciphmccgaenjidiccnmng";
135const char kEnterpriseWebStoreAppId[] = "afchcafgojfnemjkcbhfekplkmjaldaa";
136const char kGmailAppId[] = "pjkljhegncpnkpknbcohdijeoejaedia";
137const char kGoogleDocAppId[] = "aohghmighlieiainnegkcijnfilokake";
138const char kGooglePlayMusicAppId[] = "icppfcnhkcmnfdhfhphakoifcfokfdhg";
139const char kGoogleSearchAppId[] = "coobgpohoikkiipiblmjeljniedjpjpf";
140const char kGoogleSheetsAppId[] = "felcaaldnbdncclmgdcncolpebgiejap";
141const char kGoogleSlidesAppId[] = "aapocclcgogkmnckokdopfmhonfmgoek";
142const char kHTermAppId[] = "pnhechapfaindjhompbnflcldabbghjo";
143const char kHTermDevAppId[] = "okddffdblfhhnmhodogpojmfkjmhinfp";
144const char kIdentityApiUiAppId[] = "ahjaciijnoiaklcomgnblndopackapon";
145const char kCroshBuiltinAppId[] = "nkoccljplnhpfnfiajclkommnmllphnl";
146const char kQuickOfficeComponentExtensionId[] =
147    "bpmcpldpdmajfigpchkicefoigmkfalc";
148const char kQuickOfficeDevExtensionId[] = "ionpfmkccalenbmnddpbmocokhaknphg";
149const char kQuickOfficeExtensionId[] = "gbkeegbaiigmenfmjfclcdgdpimamgkj";
150const char kSettingsAppId[] = "ennkphjdgehloodpbhlhldgbnhmacadg";
151const char kStreamsPrivateTestExtensionId[] =
152    "oickdpebdnfbgkcaoklfcdhjniefkcji";
153const char kWebStoreAppId[] = "ahfgeienlihckogmohjhadlkjgocpleb";
154const char kYoutubeAppId[] = "blpcfgokakmgnkcojhhkbfbldkacnbeo";
155const char kInAppPaymentsSupportAppId[] = "nmmhkkegccagdldgiimedpiccmgmieda";
156
157const char kAppLaunchHistogram[] = "Extensions.AppLaunch";
158const char kPlatformAppLaunchHistogram[] = "Apps.AppLaunch";
159#if defined(OS_CHROMEOS)
160const char kChromeVoxExtensionPath[] =
161    "/usr/share/chromeos-assets/accessibility/extensions/access_chromevox";
162const char kSpeechSynthesisExtensionPath[] =
163    "/usr/share/chromeos-assets/speech_synthesis/patts";
164const char kSpeechSynthesisExtensionId[] =
165    "gjjabgpgjpampikjhjpfhneeoapjbjaf";
166const char kWallpaperManagerId[] = "obklkkbkpaoaejdabbfldmcfplpdgolj";
167#endif
168
169const char kAppStateNotInstalled[] = "not_installed";
170const char kAppStateInstalled[] = "installed";
171const char kAppStateDisabled[] = "disabled";
172const char kAppStateRunning[] = "running";
173const char kAppStateCannotRun[] = "cannot_run";
174const char kAppStateReadyToRun[] = "ready_to_run";
175
176const char kMediaFileSystemPathPart[] = "_";
177
178const int kExtensionIconSizes[] = {
179  EXTENSION_ICON_GIGANTOR,  // 512
180  EXTENSION_ICON_EXTRA_LARGE,  // 256
181  EXTENSION_ICON_LARGE,  // 128
182  EXTENSION_ICON_MEDIUM,  // 48
183  EXTENSION_ICON_SMALL,  // 32
184  EXTENSION_ICON_SMALLISH,  // 24
185  EXTENSION_ICON_BITTY  // 16
186};
187
188const size_t kNumExtensionIconSizes =
189    arraysize(kExtensionIconSizes);
190
191const int kExtensionActionIconSizes[] = {
192  EXTENSION_ICON_ACTION,  // 19,
193  2 * EXTENSION_ICON_ACTION  // 38
194};
195
196const size_t kNumExtensionActionIconSizes =
197    arraysize(kExtensionActionIconSizes);
198
199const int kScriptBadgeIconSizes[] = {
200  EXTENSION_ICON_BITTY,  // 16
201  2 * EXTENSION_ICON_BITTY  // 32
202};
203
204const size_t kNumScriptBadgeIconSizes =
205    arraysize(kScriptBadgeIconSizes);
206
207}  // namespace extension_misc
208