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"; 94 95} // namespace extension_urls 96 97namespace extension_misc { 98 99const char kBookmarkManagerId[] = "eemcgdkfndhakfknompkggombfjjjeno"; 100const char kChromeAppId[] = "mgndgikekgjfcpckkfioiadnlibdjbkf"; 101const char kCloudPrintAppId[] = "mfehgcgbbipciphmccgaenjidiccnmng"; 102const char kEnterpriseWebStoreAppId[] = "afchcafgojfnemjkcbhfekplkmjaldaa"; 103const char kGmailAppId[] = "pjkljhegncpnkpknbcohdijeoejaedia"; 104const char kGoogleDocAppId[] = "aohghmighlieiainnegkcijnfilokake"; 105const char kGooglePlayMusicAppId[] = "icppfcnhkcmnfdhfhphakoifcfokfdhg"; 106const char kGoogleSearchAppId[] = "coobgpohoikkiipiblmjeljniedjpjpf"; 107const char kGoogleSheetsAppId[] = "felcaaldnbdncclmgdcncolpebgiejap"; 108const char kGoogleSlidesAppId[] = "aapocclcgogkmnckokdopfmhonfmgoek"; 109const char kHTermAppId[] = "pnhechapfaindjhompbnflcldabbghjo"; 110const char kHTermDevAppId[] = "okddffdblfhhnmhodogpojmfkjmhinfp"; 111const char kIdentityApiUiAppId[] = "ahjaciijnoiaklcomgnblndopackapon"; 112const char kCroshBuiltinAppId[] = "nkoccljplnhpfnfiajclkommnmllphnl"; 113const char kPdfExtensionId[] = "mhjfbmdgcfjbbpaeojofohoefgiehjai"; 114const char kQuickOfficeComponentExtensionId[] = 115 "bpmcpldpdmajfigpchkicefoigmkfalc"; 116const char kQuickOfficeDevExtensionId[] = "ionpfmkccalenbmnddpbmocokhaknphg"; 117const char kQuickOfficeExtensionId[] = "gbkeegbaiigmenfmjfclcdgdpimamgkj"; 118const char kSettingsAppId[] = "ennkphjdgehloodpbhlhldgbnhmacadg"; 119const char kStreamsPrivateTestExtensionId[] = 120 "oickdpebdnfbgkcaoklfcdhjniefkcji"; 121const char kWebStoreAppId[] = "ahfgeienlihckogmohjhadlkjgocpleb"; 122const char kYoutubeAppId[] = "blpcfgokakmgnkcojhhkbfbldkacnbeo"; 123const char kInAppPaymentsSupportAppId[] = "nmmhkkegccagdldgiimedpiccmgmieda"; 124const char kTipsAndTricksAppId[] = "hkhhlkdconhgemhegnplaldnmnmkaemd"; 125 126const char kAppLaunchHistogram[] = "Extensions.AppLaunch"; 127const char kPlatformAppLaunchHistogram[] = "Apps.AppLaunch"; 128#if defined(OS_CHROMEOS) 129const char kChromeVoxExtensionPath[] = "chromeos/chromevox"; 130// The extension id for the built-in component extension. 131const char kChromeVoxExtensionId[] = 132 "mndnfokpggljbaajbnioimlmbfngpief"; 133const char kConnectivityDiagnosticsPath[] = 134 "/usr/share/chromeos-assets/connectivity_diagnostics"; 135const char kConnectivityDiagnosticsLauncherPath[] = 136 "/usr/share/chromeos-assets/connectivity_diagnostics_launcher"; 137const char kSpeechSynthesisExtensionPath[] = 138 "/usr/share/chromeos-assets/speech_synthesis/patts"; 139const char kSpeechSynthesisExtensionId[] = 140 "gjjabgpgjpampikjhjpfhneeoapjbjaf"; 141const char kWallpaperManagerId[] = "obklkkbkpaoaejdabbfldmcfplpdgolj"; 142const char kFirstRunDialogId[] = "jdgcneonijmofocbhmijhacgchbihela"; 143#else 144// The extension id for the web store extension. 145const char kChromeVoxExtensionId[] = 146 "kgejglhpjiefppelpmljglcjbhoiplfn"; 147#endif 148 149const char kAppStateNotInstalled[] = "not_installed"; 150const char kAppStateInstalled[] = "installed"; 151const char kAppStateDisabled[] = "disabled"; 152const char kAppStateRunning[] = "running"; 153const char kAppStateCannotRun[] = "cannot_run"; 154const char kAppStateReadyToRun[] = "ready_to_run"; 155 156const char kMediaFileSystemPathPart[] = "_"; 157 158const 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 171const size_t kNumExtensionIconSizes = 172 arraysize(kExtensionIconSizes); 173 174const int kExtensionActionIconSizes[] = { 175 EXTENSION_ICON_ACTION, // 19, 176 2 * EXTENSION_ICON_ACTION // 38 177}; 178 179const size_t kNumExtensionActionIconSizes = 180 arraysize(kExtensionActionIconSizes); 181 182const int kScriptBadgeIconSizes[] = { 183 EXTENSION_ICON_BITTY, // 16 184 2 * EXTENSION_ICON_BITTY // 32 185}; 186 187const size_t kNumScriptBadgeIconSizes = 188 arraysize(kScriptBadgeIconSizes); 189 190} // namespace extension_misc 191