extension_constants.cc revision 4ad1aa43a48567659193a298fad74f55e00b3dd9
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";
94const char kLaunchSourceAppListInfoDialog[] = "chrome-app-launcher-info-dialog";
95
96}  // namespace extension_urls
97
98namespace extension_misc {
99
100const char kBookmarkManagerId[] = "eemcgdkfndhakfknompkggombfjjjeno";
101const char kChromeAppId[] = "mgndgikekgjfcpckkfioiadnlibdjbkf";
102const char kCloudPrintAppId[] = "mfehgcgbbipciphmccgaenjidiccnmng";
103const char kEasyUnlockAppId[] = "mkaemigholebcgchlkbankmihknojeak";
104const char kEnterpriseWebStoreAppId[] = "afchcafgojfnemjkcbhfekplkmjaldaa";
105const char kGmailAppId[] = "pjkljhegncpnkpknbcohdijeoejaedia";
106const char kGoogleDocAppId[] = "aohghmighlieiainnegkcijnfilokake";
107const char kGooglePlayMusicAppId[] = "icppfcnhkcmnfdhfhphakoifcfokfdhg";
108const char kGoogleSearchAppId[] = "coobgpohoikkiipiblmjeljniedjpjpf";
109const char kGoogleSheetsAppId[] = "felcaaldnbdncclmgdcncolpebgiejap";
110const char kGoogleSlidesAppId[] = "aapocclcgogkmnckokdopfmhonfmgoek";
111const char kHTermAppId[] = "pnhechapfaindjhompbnflcldabbghjo";
112const char kHTermDevAppId[] = "okddffdblfhhnmhodogpojmfkjmhinfp";
113const char kIdentityApiUiAppId[] = "ahjaciijnoiaklcomgnblndopackapon";
114const char kCroshBuiltinAppId[] = "nkoccljplnhpfnfiajclkommnmllphnl";
115const char kHotwordExtensionId[] = "bepbmhgboaologfdajaanbcjmnhjmhfn";
116const char kPdfExtensionId[] = "mhjfbmdgcfjbbpaeojofohoefgiehjai";
117const char kQuickOfficeComponentExtensionId[] =
118    "bpmcpldpdmajfigpchkicefoigmkfalc";
119const char kQuickOfficeInternalExtensionId[] =
120    "ehibbfinohgbchlgdbfpikodjaojhccn";
121const char kQuickOfficeExtensionId[] = "gbkeegbaiigmenfmjfclcdgdpimamgkj";
122const char kSettingsAppId[] = "ennkphjdgehloodpbhlhldgbnhmacadg";
123const char kStreamsPrivateTestExtensionId[] =
124    "oickdpebdnfbgkcaoklfcdhjniefkcji";
125const char kWebStoreAppId[] = "ahfgeienlihckogmohjhadlkjgocpleb";
126const char kYoutubeAppId[] = "blpcfgokakmgnkcojhhkbfbldkacnbeo";
127const char kInAppPaymentsSupportAppId[] = "nmmhkkegccagdldgiimedpiccmgmieda";
128
129const char kAppLaunchHistogram[] = "Extensions.AppLaunch";
130const char kPlatformAppLaunchHistogram[] = "Apps.AppLaunch";
131#if defined(OS_CHROMEOS)
132const char kChromeVoxExtensionPath[] = "chromeos/chromevox";
133// The extension id for the built-in component extension.
134const char kChromeVoxExtensionId[] =
135    "mndnfokpggljbaajbnioimlmbfngpief";
136const char kConnectivityDiagnosticsPath[] =
137    "/usr/share/chromeos-assets/connectivity_diagnostics";
138const char kConnectivityDiagnosticsLauncherPath[] =
139    "/usr/share/chromeos-assets/connectivity_diagnostics_launcher";
140const char kSpeechSynthesisExtensionPath[] =
141    "/usr/share/chromeos-assets/speech_synthesis/patts";
142const char kSpeechSynthesisExtensionId[] =
143    "gjjabgpgjpampikjhjpfhneeoapjbjaf";
144const char kWallpaperManagerId[] = "obklkkbkpaoaejdabbfldmcfplpdgolj";
145const char kFirstRunDialogId[] = "jdgcneonijmofocbhmijhacgchbihela";
146#else
147// The extension id for the web store extension.
148const char kChromeVoxExtensionId[] =
149    "kgejglhpjiefppelpmljglcjbhoiplfn";
150#endif
151
152const char kAppStateNotInstalled[] = "not_installed";
153const char kAppStateInstalled[] = "installed";
154const char kAppStateDisabled[] = "disabled";
155const char kAppStateRunning[] = "running";
156const char kAppStateCannotRun[] = "cannot_run";
157const char kAppStateReadyToRun[] = "ready_to_run";
158
159const char kMediaFileSystemPathPart[] = "_";
160
161const int kExtensionIconSizes[] = {
162  EXTENSION_ICON_GIGANTOR,  // 512
163  EXTENSION_ICON_EXTRA_LARGE,  // 256
164  EXTENSION_ICON_LARGE,  // 128
165  EXTENSION_ICON_MEDIUM,  // 48
166  EXTENSION_ICON_SMALL,  // 32
167  EXTENSION_ICON_SMALLISH,  // 24
168  EXTENSION_ICON_BITTY,  // 16
169  // Additional 2x resources to load.
170  2 * EXTENSION_ICON_MEDIUM,  // 96
171  2 * EXTENSION_ICON_SMALL  // 64
172};
173
174const size_t kNumExtensionIconSizes =
175    arraysize(kExtensionIconSizes);
176
177const int kExtensionActionIconSizes[] = {
178  EXTENSION_ICON_ACTION,  // 19,
179  2 * EXTENSION_ICON_ACTION  // 38
180};
181
182const size_t kNumExtensionActionIconSizes =
183    arraysize(kExtensionActionIconSizes);
184
185}  // namespace extension_misc
186