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.
5 // This file defines a class that contains various method related to branding.
6 // It provides only default implementations of these methods. Usually to add
7 // specific branding, we will need to extend this class with a custom
10 #include "chrome/installer/util/browser_distribution.h"
12 #include "base/atomicops.h"
13 #include "base/command_line.h"
14 #include "base/files/file_path.h"
15 #include "base/logging.h"
16 #include "base/win/registry.h"
17 #include "base/win/windows_version.h"
18 #include "chrome/common/chrome_icon_resources_win.h"
19 #include "chrome/common/env_vars.h"
20 #include "chrome/installer/util/app_registration_data.h"
21 #include "chrome/installer/util/chrome_frame_distribution.h"
22 #include "chrome/installer/util/chromium_binaries_distribution.h"
23 #include "chrome/installer/util/google_chrome_binaries_distribution.h"
24 #include "chrome/installer/util/google_chrome_distribution.h"
25 #include "chrome/installer/util/google_chrome_sxs_distribution.h"
26 #include "chrome/installer/util/install_util.h"
27 #include "chrome/installer/util/l10n_string_util.h"
28 #include "chrome/installer/util/master_preferences.h"
29 #include "chrome/installer/util/non_updating_app_registration_data.h"
31 #include "installer_util_strings.h" // NOLINT
33 using installer::MasterPreferences
;
37 const wchar_t kChromiumActiveSetupGuid
[] =
38 L
"{7D2B3E1D-D096-4594-9D8F-A6667F12E0AC}";
40 const wchar_t kCommandExecuteImplUuid
[] =
41 L
"{A2DF06F9-A21A-44A8-8A99-8B9C84F29160}";
43 // The BrowserDistribution objects are never freed.
44 BrowserDistribution
* g_browser_distribution
= NULL
;
45 BrowserDistribution
* g_chrome_frame_distribution
= NULL
;
46 BrowserDistribution
* g_binaries_distribution
= NULL
;
48 BrowserDistribution::Type
GetCurrentDistributionType() {
49 return BrowserDistribution::CHROME_BROWSER
;
54 BrowserDistribution::BrowserDistribution()
55 : type_(CHROME_BROWSER
),
56 app_reg_data_(make_scoped_ptr(
57 new NonUpdatingAppRegistrationData(L
"Software\\Chromium"))) {
60 BrowserDistribution::BrowserDistribution(
61 Type type
, scoped_ptr
<AppRegistrationData
> app_reg_data
)
62 : type_(type
), app_reg_data_(app_reg_data
.Pass()) {
65 BrowserDistribution::~BrowserDistribution() {}
67 template<class DistributionClass
>
68 BrowserDistribution
* BrowserDistribution::GetOrCreateBrowserDistribution(
69 BrowserDistribution
** dist
) {
71 DistributionClass
* temp
= new DistributionClass();
72 if (base::subtle::NoBarrier_CompareAndSwap(
73 reinterpret_cast<base::subtle::AtomicWord
*>(dist
), NULL
,
74 reinterpret_cast<base::subtle::AtomicWord
>(temp
)) != NULL
)
81 BrowserDistribution
* BrowserDistribution::GetDistribution() {
82 return GetSpecificDistribution(GetCurrentDistributionType());
86 BrowserDistribution
* BrowserDistribution::GetSpecificDistribution(
87 BrowserDistribution::Type type
) {
88 BrowserDistribution
* dist
= NULL
;
92 #if defined(GOOGLE_CHROME_BUILD)
93 if (InstallUtil::IsChromeSxSProcess()) {
94 dist
= GetOrCreateBrowserDistribution
<GoogleChromeSxSDistribution
>(
95 &g_browser_distribution
);
97 dist
= GetOrCreateBrowserDistribution
<GoogleChromeDistribution
>(
98 &g_browser_distribution
);
101 dist
= GetOrCreateBrowserDistribution
<BrowserDistribution
>(
102 &g_browser_distribution
);
107 dist
= GetOrCreateBrowserDistribution
<ChromeFrameDistribution
>(
108 &g_chrome_frame_distribution
);
112 DCHECK_EQ(CHROME_BINARIES
, type
);
113 #if defined(GOOGLE_CHROME_BUILD)
114 dist
= GetOrCreateBrowserDistribution
<GoogleChromeBinariesDistribution
>(
115 &g_binaries_distribution
);
117 dist
= GetOrCreateBrowserDistribution
<ChromiumBinariesDistribution
>(
118 &g_binaries_distribution
);
125 const AppRegistrationData
& BrowserDistribution::GetAppRegistrationData() const {
126 return *app_reg_data_
;
129 base::string16
BrowserDistribution::GetAppGuid() const {
130 return app_reg_data_
->GetAppGuid();
133 base::string16
BrowserDistribution::GetStateKey() const {
134 return app_reg_data_
->GetStateKey();
137 base::string16
BrowserDistribution::GetStateMediumKey() const {
138 return app_reg_data_
->GetStateMediumKey();
141 base::string16
BrowserDistribution::GetVersionKey() const {
142 return app_reg_data_
->GetVersionKey();
145 void BrowserDistribution::DoPostUninstallOperations(
146 const Version
& version
, const base::FilePath
& local_data_path
,
147 const base::string16
& distribution_data
) {
150 base::string16
BrowserDistribution::GetActiveSetupGuid() {
151 return kChromiumActiveSetupGuid
;
154 base::string16
BrowserDistribution::GetBaseAppName() {
158 base::string16
BrowserDistribution::GetDisplayName() {
159 return GetShortcutName(SHORTCUT_CHROME
);
162 base::string16
BrowserDistribution::GetShortcutName(
163 ShortcutType shortcut_type
) {
164 switch (shortcut_type
) {
165 case SHORTCUT_CHROME_ALTERNATE
:
166 // TODO(calamity): Change IDS_OEM_MAIN_SHORTCUT_NAME in
167 // chromium_strings.grd to "The Internet" (so that it doesn't collide with
168 // the value in google_chrome_strings.grd) then change this to
169 // installer::GetLocalizedString(IDS_OEM_MAIN_SHORTCUT_NAME_BASE)
170 return L
"The Internet";
171 case SHORTCUT_APP_LAUNCHER
:
172 return installer::GetLocalizedString(IDS_APP_LIST_SHORTCUT_NAME_BASE
);
174 DCHECK_EQ(shortcut_type
, SHORTCUT_CHROME
);
175 return GetBaseAppName();
179 int BrowserDistribution::GetIconIndex(ShortcutType shortcut_type
) {
180 if (shortcut_type
== SHORTCUT_APP_LAUNCHER
)
181 return icon_resources::kAppLauncherIndex
;
182 DCHECK(shortcut_type
== SHORTCUT_CHROME
||
183 shortcut_type
== SHORTCUT_CHROME_ALTERNATE
) << shortcut_type
;
184 return icon_resources::kApplicationIndex
;
187 base::string16
BrowserDistribution::GetIconFilename() {
188 return installer::kChromeExe
;
191 base::string16
BrowserDistribution::GetStartMenuShortcutSubfolder(
192 Subfolder subfolder_type
) {
193 switch (subfolder_type
) {
195 return installer::GetLocalizedString(IDS_APP_SHORTCUTS_SUBDIR_NAME_BASE
);
197 DCHECK_EQ(subfolder_type
, SUBFOLDER_CHROME
);
198 return GetShortcutName(SHORTCUT_CHROME
);
202 base::string16
BrowserDistribution::GetBaseAppId() {
206 base::string16
BrowserDistribution::GetBrowserProgIdPrefix() {
207 // This used to be "ChromiumHTML", but was forced to become "ChromiumHTM"
208 // because of http://crbug.com/153349. See the declaration of this function
209 // in the header file for more details.
210 return L
"ChromiumHTM";
213 base::string16
BrowserDistribution::GetBrowserProgIdDesc() {
214 return L
"Chromium HTML Document";
218 base::string16
BrowserDistribution::GetInstallSubDir() {
222 base::string16
BrowserDistribution::GetPublisherName() {
226 base::string16
BrowserDistribution::GetAppDescription() {
227 return L
"Browse the web";
230 base::string16
BrowserDistribution::GetLongAppDescription() {
231 const base::string16
& app_description
=
232 installer::GetLocalizedString(IDS_PRODUCT_DESCRIPTION_BASE
);
233 return app_description
;
236 std::string
BrowserDistribution::GetSafeBrowsingName() {
240 std::string
BrowserDistribution::GetNetworkStatsServer() const {
244 base::string16
BrowserDistribution::GetDistributionData(HKEY root_key
) {
248 base::string16
BrowserDistribution::GetUninstallLinkName() {
249 return L
"Uninstall Chromium";
252 base::string16
BrowserDistribution::GetUninstallRegPath() {
253 return L
"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Chromium";
256 BrowserDistribution::DefaultBrowserControlPolicy
257 BrowserDistribution::GetDefaultBrowserControlPolicy() {
258 return DEFAULT_BROWSER_FULL_CONTROL
;
261 bool BrowserDistribution::CanCreateDesktopShortcuts() {
265 bool BrowserDistribution::GetChromeChannel(base::string16
* channel
) {
269 bool BrowserDistribution::GetCommandExecuteImplClsid(
270 base::string16
* handler_class_uuid
) {
271 if (handler_class_uuid
)
272 *handler_class_uuid
= kCommandExecuteImplUuid
;
276 void BrowserDistribution::UpdateInstallStatus(bool system_install
,
277 installer::ArchiveType archive_type
,
278 installer::InstallStatus install_status
) {
281 bool BrowserDistribution::ShouldSetExperimentLabels() {
285 bool BrowserDistribution::HasUserExperiments() {