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 // This file declares a class that contains various method related to branding. 6 7 #ifndef CHROME_INSTALLER_UTIL_BROWSER_DISTRIBUTION_H_ 8 #define CHROME_INSTALLER_UTIL_BROWSER_DISTRIBUTION_H_ 9 10 #include <string> 11 12 #include "base/basictypes.h" 13 #include "base/files/file_path.h" 14 #include "base/strings/string16.h" 15 #include "base/version.h" 16 #include "chrome/installer/util/util_constants.h" 17 18 #if defined(OS_WIN) 19 #include <windows.h> // NOLINT 20 #endif 21 22 class BrowserDistribution { 23 public: 24 enum Type { 25 CHROME_BROWSER, 26 CHROME_FRAME, 27 CHROME_BINARIES, 28 CHROME_APP_HOST, 29 NUM_TYPES 30 }; 31 32 enum ShortcutType { 33 SHORTCUT_CHROME, 34 SHORTCUT_CHROME_ALTERNATE, 35 SHORTCUT_APP_LAUNCHER 36 }; 37 38 enum Subfolder { 39 SUBFOLDER_CHROME, 40 SUBFOLDER_APPS, 41 }; 42 43 enum DefaultBrowserControlPolicy { 44 DEFAULT_BROWSER_UNSUPPORTED, 45 DEFAULT_BROWSER_OS_CONTROL_ONLY, 46 DEFAULT_BROWSER_FULL_CONTROL 47 }; 48 49 virtual ~BrowserDistribution() {} 50 51 static BrowserDistribution* GetDistribution(); 52 53 static BrowserDistribution* GetSpecificDistribution(Type type); 54 55 Type GetType() const { return type_; } 56 57 virtual void DoPostUninstallOperations(const Version& version, 58 const base::FilePath& local_data_path, 59 const string16& distribution_data); 60 61 // Returns the GUID to be used when registering for Active Setup. 62 virtual string16 GetActiveSetupGuid(); 63 64 virtual string16 GetAppGuid(); 65 66 // Returns the unsuffixed application name of this program. 67 // This is the base of the name registered with Default Programs on Windows. 68 // IMPORTANT: This should only be called by the installer which needs to make 69 // decisions on the suffixing of the upcoming install, not by external callers 70 // at run-time. 71 virtual string16 GetBaseAppName(); 72 73 // Returns the localized display name of this distribution. 74 virtual string16 GetDisplayName(); 75 76 // Returns the localized name of the shortcut identified by |shortcut_type| 77 // for this distribution. 78 virtual string16 GetShortcutName(ShortcutType shortcut_type); 79 80 // Returns the index of the icon for the product identified by 81 // |shortcut_type|, inside the file specified by GetIconFilename(). 82 virtual int GetIconIndex(ShortcutType shortcut_type); 83 84 // Returns the executable filename (not path) that contains the product icon. 85 virtual string16 GetIconFilename(); 86 87 // Returns the localized name of the subfolder in the Start Menu identified by 88 // |subfolder_type| that this distribution should create shortcuts in. For 89 // SUBFOLDER_CHROME this returns GetShortcutName(SHORTCUT_CHROME). 90 virtual string16 GetStartMenuShortcutSubfolder(Subfolder subfolder_type); 91 92 // Returns the unsuffixed appid of this program. 93 // The AppUserModelId is a property of Windows programs. 94 // IMPORTANT: This should only be called by ShellUtil::GetAppId as the appid 95 // should be suffixed in all scenarios. 96 virtual string16 GetBaseAppId(); 97 98 // Returns the Browser ProgId prefix (e.g. ChromeHTML, ChromiumHTM, etc...). 99 // The full id is of the form |prefix|.|suffix| and is limited to a maximum 100 // length of 39 characters including null-terminator. See 101 // http://msdn.microsoft.com/library/aa911706.aspx for details. We define 102 // |suffix| as a fixed-length 26-character alphanumeric identifier, therefore 103 // the return value of this function must have a maximum length of 104 // 39 - 1(null-term) - 26(|suffix|) - 1(dot separator) = 11 characters. 105 virtual string16 GetBrowserProgIdPrefix(); 106 107 // Returns the Browser ProgId description. 108 virtual string16 GetBrowserProgIdDesc(); 109 110 virtual string16 GetInstallSubDir(); 111 112 virtual string16 GetPublisherName(); 113 114 virtual string16 GetAppDescription(); 115 116 virtual string16 GetLongAppDescription(); 117 118 virtual std::string GetSafeBrowsingName(); 119 120 virtual string16 GetStateKey(); 121 122 virtual string16 GetStateMediumKey(); 123 124 virtual std::string GetNetworkStatsServer() const; 125 126 virtual std::string GetHttpPipeliningTestServer() const; 127 128 #if defined(OS_WIN) 129 virtual string16 GetDistributionData(HKEY root_key); 130 #endif 131 132 virtual string16 GetUninstallLinkName(); 133 134 virtual string16 GetUninstallRegPath(); 135 136 virtual string16 GetVersionKey(); 137 138 // Returns an enum specifying the different ways in which this distribution 139 // is allowed to be set as default. 140 virtual DefaultBrowserControlPolicy GetDefaultBrowserControlPolicy(); 141 142 virtual bool CanCreateDesktopShortcuts(); 143 144 virtual bool GetChromeChannel(string16* channel); 145 146 // Returns true if this distribution includes a DelegateExecute verb handler, 147 // and provides the CommandExecuteImpl class UUID if |handler_class_uuid| is 148 // non-NULL. 149 virtual bool GetCommandExecuteImplClsid(string16* handler_class_uuid); 150 151 // Returns true if this distribution uses app_host.exe to run platform apps. 152 virtual bool AppHostIsSupported(); 153 154 virtual void UpdateInstallStatus(bool system_install, 155 installer::ArchiveType archive_type, 156 installer::InstallStatus install_status); 157 158 // Returns true if this distribution should set the Omaha experiment_labels 159 // registry value. 160 virtual bool ShouldSetExperimentLabels(); 161 162 virtual bool HasUserExperiments(); 163 164 protected: 165 explicit BrowserDistribution(Type type); 166 167 template<class DistributionClass> 168 static BrowserDistribution* GetOrCreateBrowserDistribution( 169 BrowserDistribution** dist); 170 171 const Type type_; 172 173 private: 174 BrowserDistribution(); 175 176 DISALLOW_COPY_AND_ASSIGN(BrowserDistribution); 177 }; 178 179 #endif // CHROME_INSTALLER_UTIL_BROWSER_DISTRIBUTION_H_ 180