extension_constants.cc revision 68043e1e95eeb07d5cae7aca370b26518b0867d6
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
7#include <vector>
8
9#include "base/command_line.h"
10#include "base/strings/string_util.h"
11#include "chrome/common/chrome_switches.h"
12#include "net/base/escape.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 GetWebstoreItemJsonDataURL(const std::string& extension_id) {
36  return GURL(GetWebstoreLaunchURL() + "/inlineinstall/detail/" + extension_id);
37}
38
39GURL GetWebstoreJsonSearchUrl(const std::string& query, const std::string& hl) {
40  GURL url(GetWebstoreLaunchURL() + "/jsonsearch");
41  url = net::AppendQueryParameter(url, "q", query);
42  url = net::AppendQueryParameter(url, "hl", hl);
43  return url;
44}
45
46GURL GetWebstoreSearchPageUrl(const std::string& query) {
47  return GURL(GetWebstoreLaunchURL() + "/search/" +
48              net::EscapeQueryParamValue(query, false));
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
90const char kWebstoreSourceField[] = "utm_source";
91
92const char kLaunchSourceAppList[] = "chrome-app-launcher";
93const char kLaunchSourceAppListSearch[] = "chrome-app-launcher-search";
94
95}  // namespace extension_urls
96
97namespace extension_misc {
98
99const char kBookmarkManagerId[] = "eemcgdkfndhakfknompkggombfjjjeno";
100const char kChromeAppId[] = "mgndgikekgjfcpckkfioiadnlibdjbkf";
101const char kCitrixReceiverAppId[] = "haiffjcadagjlijoggckpgfnoeiflnem";
102const char kCitrixReceiverAppBetaId[] = "gnedhmakppccajfpfiihfcdlnpgomkcf";
103const char kCitrixReceiverAppDevId[] = "fjcibdnjlbfnbfdjneajpipnlcppleek";
104const char kCloudPrintAppId[] = "mfehgcgbbipciphmccgaenjidiccnmng";
105const char kEnterpriseWebStoreAppId[] = "afchcafgojfnemjkcbhfekplkmjaldaa";
106const char kGmailAppId[] = "pjkljhegncpnkpknbcohdijeoejaedia";
107const char kGoogleDocAppId[] = "aohghmighlieiainnegkcijnfilokake";
108const char kGooglePlayMusicAppId[] = "icppfcnhkcmnfdhfhphakoifcfokfdhg";
109const char kGoogleSearchAppId[] = "coobgpohoikkiipiblmjeljniedjpjpf";
110const char kGoogleSheetsAppId[] = "felcaaldnbdncclmgdcncolpebgiejap";
111const char kGoogleSlidesAppId[] = "aapocclcgogkmnckokdopfmhonfmgoek";
112const char kHTermAppId[] = "pnhechapfaindjhompbnflcldabbghjo";
113const char kHTermDevAppId[] = "okddffdblfhhnmhodogpojmfkjmhinfp";
114const char kIdentityApiUiAppId[] = "ahjaciijnoiaklcomgnblndopackapon";
115const char kCroshBuiltinAppId[] = "nkoccljplnhpfnfiajclkommnmllphnl";
116const char kQuickOfficeComponentExtensionId[] =
117    "bpmcpldpdmajfigpchkicefoigmkfalc";
118const char kQuickOfficeDevExtensionId[] = "ionpfmkccalenbmnddpbmocokhaknphg";
119const char kQuickOfficeExtensionId[] = "gbkeegbaiigmenfmjfclcdgdpimamgkj";
120const char kSettingsAppId[] = "ennkphjdgehloodpbhlhldgbnhmacadg";
121const char kStreamsPrivateTestExtensionId[] =
122    "oickdpebdnfbgkcaoklfcdhjniefkcji";
123const char kWebStoreAppId[] = "ahfgeienlihckogmohjhadlkjgocpleb";
124const char kYoutubeAppId[] = "blpcfgokakmgnkcojhhkbfbldkacnbeo";
125const char kInAppPaymentsSupportAppId[] = "nmmhkkegccagdldgiimedpiccmgmieda";
126
127const char kAppLaunchHistogram[] = "Extensions.AppLaunch";
128const char kPlatformAppLaunchHistogram[] = "Apps.AppLaunch";
129#if defined(OS_CHROMEOS)
130const char kChromeVoxExtensionPath[] =
131    "/usr/share/chromeos-assets/accessibility/extensions/access_chromevox";
132// The extension id for the built-in component extension.
133const char kChromeVoxExtensionId[] =
134    "mndnfokpggljbaajbnioimlmbfngpief";
135const char kConnectivityDiagnosticsPath[] =
136    "/usr/share/chromeos-assets/connectivity_diagnostics";
137const char kConnectivityDiagnosticsLauncherPath[] =
138    "/usr/share/chromeos-assets/connectivity_diagnostics_launcher";
139const char kSpeechSynthesisExtensionPath[] =
140    "/usr/share/chromeos-assets/speech_synthesis/patts";
141const char kSpeechSynthesisExtensionId[] =
142    "gjjabgpgjpampikjhjpfhneeoapjbjaf";
143const char kWallpaperManagerId[] = "obklkkbkpaoaejdabbfldmcfplpdgolj";
144#else
145// The extension id for the web store extension.
146const char kChromeVoxExtensionId[] =
147    "kgejglhpjiefppelpmljglcjbhoiplfn";
148#endif
149
150const char kAppStateNotInstalled[] = "not_installed";
151const char kAppStateInstalled[] = "installed";
152const char kAppStateDisabled[] = "disabled";
153const char kAppStateRunning[] = "running";
154const char kAppStateCannotRun[] = "cannot_run";
155const char kAppStateReadyToRun[] = "ready_to_run";
156
157const char kMediaFileSystemPathPart[] = "_";
158
159const int kExtensionIconSizes[] = {
160  EXTENSION_ICON_GIGANTOR,  // 512
161  EXTENSION_ICON_EXTRA_LARGE,  // 256
162  EXTENSION_ICON_LARGE,  // 128
163  EXTENSION_ICON_MEDIUM,  // 48
164  EXTENSION_ICON_SMALL,  // 32
165  EXTENSION_ICON_SMALLISH,  // 24
166  EXTENSION_ICON_BITTY,  // 16
167  // Additional 2x resources to load.
168  2 * EXTENSION_ICON_MEDIUM,  // 96
169  2 * EXTENSION_ICON_SMALL  // 64
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