1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// This file defines a class that contains various method related to branding.
// It provides only default implementations of these methods. Usually to add
// specific branding, we will need to extend this class with a custom
// implementation.
#include "chrome/installer/util/browser_distribution.h"
#include "base/atomicops.h"
#include "base/command_line.h"
#include "base/file_path.h"
#include "base/path_service.h"
#include "base/lock.h"
#include "base/logging.h"
#include "base/win/registry.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/env_vars.h"
#include "chrome/installer/util/chrome_frame_distribution.h"
#include "chrome/installer/util/google_chrome_distribution.h"
#include "chrome/installer/util/google_chrome_sxs_distribution.h"
#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/l10n_string_util.h"
#include "installer_util_strings.h" // NOLINT
namespace {
// The BrowserDistribution objects are never freed.
BrowserDistribution* g_browser_distribution = NULL;
BrowserDistribution* g_chrome_frame_distribution = NULL;
BrowserDistribution* g_ceee_distribution = NULL;
// Returns true if currently running in npchrome_frame.dll
bool IsChromeFrameModule() {
FilePath module_path;
PathService::Get(base::FILE_MODULE, &module_path);
return FilePath::CompareEqualIgnoreCase(module_path.BaseName().value(),
installer::kChromeFrameDll);
}
// Returns true if currently running in ceee_broker.exe
bool IsCeeeBrokerProcess() {
FilePath exe_path;
PathService::Get(base::FILE_EXE, &exe_path);
return FilePath::CompareEqualIgnoreCase(exe_path.BaseName().value(),
installer::kCeeeBrokerExe);
}
BrowserDistribution::Type GetCurrentDistributionType() {
static BrowserDistribution::Type type =
(InstallUtil::IsChromeFrameProcess() || IsChromeFrameModule()) ?
BrowserDistribution::CHROME_FRAME :
BrowserDistribution::CHROME_BROWSER;
return type;
}
} // end namespace
BrowserDistribution::BrowserDistribution(
const installer::MasterPreferences& prefs)
: type_(BrowserDistribution::CHROME_BROWSER) {
}
template<class DistributionClass>
BrowserDistribution* BrowserDistribution::GetOrCreateBrowserDistribution(
const installer::MasterPreferences& prefs,
BrowserDistribution** dist) {
if (!*dist) {
DistributionClass* temp = new DistributionClass(prefs);
if (base::subtle::NoBarrier_CompareAndSwap(
reinterpret_cast<base::subtle::AtomicWord*>(dist), NULL,
reinterpret_cast<base::subtle::AtomicWord>(temp)) != NULL)
delete temp;
}
return *dist;
}
BrowserDistribution* BrowserDistribution::GetDistribution() {
const installer::MasterPreferences& prefs =
installer::MasterPreferences::ForCurrentProcess();
return GetSpecificDistribution(GetCurrentDistributionType(), prefs);
}
// static
BrowserDistribution* BrowserDistribution::GetSpecificDistribution(
BrowserDistribution::Type type,
const installer::MasterPreferences& prefs) {
BrowserDistribution* dist = NULL;
if (type == CHROME_FRAME) {
dist = GetOrCreateBrowserDistribution<ChromeFrameDistribution>(
prefs, &g_chrome_frame_distribution);
} else {
DCHECK_EQ(CHROME_BROWSER, type);
#if defined(GOOGLE_CHROME_BUILD)
if (InstallUtil::IsChromeSxSProcess()) {
dist = GetOrCreateBrowserDistribution<GoogleChromeSxSDistribution>(
prefs, &g_browser_distribution);
} else {
dist = GetOrCreateBrowserDistribution<GoogleChromeDistribution>(
prefs, &g_browser_distribution);
}
#else
dist = GetOrCreateBrowserDistribution<BrowserDistribution>(
prefs, &g_browser_distribution);
#endif
}
return dist;
}
void BrowserDistribution::DoPostUninstallOperations(
const installer::Version& version, const FilePath& local_data_path,
const std::wstring& distribution_data) {
}
std::wstring BrowserDistribution::GetAppGuid() {
return L"";
}
std::wstring BrowserDistribution::GetApplicationName() {
return L"Chromium";
}
std::wstring BrowserDistribution::GetAppShortCutName() {
return GetApplicationName();
}
std::wstring BrowserDistribution::GetAlternateApplicationName() {
return L"The Internet";
}
std::wstring BrowserDistribution::GetBrowserAppId() {
return L"Chromium";
}
std::wstring BrowserDistribution::GetInstallSubDir() {
return L"Chromium";
}
std::wstring BrowserDistribution::GetPublisherName() {
return L"Chromium";
}
std::wstring BrowserDistribution::GetAppDescription() {
return L"Browse the web";
}
std::wstring BrowserDistribution::GetLongAppDescription() {
const std::wstring& app_description =
installer::GetLocalizedString(IDS_PRODUCT_DESCRIPTION_BASE);
return app_description;
}
// static
int BrowserDistribution::GetInstallReturnCode(
installer::InstallStatus status) {
switch (status) {
case installer::FIRST_INSTALL_SUCCESS:
case installer::INSTALL_REPAIRED:
case installer::NEW_VERSION_UPDATED:
case installer::IN_USE_UPDATED:
return 0;
default:
return status;
}
}
std::string BrowserDistribution::GetSafeBrowsingName() {
return "chromium";
}
std::wstring BrowserDistribution::GetStateKey() {
return L"Software\\Chromium";
}
std::wstring BrowserDistribution::GetStateMediumKey() {
return L"Software\\Chromium";
}
std::wstring BrowserDistribution::GetStatsServerURL() {
return L"";
}
std::wstring BrowserDistribution::GetDistributionData(HKEY root_key) {
return L"";
}
std::wstring BrowserDistribution::GetUninstallLinkName() {
return L"Uninstall Chromium";
}
std::wstring BrowserDistribution::GetUninstallRegPath() {
return L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Chromium";
}
std::wstring BrowserDistribution::GetVersionKey() {
return L"Software\\Chromium";
}
bool BrowserDistribution::CanSetAsDefault() {
return true;
}
int BrowserDistribution::GetIconIndex() {
return 0;
}
bool BrowserDistribution::GetChromeChannel(std::wstring* channel) {
return false;
}
void BrowserDistribution::UpdateDiffInstallStatus(bool system_install,
bool incremental_install, installer::InstallStatus install_status) {
}
void BrowserDistribution::LaunchUserExperiment(
installer::InstallStatus status, const installer::Version& version,
const installer::Product& installation, bool system_level) {
}
void BrowserDistribution::InactiveUserToastExperiment(int flavor,
const installer::Product& installation) {
}
std::vector<FilePath> BrowserDistribution::GetKeyFiles() {
std::vector<FilePath> key_files;
key_files.push_back(FilePath(installer::kChromeDll));
return key_files;
}
std::vector<FilePath> BrowserDistribution::GetComDllList() {
return std::vector<FilePath>();
}
void BrowserDistribution::AppendUninstallCommandLineFlags(
CommandLine* cmd_line) {
DCHECK(cmd_line);
cmd_line->AppendSwitch(installer::switches::kChrome);
}
|