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