• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
15 namespace extension_urls {
16 
GetWebstoreLaunchURL()17 std::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 
GetExtensionGalleryURL()27 std::string GetExtensionGalleryURL() {
28   return GetWebstoreLaunchURL() + "/category/extensions";
29 }
30 
GetWebstoreItemDetailURLPrefix()31 std::string GetWebstoreItemDetailURLPrefix() {
32   return GetWebstoreLaunchURL() + "/detail/";
33 }
34 
GetWebstoreItemJsonDataURL(const std::string & extension_id)35 GURL GetWebstoreItemJsonDataURL(const std::string& extension_id) {
36   return GURL(GetWebstoreLaunchURL() + "/inlineinstall/detail/" + extension_id);
37 }
38 
GetWebstoreJsonSearchUrl(const std::string & query,const std::string & hl)39 GURL 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 
GetWebstoreSearchPageUrl(const std::string & query)46 GURL GetWebstoreSearchPageUrl(const std::string& query) {
47   return GURL(GetWebstoreLaunchURL() + "/search/" +
48               net::EscapeQueryParamValue(query, false));
49 }
50 
51 const char kGalleryUpdateHttpsUrl[] =
52     "https://clients2.google.com/service/update2/crx";
53 // TODO(battre): Delete the HTTP URL once the blacklist is downloaded via HTTPS.
54 const char kExtensionBlocklistUrlPrefix[] =
55     "http://www.gstatic.com/chrome/extensions/blacklist";
56 const char kExtensionBlocklistHttpsUrlPrefix[] =
57     "https://www.gstatic.com/chrome/extensions/blacklist";
58 
GetWebstoreUpdateUrl()59 GURL GetWebstoreUpdateUrl() {
60   CommandLine* cmdline = CommandLine::ForCurrentProcess();
61   if (cmdline->HasSwitch(switches::kAppsGalleryUpdateURL))
62     return GURL(cmdline->GetSwitchValueASCII(switches::kAppsGalleryUpdateURL));
63   else
64     return GetDefaultWebstoreUpdateUrl();
65 }
66 
GetDefaultWebstoreUpdateUrl()67 GURL GetDefaultWebstoreUpdateUrl() {
68   return GURL(kGalleryUpdateHttpsUrl);
69 }
70 
IsWebstoreUpdateUrl(const GURL & update_url)71 bool IsWebstoreUpdateUrl(const GURL& update_url) {
72   GURL store_url = GetWebstoreUpdateUrl();
73   if (update_url == store_url) {
74     return true;
75   } else {
76     return (update_url.host() == store_url.host() &&
77             update_url.path() == store_url.path());
78   }
79 }
80 
IsBlacklistUpdateUrl(const GURL & url)81 bool IsBlacklistUpdateUrl(const GURL& url) {
82   // The extension blacklist URL is returned from the update service and
83   // therefore not determined by Chromium. If the location of the blacklist file
84   // ever changes, we need to update this function. A DCHECK in the
85   // ExtensionUpdater ensures that we notice a change. This is the full URL
86   // of a blacklist:
87   // http://www.gstatic.com/chrome/extensions/blacklist/l_0_0_0_7.txt
88   return StartsWithASCII(url.spec(), kExtensionBlocklistUrlPrefix, true) ||
89       StartsWithASCII(url.spec(), kExtensionBlocklistHttpsUrlPrefix, true);
90 }
91 
92 const char kGalleryBrowsePrefix[] = "https://chrome.google.com/webstore";
93 
94 const char kWebstoreSourceField[] = "utm_source";
95 
96 const char kLaunchSourceAppList[] = "chrome-app-launcher";
97 const char kLaunchSourceAppListSearch[] = "chrome-app-launcher-search";
98 const char kLaunchSourceAppListInfoDialog[] = "chrome-app-launcher-info-dialog";
99 
100 }  // namespace extension_urls
101 
102 namespace extension_misc {
103 
104 const char kBookmarkManagerId[] = "eemcgdkfndhakfknompkggombfjjjeno";
105 const char kChromeAppId[] = "mgndgikekgjfcpckkfioiadnlibdjbkf";
106 const char kCloudPrintAppId[] = "mfehgcgbbipciphmccgaenjidiccnmng";
107 const char kEasyUnlockAppId[] = "mkaemigholebcgchlkbankmihknojeak";
108 const char kEnterpriseWebStoreAppId[] = "afchcafgojfnemjkcbhfekplkmjaldaa";
109 const char kGmailAppId[] = "pjkljhegncpnkpknbcohdijeoejaedia";
110 const char kGoogleDocAppId[] = "aohghmighlieiainnegkcijnfilokake";
111 const char kGooglePlayMusicAppId[] = "icppfcnhkcmnfdhfhphakoifcfokfdhg";
112 const char kGoogleSearchAppId[] = "coobgpohoikkiipiblmjeljniedjpjpf";
113 const char kGoogleSheetsAppId[] = "felcaaldnbdncclmgdcncolpebgiejap";
114 const char kGoogleSlidesAppId[] = "aapocclcgogkmnckokdopfmhonfmgoek";
115 const char kHTermAppId[] = "pnhechapfaindjhompbnflcldabbghjo";
116 const char kHTermDevAppId[] = "okddffdblfhhnmhodogpojmfkjmhinfp";
117 const char kIdentityApiUiAppId[] = "ahjaciijnoiaklcomgnblndopackapon";
118 const char kCroshBuiltinAppId[] = "nkoccljplnhpfnfiajclkommnmllphnl";
119 const char kHotwordExtensionId[] = "bepbmhgboaologfdajaanbcjmnhjmhfn";
120 const char kPdfExtensionId[] = "mhjfbmdgcfjbbpaeojofohoefgiehjai";
121 const char kQuickOfficeComponentExtensionId[] =
122     "bpmcpldpdmajfigpchkicefoigmkfalc";
123 const char kQuickOfficeInternalExtensionId[] =
124     "ehibbfinohgbchlgdbfpikodjaojhccn";
125 const char kQuickOfficeExtensionId[] = "gbkeegbaiigmenfmjfclcdgdpimamgkj";
126 const char kSettingsAppId[] = "ennkphjdgehloodpbhlhldgbnhmacadg";
127 const char kStreamsPrivateTestExtensionId[] =
128     "oickdpebdnfbgkcaoklfcdhjniefkcji";
129 const char kWebStoreAppId[] = "ahfgeienlihckogmohjhadlkjgocpleb";
130 const char kYoutubeAppId[] = "blpcfgokakmgnkcojhhkbfbldkacnbeo";
131 const char kInAppPaymentsSupportAppId[] = "nmmhkkegccagdldgiimedpiccmgmieda";
132 
133 const char kAppLaunchHistogram[] = "Extensions.AppLaunch";
134 const char kPlatformAppLaunchHistogram[] = "Apps.AppLaunch";
135 #if defined(OS_CHROMEOS)
136 // The extension id for the built-in component extension.
137 const char kChromeVoxExtensionId[] =
138     "mndnfokpggljbaajbnioimlmbfngpief";
139 const char kChromeVoxExtensionPath[] = "chromeos/chromevox";
140 const char kChromeVoxManifestFilename[] = "manifest.json";
141 const char kChromeVoxGuestManifestFilename[] = "manifest_guest.json";
142 const char kBrailleImeExtensionId[] =
143     "jddehjeebkoimngcbdkaahpobgicbffp";
144 const char kBrailleImeExtensionPath[] =
145     "chromeos/braille_ime";
146 const char kBrailleImeEngineId[] =
147     "_comp_ime_jddehjeebkoimngcbdkaahpobgicbffpbraille";
148 const char kConnectivityDiagnosticsPath[] =
149     "/usr/share/chromeos-assets/connectivity_diagnostics";
150 const char kConnectivityDiagnosticsKioskPath[] =
151     "/usr/share/chromeos-assets/connectivity_diagnostics_kiosk";
152 const char kConnectivityDiagnosticsLauncherPath[] =
153     "/usr/share/chromeos-assets/connectivity_diagnostics_launcher";
154 const char kSpeechSynthesisExtensionPath[] =
155     "/usr/share/chromeos-assets/speech_synthesis/patts";
156 const char kSpeechSynthesisExtensionId[] =
157     "gjjabgpgjpampikjhjpfhneeoapjbjaf";
158 const char kWallpaperManagerId[] = "obklkkbkpaoaejdabbfldmcfplpdgolj";
159 const char kFirstRunDialogId[] = "jdgcneonijmofocbhmijhacgchbihela";
160 #else
161 // The extension id for the web store extension.
162 const char kChromeVoxExtensionId[] =
163     "kgejglhpjiefppelpmljglcjbhoiplfn";
164 #endif
165 
166 const char kAppStateNotInstalled[] = "not_installed";
167 const char kAppStateInstalled[] = "installed";
168 const char kAppStateDisabled[] = "disabled";
169 const char kAppStateRunning[] = "running";
170 const char kAppStateCannotRun[] = "cannot_run";
171 const char kAppStateReadyToRun[] = "ready_to_run";
172 
173 const char kMediaFileSystemPathPart[] = "_";
174 
175 const uint8 kWebstoreSignaturesPublicKey[] = {
176     0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
177     0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00,
178     0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0x8f, 0xfb, 0xbf,
179     0x5c, 0x37, 0x63, 0x94, 0x3c, 0xb0, 0xee, 0x01, 0xc4, 0xb5, 0xa6, 0x9a,
180     0xb1, 0x9f, 0x46, 0x74, 0x6f, 0x16, 0x38, 0xa0, 0x32, 0x27, 0x35, 0xdd,
181     0xf0, 0x71, 0x6b, 0x0e, 0xdc, 0xf6, 0x25, 0xcb, 0xb2, 0xed, 0xea, 0xfb,
182     0x32, 0xd5, 0xaf, 0x1e, 0x03, 0x43, 0x03, 0x46, 0xf0, 0xa7, 0x39, 0xdb,
183     0x23, 0x96, 0x1d, 0x65, 0xe5, 0x78, 0x51, 0xf0, 0x84, 0xb0, 0x0e, 0x12,
184     0xac, 0x0e, 0x5b, 0xdc, 0xc9, 0xd6, 0x4c, 0x7c, 0x00, 0xd5, 0xb8, 0x1b,
185     0x88, 0x33, 0x3e, 0x2f, 0xda, 0xeb, 0xaa, 0xf7, 0x1a, 0x75, 0xc2, 0xae,
186     0x3a, 0x54, 0xde, 0x37, 0x8f, 0x10, 0xd2, 0x28, 0xe6, 0x84, 0x79, 0x4d,
187     0x15, 0xb4, 0xf3, 0xbd, 0x3f, 0x56, 0xd3, 0x3c, 0x3f, 0x18, 0xab, 0xfc,
188     0x2e, 0x05, 0xc0, 0x1e, 0x08, 0x31, 0xb6, 0x61, 0xd0, 0xfd, 0x9f, 0x4f,
189     0x3f, 0x64, 0x0d, 0x17, 0x93, 0xbc, 0xad, 0x41, 0xc7, 0x48, 0xbe, 0x00,
190     0x27, 0xa8, 0x4d, 0x70, 0x42, 0x92, 0x05, 0x54, 0xa6, 0x6d, 0xb8, 0xde,
191     0x56, 0x6e, 0x20, 0x49, 0x70, 0xee, 0x10, 0x3e, 0x6b, 0xd2, 0x7c, 0x31,
192     0xbd, 0x1b, 0x6e, 0xa4, 0x3c, 0x46, 0x62, 0x9f, 0x08, 0x66, 0x93, 0xf9,
193     0x2a, 0x51, 0x31, 0xa8, 0xdb, 0xb5, 0x9d, 0xb9, 0x0f, 0x73, 0xe8, 0xa0,
194     0x09, 0x32, 0x01, 0xe9, 0x7b, 0x2a, 0x8a, 0x36, 0xa0, 0xcf, 0x17, 0xb0,
195     0x50, 0x70, 0x9d, 0xa2, 0xf9, 0xa4, 0x6f, 0x62, 0x4d, 0xb6, 0xc9, 0x31,
196     0xfc, 0xf3, 0x08, 0x12, 0xff, 0x93, 0xbd, 0x62, 0x31, 0xd8, 0x1c, 0xea,
197     0x1a, 0x9e, 0xf5, 0x81, 0x28, 0x7f, 0x75, 0x5e, 0xd2, 0x27, 0x7a, 0xc2,
198     0x96, 0xf5, 0x9d, 0xdb, 0x18, 0xfc, 0x76, 0xdc, 0x46, 0xf0, 0x57, 0xc0,
199     0x58, 0x34, 0xc8, 0x22, 0x2d, 0x2a, 0x65, 0x75, 0xa7, 0xd9, 0x08, 0x62,
200     0xcd, 0x02, 0x03, 0x01, 0x00, 0x01};
201 
202 const int kWebstoreSignaturesPublicKeySize =
203     arraysize(kWebstoreSignaturesPublicKey);
204 
205 }  // namespace extension_misc
206