extension_constants.cc revision 5821806d5e7f356e8fa4b058a389a808ea183019
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/string_util.h" 12#include "chrome/common/chrome_switches.h" 13#include "chrome/common/net/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 GetWebstoreIntentQueryURL(const std::string& action, 36 const std::string& type) { 37 const char kIntentsCategoryPath[] = "category/collection/webintent_apps"; 38 39 GURL url(std::string(kGalleryBrowsePrefix) + "/"); 40 url = url.Resolve(kIntentsCategoryPath); 41 url = chrome_common_net::AppendQueryParameter(url, "_wi", action); 42 url = chrome_common_net::AppendQueryParameter(url, "_mt", type); 43 44 return url; 45} 46 47GURL GetWebstoreItemJsonDataURL(const std::string& extension_id) { 48 return GURL(GetWebstoreLaunchURL() + "/inlineinstall/detail/" + extension_id); 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 90} // namespace extension_urls 91 92namespace extension_filenames { 93 94const char kTempExtensionName[] = "CRX_INSTALL"; 95 96// The file to write our decoded images to, relative to the extension_path. 97const char kDecodedImagesFilename[] = "DECODED_IMAGES"; 98 99// The file to write our decoded message catalogs to, relative to the 100// extension_path. 101const char kDecodedMessageCatalogsFilename[] = "DECODED_MESSAGE_CATALOGS"; 102 103const char kGeneratedBackgroundPageFilename[] = 104 "_generated_background_page.html"; 105} 106 107// These must match the values expected by the chrome.management extension API. 108namespace extension_info_keys { 109 const char kDescriptionKey[] = "description"; 110 const char kEnabledKey[] = "enabled"; 111 const char kHomepageUrlKey[] = "homepageUrl"; 112 const char kIdKey[] = "id"; 113 const char kNameKey[] = "name"; 114 const char kOfflineEnabledKey[] = "offlineEnabled"; 115 const char kOptionsUrlKey[] = "optionsUrl"; 116 const char kDetailsUrlKey[] = "detailsUrl"; 117 const char kVersionKey[] = "version"; 118 const char kPackagedAppKey[] = "packagedApp"; 119 120} // namespace extension_filenames 121 122namespace extension_misc { 123const char kBookmarkManagerId[] = "eemcgdkfndhakfknompkggombfjjjeno"; 124const char kCitrixReceiverAppId[] = "haiffjcadagjlijoggckpgfnoeiflnem"; 125const char kCitrixReceiverAppBetaId[] = "gnedhmakppccajfpfiihfcdlnpgomkcf"; 126const char kCitrixReceiverAppDevId[] = "fjcibdnjlbfnbfdjneajpipnlcppleek"; 127const char kEnterpriseWebStoreAppId[] = "afchcafgojfnemjkcbhfekplkmjaldaa"; 128const char kHTermAppId[] = "pnhechapfaindjhompbnflcldabbghjo"; 129const char kHTermDevAppId[] = "okddffdblfhhnmhodogpojmfkjmhinfp"; 130const char kCroshBuiltinAppId[] = "nkoccljplnhpfnfiajclkommnmllphnl"; 131const char kWebStoreAppId[] = "ahfgeienlihckogmohjhadlkjgocpleb"; 132const char kCloudPrintAppId[] = "mfehgcgbbipciphmccgaenjidiccnmng"; 133const char kChromeAppId[] = "mgndgikekgjfcpckkfioiadnlibdjbkf"; 134const char kAppLaunchHistogram[] = "Extensions.AppLaunch"; 135#if defined(OS_CHROMEOS) 136const char kAccessExtensionPath[] = 137 "/usr/share/chromeos-assets/accessibility/extensions"; 138const char kChromeVoxDirectoryName[] = "access_chromevox"; 139const char kWallpaperManagerId[] = "obklkkbkpaoaejdabbfldmcfplpdgolj"; 140#endif 141 142const char kAppStateNotInstalled[] = "not_installed"; 143const char kAppStateInstalled[] = "installed"; 144const char kAppStateDisabled[] = "disabled"; 145const char kAppStateRunning[] = "running"; 146const char kAppStateCannotRun[] = "cannot_run"; 147const char kAppStateReadyToRun[] = "ready_to_run"; 148 149const char kMediaFileSystemPathPart[] = "_"; 150 151const char kAppNotificationsIncognitoError[] = 152 "This API is not accessible by 'split' mode " 153 "extensions in incognito windows."; 154 155const int kExtensionIconSizes[] = { 156 EXTENSION_ICON_GIGANTOR, // 512 157 EXTENSION_ICON_EXTRA_LARGE, // 256 158 EXTENSION_ICON_LARGE, // 128 159 EXTENSION_ICON_MEDIUM, // 48 160 EXTENSION_ICON_SMALL, // 32 161 EXTENSION_ICON_SMALLISH, // 24 162 EXTENSION_ICON_BITTY // 16 163}; 164 165const size_t kNumExtensionIconSizes = 166 arraysize(kExtensionIconSizes); 167 168const int kExtensionActionIconSizes[] = { 169 EXTENSION_ICON_ACTION, // 19, 170 2 * EXTENSION_ICON_ACTION // 38 171}; 172 173const size_t kNumExtensionActionIconSizes = 174 arraysize(kExtensionActionIconSizes); 175 176const int kScriptBadgeIconSizes[] = { 177 EXTENSION_ICON_BITTY, // 16 178 2 * EXTENSION_ICON_BITTY // 32 179}; 180 181const size_t kNumScriptBadgeIconSizes = 182 arraysize(kScriptBadgeIconSizes); 183 184} // namespace extension_misc 185