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