extension_constants.cc revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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 "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 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 = net::AppendQueryParameter(url, "_wi", action); 42 url = 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 kKioskEnabledKey[] = "kioskEnabled"; 115 const char kOfflineEnabledKey[] = "offlineEnabled"; 116 const char kOptionsUrlKey[] = "optionsUrl"; 117 const char kDetailsUrlKey[] = "detailsUrl"; 118 const char kVersionKey[] = "version"; 119 const char kPackagedAppKey[] = "packagedApp"; 120 121} // namespace extension_filenames 122 123namespace extension_misc { 124const char kBookmarkManagerId[] = "eemcgdkfndhakfknompkggombfjjjeno"; 125const char kCitrixReceiverAppId[] = "haiffjcadagjlijoggckpgfnoeiflnem"; 126const char kCitrixReceiverAppBetaId[] = "gnedhmakppccajfpfiihfcdlnpgomkcf"; 127const char kCitrixReceiverAppDevId[] = "fjcibdnjlbfnbfdjneajpipnlcppleek"; 128const char kEnterpriseWebStoreAppId[] = "afchcafgojfnemjkcbhfekplkmjaldaa"; 129const char kHTermAppId[] = "pnhechapfaindjhompbnflcldabbghjo"; 130const char kHTermDevAppId[] = "okddffdblfhhnmhodogpojmfkjmhinfp"; 131const char kCroshBuiltinAppId[] = "nkoccljplnhpfnfiajclkommnmllphnl"; 132const char kQuickOfficeComponentExtensionId[] = 133 "bpmcpldpdmajfigpchkicefoigmkfalc"; 134const char kQuickOfficeDevExtensionId[] = "ionpfmkccalenbmnddpbmocokhaknphg"; 135const char kQuickOfficeExtensionId[] = "gbkeegbaiigmenfmjfclcdgdpimamgkj"; 136const char kStreamsPrivateTestExtensionId[] = 137 "oickdpebdnfbgkcaoklfcdhjniefkcji"; 138const char kWebStoreAppId[] = "ahfgeienlihckogmohjhadlkjgocpleb"; 139const char kCloudPrintAppId[] = "mfehgcgbbipciphmccgaenjidiccnmng"; 140const char kChromeAppId[] = "mgndgikekgjfcpckkfioiadnlibdjbkf"; 141const char kSettingsAppId[] = "ennkphjdgehloodpbhlhldgbnhmacadg"; 142const char kAppLaunchHistogram[] = "Extensions.AppLaunch"; 143const char kPlatformAppLaunchHistogram[] = "Apps.AppLaunch"; 144#if defined(OS_CHROMEOS) 145const char kChromeVoxExtensionPath[] = 146 "/usr/share/chromeos-assets/accessibility/extensions/access_chromevox"; 147const char kSpeechSynthesisExtensionPath[] = 148 "/usr/share/chromeos-assets/speech_synthesis/patts"; 149const char kSpeechSynthesisExtensionId[] = 150 "gjjabgpgjpampikjhjpfhneeoapjbjaf"; 151const char kWallpaperManagerId[] = "obklkkbkpaoaejdabbfldmcfplpdgolj"; 152#endif 153 154const char kAppStateNotInstalled[] = "not_installed"; 155const char kAppStateInstalled[] = "installed"; 156const char kAppStateDisabled[] = "disabled"; 157const char kAppStateRunning[] = "running"; 158const char kAppStateCannotRun[] = "cannot_run"; 159const char kAppStateReadyToRun[] = "ready_to_run"; 160 161const char kMediaFileSystemPathPart[] = "_"; 162 163const int kExtensionIconSizes[] = { 164 EXTENSION_ICON_GIGANTOR, // 512 165 EXTENSION_ICON_EXTRA_LARGE, // 256 166 EXTENSION_ICON_LARGE, // 128 167 EXTENSION_ICON_MEDIUM, // 48 168 EXTENSION_ICON_SMALL, // 32 169 EXTENSION_ICON_SMALLISH, // 24 170 EXTENSION_ICON_BITTY // 16 171}; 172 173const size_t kNumExtensionIconSizes = 174 arraysize(kExtensionIconSizes); 175 176const int kExtensionActionIconSizes[] = { 177 EXTENSION_ICON_ACTION, // 19, 178 2 * EXTENSION_ICON_ACTION // 38 179}; 180 181const size_t kNumExtensionActionIconSizes = 182 arraysize(kExtensionActionIconSizes); 183 184const int kScriptBadgeIconSizes[] = { 185 EXTENSION_ICON_BITTY, // 16 186 2 * EXTENSION_ICON_BITTY // 32 187}; 188 189const size_t kNumScriptBadgeIconSizes = 190 arraysize(kScriptBadgeIconSizes); 191 192} // namespace extension_misc 193