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