• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/memory/scoped_ptr.h"
15 #include "base/strings/string16.h"
16 #include "base/version.h"
17 #include "chrome/installer/util/util_constants.h"
18 
19 #if defined(OS_WIN)
20 #include <windows.h>  // NOLINT
21 #endif
22 
23 class AppRegistrationData;
24 
25 class BrowserDistribution {
26  public:
27   enum Type {
28     CHROME_BROWSER,
29     CHROME_FRAME,
30     CHROME_BINARIES,
31     CHROME_APP_HOST,
32     NUM_TYPES
33   };
34 
35   enum ShortcutType {
36     SHORTCUT_CHROME,
37     SHORTCUT_CHROME_ALTERNATE,
38     SHORTCUT_APP_LAUNCHER
39   };
40 
41   enum Subfolder {
42     SUBFOLDER_CHROME,
43     SUBFOLDER_APPS,
44   };
45 
46   enum DefaultBrowserControlPolicy {
47     DEFAULT_BROWSER_UNSUPPORTED,
48     DEFAULT_BROWSER_OS_CONTROL_ONLY,
49     DEFAULT_BROWSER_FULL_CONTROL
50   };
51 
52   virtual ~BrowserDistribution();
53 
54   static BrowserDistribution* GetDistribution();
55 
56   static BrowserDistribution* GetSpecificDistribution(Type type);
57 
GetType()58   Type GetType() const { return type_; }
59 
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;
66 
67   virtual void DoPostUninstallOperations(
68       const Version& version,
69       const base::FilePath& local_data_path,
70       const base::string16& distribution_data);
71 
72   // Returns the GUID to be used when registering for Active Setup.
73   virtual base::string16 GetActiveSetupGuid();
74 
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();
81 
82   // Returns the localized display name of this distribution.
83   virtual base::string16 GetDisplayName();
84 
85   // Returns the localized name of the shortcut identified by |shortcut_type|
86   // for this distribution.
87   virtual base::string16 GetShortcutName(ShortcutType shortcut_type);
88 
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);
92 
93   // Returns the executable filename (not path) that contains the product icon.
94   virtual base::string16 GetIconFilename();
95 
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);
101 
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();
107 
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();
116 
117   // Returns the Browser ProgId description.
118   virtual base::string16 GetBrowserProgIdDesc();
119 
120   virtual base::string16 GetInstallSubDir();
121 
122   virtual base::string16 GetPublisherName();
123 
124   virtual base::string16 GetAppDescription();
125 
126   virtual base::string16 GetLongAppDescription();
127 
128   virtual std::string GetSafeBrowsingName();
129 
130   virtual std::string GetNetworkStatsServer() const;
131 
132 #if defined(OS_WIN)
133   virtual base::string16 GetDistributionData(HKEY root_key);
134 #endif
135 
136   virtual base::string16 GetUninstallLinkName();
137 
138   virtual base::string16 GetUninstallRegPath();
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   BrowserDistribution(Type type, scoped_ptr<AppRegistrationData> app_reg_data);
168 
169   template<class DistributionClass>
170   static BrowserDistribution* GetOrCreateBrowserDistribution(
171       BrowserDistribution** dist);
172 
173   const Type type_;
174 
175   scoped_ptr<AppRegistrationData> app_reg_data_;
176 
177  private:
178   BrowserDistribution();
179 
180   DISALLOW_COPY_AND_ASSIGN(BrowserDistribution);
181 };
182 
183 #endif  // CHROME_INSTALLER_UTIL_BROWSER_DISTRIBUTION_H_
184