Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / common / extensions / extension_constants.cc
blob6e8b3cf34e334aa217f620221b39ee3d1edb94fe
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.
5 #include "chrome/common/extensions/extension_constants.h"
7 #include <vector>
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"
15 namespace extension_urls {
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;
27 std::string GetExtensionGalleryURL() {
28 return GetWebstoreLaunchURL() + "/category/extensions";
31 std::string GetWebstoreItemDetailURLPrefix() {
32 return GetWebstoreLaunchURL() + "/detail/";
35 GURL GetWebstoreItemJsonDataURL(const std::string& extension_id) {
36 return GURL(GetWebstoreLaunchURL() + "/inlineinstall/detail/" + extension_id);
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;
46 GURL GetWebstoreSearchPageUrl(const std::string& query) {
47 return GURL(GetWebstoreLaunchURL() + "/search/" +
48 net::EscapeQueryParamValue(query, false));
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";
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);
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());
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);
88 const char kGalleryBrowsePrefix[] = "https://chrome.google.com/webstore";
90 const char kWebstoreSourceField[] = "utm_source";
92 const char kLaunchSourceAppList[] = "chrome-app-launcher";
93 const char kLaunchSourceAppListSearch[] = "chrome-app-launcher-search";
95 } // namespace extension_urls
97 namespace extension_misc {
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";
125 const char kAppLaunchHistogram[] = "Extensions.AppLaunch";
126 const char kPlatformAppLaunchHistogram[] = "Apps.AppLaunch";
127 #if defined(OS_CHROMEOS)
128 const char kChromeVoxExtensionPath[] = "chromeos/chromevox";
129 // The extension id for the built-in component extension.
130 const char kChromeVoxExtensionId[] =
131 "mndnfokpggljbaajbnioimlmbfngpief";
132 const char kConnectivityDiagnosticsPath[] =
133 "/usr/share/chromeos-assets/connectivity_diagnostics";
134 const char kConnectivityDiagnosticsLauncherPath[] =
135 "/usr/share/chromeos-assets/connectivity_diagnostics_launcher";
136 const char kSpeechSynthesisExtensionPath[] =
137 "/usr/share/chromeos-assets/speech_synthesis/patts";
138 const char kSpeechSynthesisExtensionId[] =
139 "gjjabgpgjpampikjhjpfhneeoapjbjaf";
140 const char kHighQuality_en_US_ExtensionId[] =
141 "efdojdlmjknacnljjdedapanceanigkh";
142 const char kWallpaperManagerId[] = "obklkkbkpaoaejdabbfldmcfplpdgolj";
143 const char kFirstRunDialogId[] = "jdgcneonijmofocbhmijhacgchbihela";
144 #else
145 // The extension id for the web store extension.
146 const char kChromeVoxExtensionId[] =
147 "kgejglhpjiefppelpmljglcjbhoiplfn";
148 #endif
150 const char kAppStateNotInstalled[] = "not_installed";
151 const char kAppStateInstalled[] = "installed";
152 const char kAppStateDisabled[] = "disabled";
153 const char kAppStateRunning[] = "running";
154 const char kAppStateCannotRun[] = "cannot_run";
155 const char kAppStateReadyToRun[] = "ready_to_run";
157 const char kMediaFileSystemPathPart[] = "_";
159 const 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
172 const size_t kNumExtensionIconSizes =
173 arraysize(kExtensionIconSizes);
175 const int kExtensionActionIconSizes[] = {
176 EXTENSION_ICON_ACTION, // 19,
177 2 * EXTENSION_ICON_ACTION // 38
180 const size_t kNumExtensionActionIconSizes =
181 arraysize(kExtensionActionIconSizes);
183 const int kScriptBadgeIconSizes[] = {
184 EXTENSION_ICON_BITTY, // 16
185 2 * EXTENSION_ICON_BITTY // 32
188 const size_t kNumScriptBadgeIconSizes =
189 arraysize(kScriptBadgeIconSizes);
191 } // namespace extension_misc