Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / installer / util / browser_distribution.cc
blob8909f9fa3dd23ccd9bc025b086b6ae630f48afc0
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 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
8 // implementation.
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/path_service.h"
17 #include "base/win/registry.h"
18 #include "base/win/windows_version.h"
19 #include "chrome/common/env_vars.h"
20 #include "chrome/installer/util/chrome_app_host_distribution.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"
30 #include "installer_util_strings.h" // NOLINT
32 using installer::MasterPreferences;
34 namespace {
36 const wchar_t kChromiumActiveSetupGuid[] =
37 L"{7D2B3E1D-D096-4594-9D8F-A6667F12E0AC}";
39 const wchar_t kCommandExecuteImplUuid[] =
40 L"{A2DF06F9-A21A-44A8-8A99-8B9C84F29160}";
42 // The Chromium App Launcher icon is index 1; see chrome_exe.rc.
43 const int kAppLauncherIconIndex = 1;
45 // The BrowserDistribution objects are never freed.
46 BrowserDistribution* g_browser_distribution = NULL;
47 BrowserDistribution* g_chrome_frame_distribution = NULL;
48 BrowserDistribution* g_binaries_distribution = NULL;
49 BrowserDistribution* g_chrome_app_host_distribution = NULL;
51 BrowserDistribution::Type GetCurrentDistributionType() {
52 // TODO(erikwright): If the app host is installed, but not Chrome, perhaps
53 // this should return CHROME_APP_HOST.
54 return BrowserDistribution::CHROME_BROWSER;
57 } // end namespace
59 BrowserDistribution::BrowserDistribution()
60 : type_(CHROME_BROWSER) {
63 BrowserDistribution::BrowserDistribution(Type type)
64 : type_(type) {
67 template<class DistributionClass>
68 BrowserDistribution* BrowserDistribution::GetOrCreateBrowserDistribution(
69 BrowserDistribution** dist) {
70 if (!*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)
75 delete temp;
78 return *dist;
81 BrowserDistribution* BrowserDistribution::GetDistribution() {
82 return GetSpecificDistribution(GetCurrentDistributionType());
85 // static
86 BrowserDistribution* BrowserDistribution::GetSpecificDistribution(
87 BrowserDistribution::Type type) {
88 BrowserDistribution* dist = NULL;
90 switch (type) {
91 case CHROME_BROWSER:
92 #if defined(GOOGLE_CHROME_BUILD)
93 if (InstallUtil::IsChromeSxSProcess()) {
94 dist = GetOrCreateBrowserDistribution<GoogleChromeSxSDistribution>(
95 &g_browser_distribution);
96 } else {
97 dist = GetOrCreateBrowserDistribution<GoogleChromeDistribution>(
98 &g_browser_distribution);
100 #else
101 dist = GetOrCreateBrowserDistribution<BrowserDistribution>(
102 &g_browser_distribution);
103 #endif
104 break;
106 case CHROME_FRAME:
107 dist = GetOrCreateBrowserDistribution<ChromeFrameDistribution>(
108 &g_chrome_frame_distribution);
109 break;
111 case CHROME_APP_HOST:
112 dist = GetOrCreateBrowserDistribution<ChromeAppHostDistribution>(
113 &g_chrome_app_host_distribution);
114 break;
116 default:
117 DCHECK_EQ(CHROME_BINARIES, type);
118 #if defined(GOOGLE_CHROME_BUILD)
119 dist = GetOrCreateBrowserDistribution<GoogleChromeBinariesDistribution>(
120 &g_binaries_distribution);
121 #else
122 dist = GetOrCreateBrowserDistribution<ChromiumBinariesDistribution>(
123 &g_binaries_distribution);
124 #endif
127 return dist;
130 void BrowserDistribution::DoPostUninstallOperations(
131 const Version& version, const base::FilePath& local_data_path,
132 const base::string16& distribution_data) {
135 base::string16 BrowserDistribution::GetActiveSetupGuid() {
136 return kChromiumActiveSetupGuid;
139 base::string16 BrowserDistribution::GetAppGuid() {
140 return L"";
143 base::string16 BrowserDistribution::GetBaseAppName() {
144 return L"Chromium";
147 base::string16 BrowserDistribution::GetDisplayName() {
148 return GetShortcutName(SHORTCUT_CHROME);
151 base::string16 BrowserDistribution::GetShortcutName(
152 ShortcutType shortcut_type) {
153 switch (shortcut_type) {
154 case SHORTCUT_CHROME_ALTERNATE:
155 // TODO(calamity): Change IDS_OEM_MAIN_SHORTCUT_NAME in
156 // chromium_strings.grd to "The Internet" (so that it doesn't collide with
157 // the value in google_chrome_strings.grd) then change this to
158 // installer::GetLocalizedString(IDS_OEM_MAIN_SHORTCUT_NAME_BASE)
159 return L"The Internet";
160 case SHORTCUT_APP_LAUNCHER:
161 return installer::GetLocalizedString(IDS_APP_LIST_SHORTCUT_NAME_BASE);
162 default:
163 DCHECK_EQ(shortcut_type, SHORTCUT_CHROME);
164 return GetBaseAppName();
168 int BrowserDistribution::GetIconIndex(ShortcutType shortcut_type) {
169 if (shortcut_type == SHORTCUT_APP_LAUNCHER)
170 return kAppLauncherIconIndex;
171 DCHECK(shortcut_type == SHORTCUT_CHROME ||
172 shortcut_type == SHORTCUT_CHROME_ALTERNATE) << shortcut_type;
173 return 0;
176 base::string16 BrowserDistribution::GetIconFilename() {
177 return installer::kChromeExe;
180 base::string16 BrowserDistribution::GetStartMenuShortcutSubfolder(
181 Subfolder subfolder_type) {
182 switch (subfolder_type) {
183 case SUBFOLDER_APPS:
184 return installer::GetLocalizedString(IDS_APP_SHORTCUTS_SUBDIR_NAME_BASE);
185 default:
186 DCHECK_EQ(subfolder_type, SUBFOLDER_CHROME);
187 return GetShortcutName(SHORTCUT_CHROME);
191 base::string16 BrowserDistribution::GetBaseAppId() {
192 return L"Chromium";
195 base::string16 BrowserDistribution::GetBrowserProgIdPrefix() {
196 // This used to be "ChromiumHTML", but was forced to become "ChromiumHTM"
197 // because of http://crbug.com/153349. See the declaration of this function
198 // in the header file for more details.
199 return L"ChromiumHTM";
202 base::string16 BrowserDistribution::GetBrowserProgIdDesc() {
203 return L"Chromium HTML Document";
207 base::string16 BrowserDistribution::GetInstallSubDir() {
208 return L"Chromium";
211 base::string16 BrowserDistribution::GetPublisherName() {
212 return L"Chromium";
215 base::string16 BrowserDistribution::GetAppDescription() {
216 return L"Browse the web";
219 base::string16 BrowserDistribution::GetLongAppDescription() {
220 const base::string16& app_description =
221 installer::GetLocalizedString(IDS_PRODUCT_DESCRIPTION_BASE);
222 return app_description;
225 std::string BrowserDistribution::GetSafeBrowsingName() {
226 return "chromium";
229 base::string16 BrowserDistribution::GetStateKey() {
230 return L"Software\\Chromium";
233 base::string16 BrowserDistribution::GetStateMediumKey() {
234 return L"Software\\Chromium";
237 std::string BrowserDistribution::GetNetworkStatsServer() const {
238 return "";
241 std::string BrowserDistribution::GetHttpPipeliningTestServer() const {
242 return "";
245 base::string16 BrowserDistribution::GetDistributionData(HKEY root_key) {
246 return L"";
249 base::string16 BrowserDistribution::GetUninstallLinkName() {
250 return L"Uninstall Chromium";
253 base::string16 BrowserDistribution::GetUninstallRegPath() {
254 return L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Chromium";
257 base::string16 BrowserDistribution::GetVersionKey() {
258 return L"Software\\Chromium";
261 BrowserDistribution::DefaultBrowserControlPolicy
262 BrowserDistribution::GetDefaultBrowserControlPolicy() {
263 return DEFAULT_BROWSER_FULL_CONTROL;
266 bool BrowserDistribution::CanCreateDesktopShortcuts() {
267 return true;
270 bool BrowserDistribution::GetChromeChannel(base::string16* channel) {
271 return false;
274 bool BrowserDistribution::GetCommandExecuteImplClsid(
275 base::string16* handler_class_uuid) {
276 if (handler_class_uuid)
277 *handler_class_uuid = kCommandExecuteImplUuid;
278 return true;
281 bool BrowserDistribution::AppHostIsSupported() {
282 return false;
285 void BrowserDistribution::UpdateInstallStatus(bool system_install,
286 installer::ArchiveType archive_type,
287 installer::InstallStatus install_status) {
290 bool BrowserDistribution::ShouldSetExperimentLabels() {
291 return false;
294 bool BrowserDistribution::HasUserExperiments() {
295 return false;