extension_constants.cc revision a36e5920737c6adbddd3e43b760e5de8431db6e0
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 kConnectivityDiagnosticsLauncherPath[] = 131 "/usr/share/chromeos-assets/connectivity_diagnostics_launcher"; 132const char kSpeechSynthesisExtensionPath[] = 133 "/usr/share/chromeos-assets/speech_synthesis/patts"; 134const char kSpeechSynthesisExtensionId[] = 135 "gjjabgpgjpampikjhjpfhneeoapjbjaf"; 136const char kWallpaperManagerId[] = "obklkkbkpaoaejdabbfldmcfplpdgolj"; 137#endif 138 139const char kAppStateNotInstalled[] = "not_installed"; 140const char kAppStateInstalled[] = "installed"; 141const char kAppStateDisabled[] = "disabled"; 142const char kAppStateRunning[] = "running"; 143const char kAppStateCannotRun[] = "cannot_run"; 144const char kAppStateReadyToRun[] = "ready_to_run"; 145 146const char kMediaFileSystemPathPart[] = "_"; 147 148const int kExtensionIconSizes[] = { 149 EXTENSION_ICON_GIGANTOR, // 512 150 EXTENSION_ICON_EXTRA_LARGE, // 256 151 EXTENSION_ICON_LARGE, // 128 152 EXTENSION_ICON_MEDIUM, // 48 153 EXTENSION_ICON_SMALL, // 32 154 EXTENSION_ICON_SMALLISH, // 24 155 EXTENSION_ICON_BITTY, // 16 156 // Additional 2x resources to load. 157 2 * EXTENSION_ICON_MEDIUM, // 96 158 2 * EXTENSION_ICON_SMALL // 64 159}; 160 161const size_t kNumExtensionIconSizes = 162 arraysize(kExtensionIconSizes); 163 164const int kExtensionActionIconSizes[] = { 165 EXTENSION_ICON_ACTION, // 19, 166 2 * EXTENSION_ICON_ACTION // 38 167}; 168 169const size_t kNumExtensionActionIconSizes = 170 arraysize(kExtensionActionIconSizes); 171 172const int kScriptBadgeIconSizes[] = { 173 EXTENSION_ICON_BITTY, // 16 174 2 * EXTENSION_ICON_BITTY // 32 175}; 176 177const size_t kNumScriptBadgeIconSizes = 178 arraysize(kScriptBadgeIconSizes); 179 180} // namespace extension_misc 181