extension_constants.cc revision c2e0dbddbe15c98d52c4786dac06cb8952a8ae6d
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/url_util.h"
14
15namespace extension_urls {
16
17std::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;
25}
26
27std::string GetExtensionGalleryURL() {
28  return GetWebstoreLaunchURL() + "/category/extensions";
29}
30
31std::string GetWebstoreItemDetailURLPrefix() {
32  return GetWebstoreLaunchURL() + "/detail/";
33}
34
35GURL GetWebstoreIntentQueryURL(const std::string& action,
36                               const std::string& type) {
37  const char kIntentsCategoryPath[] = "category/collection/webintent_apps";
38
39  GURL url(std::string(kGalleryBrowsePrefix) + "/");
40  url = url.Resolve(kIntentsCategoryPath);
41  url = net::AppendQueryParameter(url, "_wi", action);
42  url = net::AppendQueryParameter(url, "_mt", type);
43
44  return url;
45}
46
47GURL GetWebstoreItemJsonDataURL(const std::string& extension_id) {
48  return GURL(GetWebstoreLaunchURL() + "/inlineinstall/detail/" + extension_id);
49}
50
51const char kGalleryUpdateHttpsUrl[] =
52    "https://clients2.google.com/service/update2/crx";
53// TODO(battre): Delete the HTTP URL once the blacklist is downloaded via HTTPS.
54const char kExtensionBlocklistUrlPrefix[] =
55    "http://www.gstatic.com/chrome/extensions/blacklist";
56const char kExtensionBlocklistHttpsUrlPrefix[] =
57    "https://www.gstatic.com/chrome/extensions/blacklist";
58
59GURL 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);
65}
66
67bool 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());
74  }
75}
76
77bool 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);
86}
87
88const char kGalleryBrowsePrefix[] = "https://chrome.google.com/webstore";
89
90}  // namespace extension_urls
91
92namespace extension_filenames {
93
94const char kTempExtensionName[] = "CRX_INSTALL";
95
96// The file to write our decoded images to, relative to the extension_path.
97const char kDecodedImagesFilename[] = "DECODED_IMAGES";
98
99// The file to write our decoded message catalogs to, relative to the
100// extension_path.
101const char kDecodedMessageCatalogsFilename[] = "DECODED_MESSAGE_CATALOGS";
102
103const char kGeneratedBackgroundPageFilename[] =
104    "_generated_background_page.html";
105
106const char kModulesDir[] = "_modules";
107
108}  // namespace extension_filenames
109
110// These must match the values expected by the chrome.management extension API.
111namespace extension_info_keys {
112  const char kDescriptionKey[] = "description";
113  const char kEnabledKey[] = "enabled";
114  const char kHomepageUrlKey[] = "homepageUrl";
115  const char kIdKey[] = "id";
116  const char kNameKey[] = "name";
117  const char kKioskEnabledKey[] = "kioskEnabled";
118  const char kOfflineEnabledKey[] = "offlineEnabled";
119  const char kOptionsUrlKey[] = "optionsUrl";
120  const char kDetailsUrlKey[] = "detailsUrl";
121  const char kVersionKey[] = "version";
122  const char kPackagedAppKey[] = "packagedApp";
123
124}  // namespace extension_filenames
125
126namespace extension_misc {
127
128const char kBookmarkManagerId[] = "eemcgdkfndhakfknompkggombfjjjeno";
129const char kChromeAppId[] = "mgndgikekgjfcpckkfioiadnlibdjbkf";
130const char kCitrixReceiverAppId[] = "haiffjcadagjlijoggckpgfnoeiflnem";
131const char kCitrixReceiverAppBetaId[] = "gnedhmakppccajfpfiihfcdlnpgomkcf";
132const char kCitrixReceiverAppDevId[] = "fjcibdnjlbfnbfdjneajpipnlcppleek";
133const char kCloudPrintAppId[] = "mfehgcgbbipciphmccgaenjidiccnmng";
134const char kEnterpriseWebStoreAppId[] = "afchcafgojfnemjkcbhfekplkmjaldaa";
135const char kGmailAppId[] = "pjkljhegncpnkpknbcohdijeoejaedia";
136const char kGoogleDocAppId[] = "aohghmighlieiainnegkcijnfilokake";
137const char kGooglePlayMusicAppId[] = "icppfcnhkcmnfdhfhphakoifcfokfdhg";
138const char kGoogleSearchAppId[] = "coobgpohoikkiipiblmjeljniedjpjpf";
139const char kGoogleSheetsAppId[] = "felcaaldnbdncclmgdcncolpebgiejap";
140const char kGoogleSlidesAppId[] = "aapocclcgogkmnckokdopfmhonfmgoek";
141const char kHTermAppId[] = "pnhechapfaindjhompbnflcldabbghjo";
142const char kHTermDevAppId[] = "okddffdblfhhnmhodogpojmfkjmhinfp";
143const char kCroshBuiltinAppId[] = "nkoccljplnhpfnfiajclkommnmllphnl";
144const char kQuickOfficeComponentExtensionId[] =
145    "bpmcpldpdmajfigpchkicefoigmkfalc";
146const char kQuickOfficeDevExtensionId[] = "ionpfmkccalenbmnddpbmocokhaknphg";
147const char kQuickOfficeExtensionId[] = "gbkeegbaiigmenfmjfclcdgdpimamgkj";
148const char kSettingsAppId[] = "ennkphjdgehloodpbhlhldgbnhmacadg";
149const char kStreamsPrivateTestExtensionId[] =
150    "oickdpebdnfbgkcaoklfcdhjniefkcji";
151const char kWebStoreAppId[] = "ahfgeienlihckogmohjhadlkjgocpleb";
152const char kYoutubeAppId[] = "blpcfgokakmgnkcojhhkbfbldkacnbeo";
153
154const char kAppLaunchHistogram[] = "Extensions.AppLaunch";
155const char kPlatformAppLaunchHistogram[] = "Apps.AppLaunch";
156#if defined(OS_CHROMEOS)
157const char kChromeVoxExtensionPath[] =
158    "/usr/share/chromeos-assets/accessibility/extensions/access_chromevox";
159const char kSpeechSynthesisExtensionPath[] =
160    "/usr/share/chromeos-assets/speech_synthesis/patts";
161const char kSpeechSynthesisExtensionId[] =
162    "gjjabgpgjpampikjhjpfhneeoapjbjaf";
163const char kWallpaperManagerId[] = "obklkkbkpaoaejdabbfldmcfplpdgolj";
164#endif
165
166const char kAppStateNotInstalled[] = "not_installed";
167const char kAppStateInstalled[] = "installed";
168const char kAppStateDisabled[] = "disabled";
169const char kAppStateRunning[] = "running";
170const char kAppStateCannotRun[] = "cannot_run";
171const char kAppStateReadyToRun[] = "ready_to_run";
172
173const char kMediaFileSystemPathPart[] = "_";
174
175const int kExtensionIconSizes[] = {
176  EXTENSION_ICON_GIGANTOR,  // 512
177  EXTENSION_ICON_EXTRA_LARGE,  // 256
178  EXTENSION_ICON_LARGE,  // 128
179  EXTENSION_ICON_MEDIUM,  // 48
180  EXTENSION_ICON_SMALL,  // 32
181  EXTENSION_ICON_SMALLISH,  // 24
182  EXTENSION_ICON_BITTY  // 16
183};
184
185const size_t kNumExtensionIconSizes =
186    arraysize(kExtensionIconSizes);
187
188const int kExtensionActionIconSizes[] = {
189  EXTENSION_ICON_ACTION,  // 19,
190  2 * EXTENSION_ICON_ACTION  // 38
191};
192
193const size_t kNumExtensionActionIconSizes =
194    arraysize(kExtensionActionIconSizes);
195
196const int kScriptBadgeIconSizes[] = {
197  EXTENSION_ICON_BITTY,  // 16
198  2 * EXTENSION_ICON_BITTY  // 32
199};
200
201const size_t kNumScriptBadgeIconSizes =
202    arraysize(kScriptBadgeIconSizes);
203
204}  // namespace extension_misc
205