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