Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / chrome / installer / util / browser_distribution.h
blobf4b187cfd607e1415b63be70dd06dbcadf6c2a9e
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 NUM_TYPES
34 enum ShortcutType {
35 SHORTCUT_CHROME,
36 SHORTCUT_CHROME_ALTERNATE,
37 SHORTCUT_APP_LAUNCHER
40 enum Subfolder {
41 SUBFOLDER_CHROME,
42 SUBFOLDER_APPS,
45 enum DefaultBrowserControlPolicy {
46 DEFAULT_BROWSER_UNSUPPORTED,
47 DEFAULT_BROWSER_OS_CONTROL_ONLY,
48 DEFAULT_BROWSER_FULL_CONTROL
51 virtual ~BrowserDistribution();
53 static BrowserDistribution* GetDistribution();
55 static BrowserDistribution* GetSpecificDistribution(Type type);
57 Type GetType() const { return type_; }
59 // Getter and adaptors for the underlying |app_reg_data_|.
60 const AppRegistrationData& GetAppRegistrationData() const;
61 base::string16 GetAppGuid() const;
62 base::string16 GetStateKey() const;
63 base::string16 GetStateMediumKey() const;
64 base::string16 GetVersionKey() const;
66 virtual void DoPostUninstallOperations(
67 const Version& version,
68 const base::FilePath& local_data_path,
69 const base::string16& distribution_data);
71 // Returns the GUID to be used when registering for Active Setup.
72 virtual base::string16 GetActiveSetupGuid();
74 // Returns the unsuffixed application name of this program.
75 // This is the base of the name registered with Default Programs on Windows.
76 // IMPORTANT: This should only be called by the installer which needs to make
77 // decisions on the suffixing of the upcoming install, not by external callers
78 // at run-time.
79 virtual base::string16 GetBaseAppName();
81 // Returns the localized display name of this distribution.
82 virtual base::string16 GetDisplayName();
84 // Returns the localized name of the shortcut identified by |shortcut_type|
85 // for this distribution.
86 virtual base::string16 GetShortcutName(ShortcutType shortcut_type);
88 // Returns the index of the icon for the product identified by
89 // |shortcut_type|, inside the file specified by GetIconFilename().
90 virtual int GetIconIndex(ShortcutType shortcut_type);
92 // Returns the executable filename (not path) that contains the product icon.
93 virtual base::string16 GetIconFilename();
95 // Returns the localized name of the subfolder in the Start Menu identified by
96 // |subfolder_type| that this distribution should create shortcuts in. For
97 // SUBFOLDER_CHROME this returns GetShortcutName(SHORTCUT_CHROME).
98 virtual base::string16 GetStartMenuShortcutSubfolder(
99 Subfolder subfolder_type);
101 // Returns the unsuffixed appid of this program.
102 // The AppUserModelId is a property of Windows programs.
103 // IMPORTANT: This should only be called by ShellUtil::GetAppId as the appid
104 // should be suffixed in all scenarios.
105 virtual base::string16 GetBaseAppId();
107 // Returns the Browser ProgId prefix (e.g. ChromeHTML, ChromiumHTM, etc...).
108 // The full id is of the form |prefix|.|suffix| and is limited to a maximum
109 // length of 39 characters including null-terminator. See
110 // http://msdn.microsoft.com/library/aa911706.aspx for details. We define
111 // |suffix| as a fixed-length 26-character alphanumeric identifier, therefore
112 // the return value of this function must have a maximum length of
113 // 39 - 1(null-term) - 26(|suffix|) - 1(dot separator) = 11 characters.
114 virtual base::string16 GetBrowserProgIdPrefix();
116 // Returns the Browser ProgId description.
117 virtual base::string16 GetBrowserProgIdDesc();
119 virtual base::string16 GetInstallSubDir();
121 virtual base::string16 GetPublisherName();
123 virtual base::string16 GetAppDescription();
125 virtual base::string16 GetLongAppDescription();
127 virtual std::string GetSafeBrowsingName();
129 #if defined(OS_WIN)
130 virtual base::string16 GetDistributionData(HKEY root_key);
131 #endif
133 virtual base::string16 GetUninstallRegPath();
135 // Returns an enum specifying the different ways in which this distribution
136 // is allowed to be set as default.
137 virtual DefaultBrowserControlPolicy GetDefaultBrowserControlPolicy();
139 virtual bool CanCreateDesktopShortcuts();
141 virtual bool GetChromeChannel(base::string16* channel);
143 // Returns the CommandExecuteImpl class UUID (or empty string if this
144 // distribution doesn't include a DelegateExecute verb handler).
145 virtual base::string16 GetCommandExecuteImplClsid();
147 virtual void UpdateInstallStatus(bool system_install,
148 installer::ArchiveType archive_type,
149 installer::InstallStatus install_status);
151 // Returns true if this distribution should set the Omaha experiment_labels
152 // registry value.
153 virtual bool ShouldSetExperimentLabels();
155 virtual bool HasUserExperiments();
157 protected:
158 BrowserDistribution(Type type, scoped_ptr<AppRegistrationData> app_reg_data);
160 template<class DistributionClass>
161 static BrowserDistribution* GetOrCreateBrowserDistribution(
162 BrowserDistribution** dist);
164 const Type type_;
166 scoped_ptr<AppRegistrationData> app_reg_data_;
168 private:
169 BrowserDistribution();
171 DISALLOW_COPY_AND_ASSIGN(BrowserDistribution);
174 #endif // CHROME_INSTALLER_UTIL_BROWSER_DISTRIBUTION_H_