extension_constants.cc revision 868fa2fe829687343ffae624259930155e16dbd8
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/strings/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
111namespace extension_misc {
112
113const char kBookmarkManagerId[] = "eemcgdkfndhakfknompkggombfjjjeno";
114const char kChromeAppId[] = "mgndgikekgjfcpckkfioiadnlibdjbkf";
115const char kCitrixReceiverAppId[] = "haiffjcadagjlijoggckpgfnoeiflnem";
116const char kCitrixReceiverAppBetaId[] = "gnedhmakppccajfpfiihfcdlnpgomkcf";
117const char kCitrixReceiverAppDevId[] = "fjcibdnjlbfnbfdjneajpipnlcppleek";
118const char kCloudPrintAppId[] = "mfehgcgbbipciphmccgaenjidiccnmng";
119const char kEnterpriseWebStoreAppId[] = "afchcafgojfnemjkcbhfekplkmjaldaa";
120const char kGmailAppId[] = "pjkljhegncpnkpknbcohdijeoejaedia";
121const char kGoogleDocAppId[] = "aohghmighlieiainnegkcijnfilokake";
122const char kGooglePlayMusicAppId[] = "icppfcnhkcmnfdhfhphakoifcfokfdhg";
123const char kGoogleSearchAppId[] = "coobgpohoikkiipiblmjeljniedjpjpf";
124const char kGoogleSheetsAppId[] = "felcaaldnbdncclmgdcncolpebgiejap";
125const char kGoogleSlidesAppId[] = "aapocclcgogkmnckokdopfmhonfmgoek";
126const char kHTermAppId[] = "pnhechapfaindjhompbnflcldabbghjo";
127const char kHTermDevAppId[] = "okddffdblfhhnmhodogpojmfkjmhinfp";
128const char kIdentityApiUiAppId[] = "ahjaciijnoiaklcomgnblndopackapon";
129const char kCroshBuiltinAppId[] = "nkoccljplnhpfnfiajclkommnmllphnl";
130const char kQuickOfficeComponentExtensionId[] =
131    "bpmcpldpdmajfigpchkicefoigmkfalc";
132const char kQuickOfficeDevExtensionId[] = "ionpfmkccalenbmnddpbmocokhaknphg";
133const char kQuickOfficeExtensionId[] = "gbkeegbaiigmenfmjfclcdgdpimamgkj";
134const char kSettingsAppId[] = "ennkphjdgehloodpbhlhldgbnhmacadg";
135const char kStreamsPrivateTestExtensionId[] =
136    "oickdpebdnfbgkcaoklfcdhjniefkcji";
137const char kWebStoreAppId[] = "ahfgeienlihckogmohjhadlkjgocpleb";
138const char kYoutubeAppId[] = "blpcfgokakmgnkcojhhkbfbldkacnbeo";
139const char kInAppPaymentsSupportAppId[] = "nmmhkkegccagdldgiimedpiccmgmieda";
140
141const char kAppLaunchHistogram[] = "Extensions.AppLaunch";
142const char kPlatformAppLaunchHistogram[] = "Apps.AppLaunch";
143#if defined(OS_CHROMEOS)
144const char kChromeVoxExtensionPath[] =
145    "/usr/share/chromeos-assets/accessibility/extensions/access_chromevox";
146const char kSpeechSynthesisExtensionPath[] =
147    "/usr/share/chromeos-assets/speech_synthesis/patts";
148const char kSpeechSynthesisExtensionId[] =
149    "gjjabgpgjpampikjhjpfhneeoapjbjaf";
150const char kWallpaperManagerId[] = "obklkkbkpaoaejdabbfldmcfplpdgolj";
151#endif
152
153const char kAppStateNotInstalled[] = "not_installed";
154const char kAppStateInstalled[] = "installed";
155const char kAppStateDisabled[] = "disabled";
156const char kAppStateRunning[] = "running";
157const char kAppStateCannotRun[] = "cannot_run";
158const char kAppStateReadyToRun[] = "ready_to_run";
159
160const char kMediaFileSystemPathPart[] = "_";
161
162const int kExtensionIconSizes[] = {
163  EXTENSION_ICON_GIGANTOR,  // 512
164  EXTENSION_ICON_EXTRA_LARGE,  // 256
165  EXTENSION_ICON_LARGE,  // 128
166  EXTENSION_ICON_MEDIUM,  // 48
167  EXTENSION_ICON_SMALL,  // 32
168  EXTENSION_ICON_SMALLISH,  // 24
169  EXTENSION_ICON_BITTY  // 16
170};
171
172const size_t kNumExtensionIconSizes =
173    arraysize(kExtensionIconSizes);
174
175const int kExtensionActionIconSizes[] = {
176  EXTENSION_ICON_ACTION,  // 19,
177  2 * EXTENSION_ICON_ACTION  // 38
178};
179
180const size_t kNumExtensionActionIconSizes =
181    arraysize(kExtensionActionIconSizes);
182
183const int kScriptBadgeIconSizes[] = {
184  EXTENSION_ICON_BITTY,  // 16
185  2 * EXTENSION_ICON_BITTY  // 32
186};
187
188const size_t kNumScriptBadgeIconSizes =
189    arraysize(kScriptBadgeIconSizes);
190
191}  // namespace extension_misc
192