OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // This file defines specific implementation of BrowserDistribution class for | 5 // This file defines specific implementation of BrowserDistribution class for |
6 // Google Chrome. | 6 // Google Chrome. |
7 | 7 |
8 #include "chrome/installer/util/google_chrome_distribution.h" | 8 #include "chrome/installer/util/google_chrome_distribution.h" |
9 | 9 |
10 #include <windows.h> | 10 #include <windows.h> |
(...skipping 28 matching lines...) Expand all Loading... |
39 const wchar_t kBrowserProgIdDesc[] = L"Chrome HTML Document"; | 39 const wchar_t kBrowserProgIdDesc[] = L"Chrome HTML Document"; |
40 const wchar_t kCommandExecuteImplUuid[] = | 40 const wchar_t kCommandExecuteImplUuid[] = |
41 L"{5C65F4B0-3651-4514-B207-D10CB699B14B}"; | 41 L"{5C65F4B0-3651-4514-B207-D10CB699B14B}"; |
42 | 42 |
43 // The Google Chrome App Launcher icon is index 5; see chrome_exe.rc. | 43 // The Google Chrome App Launcher icon is index 5; see chrome_exe.rc. |
44 const int kAppLauncherIconIndex = 5; | 44 const int kAppLauncherIconIndex = 5; |
45 | 45 |
46 // Substitute the locale parameter in uninstall URL with whatever | 46 // Substitute the locale parameter in uninstall URL with whatever |
47 // Google Update tells us is the locale. In case we fail to find | 47 // Google Update tells us is the locale. In case we fail to find |
48 // the locale, we use US English. | 48 // the locale, we use US English. |
49 string16 LocalizeUrl(const wchar_t* url) { | 49 base::string16 LocalizeUrl(const wchar_t* url) { |
50 string16 language; | 50 base::string16 language; |
51 if (!GoogleUpdateSettings::GetLanguage(&language)) | 51 if (!GoogleUpdateSettings::GetLanguage(&language)) |
52 language = L"en-US"; // Default to US English. | 52 language = L"en-US"; // Default to US English. |
53 return ReplaceStringPlaceholders(url, language.c_str(), NULL); | 53 return ReplaceStringPlaceholders(url, language.c_str(), NULL); |
54 } | 54 } |
55 | 55 |
56 string16 GetUninstallSurveyUrl() { | 56 base::string16 GetUninstallSurveyUrl() { |
57 const wchar_t kSurveyUrl[] = L"http://www.google.com/support/chrome/bin/" | 57 const wchar_t kSurveyUrl[] = L"http://www.google.com/support/chrome/bin/" |
58 L"request.py?hl=$1&contact_type=uninstall"; | 58 L"request.py?hl=$1&contact_type=uninstall"; |
59 return LocalizeUrl(kSurveyUrl); | 59 return LocalizeUrl(kSurveyUrl); |
60 } | 60 } |
61 | 61 |
62 } // namespace | 62 } // namespace |
63 | 63 |
64 GoogleChromeDistribution::GoogleChromeDistribution() | 64 GoogleChromeDistribution::GoogleChromeDistribution() |
65 : BrowserDistribution(CHROME_BROWSER), | 65 : BrowserDistribution(CHROME_BROWSER), |
66 product_guid_(kChromeGuid) { | 66 product_guid_(kChromeGuid) { |
67 } | 67 } |
68 | 68 |
69 void GoogleChromeDistribution::DoPostUninstallOperations( | 69 void GoogleChromeDistribution::DoPostUninstallOperations( |
70 const Version& version, | 70 const Version& version, |
71 const base::FilePath& local_data_path, | 71 const base::FilePath& local_data_path, |
72 const string16& distribution_data) { | 72 const base::string16& distribution_data) { |
73 // Send the Chrome version and OS version as params to the form. | 73 // Send the Chrome version and OS version as params to the form. |
74 // It would be nice to send the locale, too, but I don't see an | 74 // It would be nice to send the locale, too, but I don't see an |
75 // easy way to get that in the existing code. It's something we | 75 // easy way to get that in the existing code. It's something we |
76 // can add later, if needed. | 76 // can add later, if needed. |
77 // We depend on installed_version.GetString() not having spaces or other | 77 // We depend on installed_version.GetString() not having spaces or other |
78 // characters that need escaping: 0.2.13.4. Should that change, we will | 78 // characters that need escaping: 0.2.13.4. Should that change, we will |
79 // need to escape the string before using it in a URL. | 79 // need to escape the string before using it in a URL. |
80 const string16 kVersionParam = L"crversion"; | 80 const base::string16 kVersionParam = L"crversion"; |
81 const string16 kOSParam = L"os"; | 81 const base::string16 kOSParam = L"os"; |
82 base::win::OSInfo::VersionNumber version_number = | 82 base::win::OSInfo::VersionNumber version_number = |
83 base::win::OSInfo::GetInstance()->version_number(); | 83 base::win::OSInfo::GetInstance()->version_number(); |
84 string16 os_version = base::StringPrintf(L"%d.%d.%d", | 84 base::string16 os_version = base::StringPrintf(L"%d.%d.%d", |
85 version_number.major, version_number.minor, version_number.build); | 85 version_number.major, version_number.minor, version_number.build); |
86 | 86 |
87 base::FilePath iexplore; | 87 base::FilePath iexplore; |
88 if (!PathService::Get(base::DIR_PROGRAM_FILES, &iexplore)) | 88 if (!PathService::Get(base::DIR_PROGRAM_FILES, &iexplore)) |
89 return; | 89 return; |
90 | 90 |
91 iexplore = iexplore.AppendASCII("Internet Explorer"); | 91 iexplore = iexplore.AppendASCII("Internet Explorer"); |
92 iexplore = iexplore.AppendASCII("iexplore.exe"); | 92 iexplore = iexplore.AppendASCII("iexplore.exe"); |
93 | 93 |
94 string16 command = iexplore.value() + L" " + GetUninstallSurveyUrl() + | 94 base::string16 command = iexplore.value() + L" " + GetUninstallSurveyUrl() + |
95 L"&" + kVersionParam + L"=" + UTF8ToWide(version.GetString()) + L"&" + | 95 L"&" + kVersionParam + L"=" + UTF8ToWide(version.GetString()) + L"&" + |
96 kOSParam + L"=" + os_version; | 96 kOSParam + L"=" + os_version; |
97 | 97 |
98 string16 uninstall_metrics; | 98 base::string16 uninstall_metrics; |
99 if (installer::ExtractUninstallMetricsFromFile(local_data_path, | 99 if (installer::ExtractUninstallMetricsFromFile(local_data_path, |
100 &uninstall_metrics)) { | 100 &uninstall_metrics)) { |
101 // The user has opted into anonymous usage data collection, so append | 101 // The user has opted into anonymous usage data collection, so append |
102 // metrics and distribution data. | 102 // metrics and distribution data. |
103 command += uninstall_metrics; | 103 command += uninstall_metrics; |
104 if (!distribution_data.empty()) { | 104 if (!distribution_data.empty()) { |
105 command += L"&"; | 105 command += L"&"; |
106 command += distribution_data; | 106 command += distribution_data; |
107 } | 107 } |
108 } | 108 } |
109 | 109 |
110 int pid = 0; | 110 int pid = 0; |
111 // The reason we use WMI to launch the process is because the uninstall | 111 // The reason we use WMI to launch the process is because the uninstall |
112 // process runs inside a Job object controlled by the shell. As long as there | 112 // process runs inside a Job object controlled by the shell. As long as there |
113 // are processes running, the shell will not close the uninstall applet. WMI | 113 // are processes running, the shell will not close the uninstall applet. WMI |
114 // allows us to escape from the Job object so the applet will close. | 114 // allows us to escape from the Job object so the applet will close. |
115 installer::WMIProcess::Launch(command, &pid); | 115 installer::WMIProcess::Launch(command, &pid); |
116 } | 116 } |
117 | 117 |
118 string16 GoogleChromeDistribution::GetActiveSetupGuid() { | 118 base::string16 GoogleChromeDistribution::GetActiveSetupGuid() { |
119 return product_guid(); | 119 return product_guid(); |
120 } | 120 } |
121 | 121 |
122 string16 GoogleChromeDistribution::GetAppGuid() { | 122 base::string16 GoogleChromeDistribution::GetAppGuid() { |
123 return product_guid(); | 123 return product_guid(); |
124 } | 124 } |
125 | 125 |
126 string16 GoogleChromeDistribution::GetBaseAppName() { | 126 base::string16 GoogleChromeDistribution::GetBaseAppName() { |
127 // I'd really like to return L ## PRODUCT_FULLNAME_STRING; but that's no good | 127 // I'd really like to return L ## PRODUCT_FULLNAME_STRING; but that's no good |
128 // since it'd be "Chromium" in a non-Chrome build, which isn't at all what I | 128 // since it'd be "Chromium" in a non-Chrome build, which isn't at all what I |
129 // want. Sigh. | 129 // want. Sigh. |
130 return L"Google Chrome"; | 130 return L"Google Chrome"; |
131 } | 131 } |
132 | 132 |
133 string16 GoogleChromeDistribution::GetShortcutName(ShortcutType shortcut_type) { | 133 base::string16 GoogleChromeDistribution::GetShortcutName( |
| 134 ShortcutType shortcut_type) { |
134 int string_id = IDS_PRODUCT_NAME_BASE; | 135 int string_id = IDS_PRODUCT_NAME_BASE; |
135 switch (shortcut_type) { | 136 switch (shortcut_type) { |
136 case SHORTCUT_CHROME_ALTERNATE: | 137 case SHORTCUT_CHROME_ALTERNATE: |
137 string_id = IDS_OEM_MAIN_SHORTCUT_NAME_BASE; | 138 string_id = IDS_OEM_MAIN_SHORTCUT_NAME_BASE; |
138 break; | 139 break; |
139 case SHORTCUT_APP_LAUNCHER: | 140 case SHORTCUT_APP_LAUNCHER: |
140 string_id = IDS_APP_LIST_SHORTCUT_NAME_BASE; | 141 string_id = IDS_APP_LIST_SHORTCUT_NAME_BASE; |
141 break; | 142 break; |
142 default: | 143 default: |
143 DCHECK_EQ(shortcut_type, SHORTCUT_CHROME); | 144 DCHECK_EQ(shortcut_type, SHORTCUT_CHROME); |
144 break; | 145 break; |
145 } | 146 } |
146 return installer::GetLocalizedString(string_id); | 147 return installer::GetLocalizedString(string_id); |
147 } | 148 } |
148 | 149 |
149 int GoogleChromeDistribution::GetIconIndex(ShortcutType shortcut_type) { | 150 int GoogleChromeDistribution::GetIconIndex(ShortcutType shortcut_type) { |
150 if (shortcut_type == SHORTCUT_APP_LAUNCHER) | 151 if (shortcut_type == SHORTCUT_APP_LAUNCHER) |
151 return kAppLauncherIconIndex; | 152 return kAppLauncherIconIndex; |
152 DCHECK(shortcut_type == SHORTCUT_CHROME || | 153 DCHECK(shortcut_type == SHORTCUT_CHROME || |
153 shortcut_type == SHORTCUT_CHROME_ALTERNATE) << shortcut_type; | 154 shortcut_type == SHORTCUT_CHROME_ALTERNATE) << shortcut_type; |
154 return 0; | 155 return 0; |
155 } | 156 } |
156 | 157 |
157 string16 GoogleChromeDistribution::GetBaseAppId() { | 158 base::string16 GoogleChromeDistribution::GetBaseAppId() { |
158 return kBrowserAppId; | 159 return kBrowserAppId; |
159 } | 160 } |
160 | 161 |
161 string16 GoogleChromeDistribution::GetBrowserProgIdPrefix() { | 162 base::string16 GoogleChromeDistribution::GetBrowserProgIdPrefix() { |
162 return kBrowserProgIdPrefix; | 163 return kBrowserProgIdPrefix; |
163 } | 164 } |
164 | 165 |
165 string16 GoogleChromeDistribution::GetBrowserProgIdDesc() { | 166 base::string16 GoogleChromeDistribution::GetBrowserProgIdDesc() { |
166 return kBrowserProgIdDesc; | 167 return kBrowserProgIdDesc; |
167 } | 168 } |
168 | 169 |
169 string16 GoogleChromeDistribution::GetInstallSubDir() { | 170 base::string16 GoogleChromeDistribution::GetInstallSubDir() { |
170 string16 sub_dir(installer::kGoogleChromeInstallSubDir1); | 171 base::string16 sub_dir(installer::kGoogleChromeInstallSubDir1); |
171 sub_dir.append(L"\\"); | 172 sub_dir.append(L"\\"); |
172 sub_dir.append(installer::kGoogleChromeInstallSubDir2); | 173 sub_dir.append(installer::kGoogleChromeInstallSubDir2); |
173 return sub_dir; | 174 return sub_dir; |
174 } | 175 } |
175 | 176 |
176 string16 GoogleChromeDistribution::GetPublisherName() { | 177 base::string16 GoogleChromeDistribution::GetPublisherName() { |
177 const string16& publisher_name = | 178 const base::string16& publisher_name = |
178 installer::GetLocalizedString(IDS_ABOUT_VERSION_COMPANY_NAME_BASE); | 179 installer::GetLocalizedString(IDS_ABOUT_VERSION_COMPANY_NAME_BASE); |
179 return publisher_name; | 180 return publisher_name; |
180 } | 181 } |
181 | 182 |
182 string16 GoogleChromeDistribution::GetAppDescription() { | 183 base::string16 GoogleChromeDistribution::GetAppDescription() { |
183 const string16& app_description = | 184 const base::string16& app_description = |
184 installer::GetLocalizedString(IDS_SHORTCUT_TOOLTIP_BASE); | 185 installer::GetLocalizedString(IDS_SHORTCUT_TOOLTIP_BASE); |
185 return app_description; | 186 return app_description; |
186 } | 187 } |
187 | 188 |
188 std::string GoogleChromeDistribution::GetSafeBrowsingName() { | 189 std::string GoogleChromeDistribution::GetSafeBrowsingName() { |
189 return "googlechrome"; | 190 return "googlechrome"; |
190 } | 191 } |
191 | 192 |
192 string16 GoogleChromeDistribution::GetStateKey() { | 193 base::string16 GoogleChromeDistribution::GetStateKey() { |
193 string16 key(google_update::kRegPathClientState); | 194 base::string16 key(google_update::kRegPathClientState); |
194 key.append(L"\\"); | 195 key.append(L"\\"); |
195 key.append(product_guid()); | 196 key.append(product_guid()); |
196 return key; | 197 return key; |
197 } | 198 } |
198 | 199 |
199 string16 GoogleChromeDistribution::GetStateMediumKey() { | 200 base::string16 GoogleChromeDistribution::GetStateMediumKey() { |
200 string16 key(google_update::kRegPathClientStateMedium); | 201 base::string16 key(google_update::kRegPathClientStateMedium); |
201 key.append(L"\\"); | 202 key.append(L"\\"); |
202 key.append(product_guid()); | 203 key.append(product_guid()); |
203 return key; | 204 return key; |
204 } | 205 } |
205 | 206 |
206 std::string GoogleChromeDistribution::GetNetworkStatsServer() const { | 207 std::string GoogleChromeDistribution::GetNetworkStatsServer() const { |
207 return chrome_common_net::kEchoTestServerLocation; | 208 return chrome_common_net::kEchoTestServerLocation; |
208 } | 209 } |
209 | 210 |
210 std::string GoogleChromeDistribution::GetHttpPipeliningTestServer() const { | 211 std::string GoogleChromeDistribution::GetHttpPipeliningTestServer() const { |
211 return chrome_common_net::kPipelineTestServerBaseUrl; | 212 return chrome_common_net::kPipelineTestServerBaseUrl; |
212 } | 213 } |
213 | 214 |
214 string16 GoogleChromeDistribution::GetDistributionData(HKEY root_key) { | 215 base::string16 GoogleChromeDistribution::GetDistributionData(HKEY root_key) { |
215 string16 sub_key(google_update::kRegPathClientState); | 216 base::string16 sub_key(google_update::kRegPathClientState); |
216 sub_key.append(L"\\"); | 217 sub_key.append(L"\\"); |
217 sub_key.append(product_guid()); | 218 sub_key.append(product_guid()); |
218 | 219 |
219 base::win::RegKey client_state_key(root_key, sub_key.c_str(), KEY_READ); | 220 base::win::RegKey client_state_key(root_key, sub_key.c_str(), KEY_READ); |
220 string16 result; | 221 base::string16 result; |
221 string16 brand_value; | 222 base::string16 brand_value; |
222 if (client_state_key.ReadValue(google_update::kRegRLZBrandField, | 223 if (client_state_key.ReadValue(google_update::kRegRLZBrandField, |
223 &brand_value) == ERROR_SUCCESS) { | 224 &brand_value) == ERROR_SUCCESS) { |
224 result = google_update::kRegRLZBrandField; | 225 result = google_update::kRegRLZBrandField; |
225 result.append(L"="); | 226 result.append(L"="); |
226 result.append(brand_value); | 227 result.append(brand_value); |
227 result.append(L"&"); | 228 result.append(L"&"); |
228 } | 229 } |
229 | 230 |
230 string16 client_value; | 231 base::string16 client_value; |
231 if (client_state_key.ReadValue(google_update::kRegClientField, | 232 if (client_state_key.ReadValue(google_update::kRegClientField, |
232 &client_value) == ERROR_SUCCESS) { | 233 &client_value) == ERROR_SUCCESS) { |
233 result.append(google_update::kRegClientField); | 234 result.append(google_update::kRegClientField); |
234 result.append(L"="); | 235 result.append(L"="); |
235 result.append(client_value); | 236 result.append(client_value); |
236 result.append(L"&"); | 237 result.append(L"&"); |
237 } | 238 } |
238 | 239 |
239 string16 ap_value; | 240 base::string16 ap_value; |
240 // If we fail to read the ap key, send up "&ap=" anyway to indicate | 241 // If we fail to read the ap key, send up "&ap=" anyway to indicate |
241 // that this was probably a stable channel release. | 242 // that this was probably a stable channel release. |
242 client_state_key.ReadValue(google_update::kRegApField, &ap_value); | 243 client_state_key.ReadValue(google_update::kRegApField, &ap_value); |
243 result.append(google_update::kRegApField); | 244 result.append(google_update::kRegApField); |
244 result.append(L"="); | 245 result.append(L"="); |
245 result.append(ap_value); | 246 result.append(ap_value); |
246 | 247 |
247 return result; | 248 return result; |
248 } | 249 } |
249 | 250 |
250 string16 GoogleChromeDistribution::GetUninstallLinkName() { | 251 base::string16 GoogleChromeDistribution::GetUninstallLinkName() { |
251 const string16& link_name = | 252 const base::string16& link_name = |
252 installer::GetLocalizedString(IDS_UNINSTALL_CHROME_BASE); | 253 installer::GetLocalizedString(IDS_UNINSTALL_CHROME_BASE); |
253 return link_name; | 254 return link_name; |
254 } | 255 } |
255 | 256 |
256 string16 GoogleChromeDistribution::GetUninstallRegPath() { | 257 base::string16 GoogleChromeDistribution::GetUninstallRegPath() { |
257 return L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" | 258 return L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" |
258 L"Google Chrome"; | 259 L"Google Chrome"; |
259 } | 260 } |
260 | 261 |
261 string16 GoogleChromeDistribution::GetVersionKey() { | 262 base::string16 GoogleChromeDistribution::GetVersionKey() { |
262 string16 key(google_update::kRegPathClients); | 263 base::string16 key(google_update::kRegPathClients); |
263 key.append(L"\\"); | 264 key.append(L"\\"); |
264 key.append(product_guid()); | 265 key.append(product_guid()); |
265 return key; | 266 return key; |
266 } | 267 } |
267 | 268 |
268 string16 GoogleChromeDistribution::GetIconFilename() { | 269 base::string16 GoogleChromeDistribution::GetIconFilename() { |
269 return installer::kChromeExe; | 270 return installer::kChromeExe; |
270 } | 271 } |
271 | 272 |
272 bool GoogleChromeDistribution::GetCommandExecuteImplClsid( | 273 bool GoogleChromeDistribution::GetCommandExecuteImplClsid( |
273 string16* handler_class_uuid) { | 274 base::string16* handler_class_uuid) { |
274 if (handler_class_uuid) | 275 if (handler_class_uuid) |
275 *handler_class_uuid = kCommandExecuteImplUuid; | 276 *handler_class_uuid = kCommandExecuteImplUuid; |
276 return true; | 277 return true; |
277 } | 278 } |
278 | 279 |
279 bool GoogleChromeDistribution::AppHostIsSupported() { | 280 bool GoogleChromeDistribution::AppHostIsSupported() { |
280 return true; | 281 return true; |
281 } | 282 } |
282 | 283 |
283 // This method checks if we need to change "ap" key in Google Update to try | 284 // This method checks if we need to change "ap" key in Google Update to try |
(...skipping 12 matching lines...) Expand all Loading... |
296 product_guid()); | 297 product_guid()); |
297 } | 298 } |
298 | 299 |
299 bool GoogleChromeDistribution::ShouldSetExperimentLabels() { | 300 bool GoogleChromeDistribution::ShouldSetExperimentLabels() { |
300 return true; | 301 return true; |
301 } | 302 } |
302 | 303 |
303 bool GoogleChromeDistribution::HasUserExperiments() { | 304 bool GoogleChromeDistribution::HasUserExperiments() { |
304 return true; | 305 return true; |
305 } | 306 } |
OLD | NEW |