Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(977)

Side by Side Diff: chrome/installer/util/google_chrome_distribution.cc

Issue 10246007: Fix GetAppShortcutName to return a localized name for Chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: last nits Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <vector>
10 #include <windows.h> 11 #include <windows.h>
11 #include <wtsapi32.h> 12 #include <wtsapi32.h>
12 #include <msi.h> 13 #include <msi.h>
13 #include <sddl.h> 14 #include <sddl.h>
14 15
15 #include "base/command_line.h" 16 #include "base/command_line.h"
16 #include "base/file_path.h" 17 #include "base/file_path.h"
17 #include "base/json/json_file_value_serializer.h" 18 #include "base/json/json_file_value_serializer.h"
18 #include "base/memory/scoped_ptr.h" 19 #include "base/memory/scoped_ptr.h"
19 #include "base/path_service.h" 20 #include "base/path_service.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 const wchar_t kToastExpUninstallGroup[] = L"04"; 65 const wchar_t kToastExpUninstallGroup[] = L"04";
65 const wchar_t kToastExpTriesOkGroup[] = L"18"; 66 const wchar_t kToastExpTriesOkGroup[] = L"18";
66 const wchar_t kToastExpTriesErrorGroup[] = L"28"; 67 const wchar_t kToastExpTriesErrorGroup[] = L"28";
67 const wchar_t kToastActiveGroup[] = L"40"; 68 const wchar_t kToastActiveGroup[] = L"40";
68 const wchar_t kToastUDDirFailure[] = L"40"; 69 const wchar_t kToastUDDirFailure[] = L"40";
69 const wchar_t kToastExpBaseGroup[] = L"80"; 70 const wchar_t kToastExpBaseGroup[] = L"80";
70 71
71 // Substitute the locale parameter in uninstall URL with whatever 72 // Substitute the locale parameter in uninstall URL with whatever
72 // Google Update tells us is the locale. In case we fail to find 73 // Google Update tells us is the locale. In case we fail to find
73 // the locale, we use US English. 74 // the locale, we use US English.
74 std::wstring LocalizeUrl(const wchar_t* url) { 75 string16 LocalizeUrl(const wchar_t* url) {
75 std::wstring language; 76 string16 language;
76 if (!GoogleUpdateSettings::GetLanguage(&language)) 77 if (!GoogleUpdateSettings::GetLanguage(&language))
77 language = L"en-US"; // Default to US English. 78 language = L"en-US"; // Default to US English.
78 return ReplaceStringPlaceholders(url, language.c_str(), NULL); 79 return ReplaceStringPlaceholders(url, language.c_str(), NULL);
79 } 80 }
80 81
81 std::wstring GetUninstallSurveyUrl() { 82 string16 GetUninstallSurveyUrl() {
82 const wchar_t kSurveyUrl[] = L"http://www.google.com/support/chrome/bin/" 83 const wchar_t kSurveyUrl[] = L"http://www.google.com/support/chrome/bin/"
83 L"request.py?hl=$1&contact_type=uninstall"; 84 L"request.py?hl=$1&contact_type=uninstall";
84 return LocalizeUrl(kSurveyUrl); 85 return LocalizeUrl(kSurveyUrl);
85 } 86 }
86 87
87 std::wstring GetWelcomeBackUrl() { 88 string16 GetWelcomeBackUrl() {
88 const wchar_t kWelcomeUrl[] = L"http://www.google.com/chrome/intl/$1/" 89 const wchar_t kWelcomeUrl[] = L"http://www.google.com/chrome/intl/$1/"
89 L"welcomeback-new.html"; 90 L"welcomeback-new.html";
90 return LocalizeUrl(kWelcomeUrl); 91 return LocalizeUrl(kWelcomeUrl);
91 } 92 }
92 93
93 // Converts FILETIME to hours. FILETIME times are absolute times in 94 // Converts FILETIME to hours. FILETIME times are absolute times in
94 // 100 nanosecond units. For example 5:30 pm of June 15, 2009 is 3580464. 95 // 100 nanosecond units. For example 5:30 pm of June 15, 2009 is 3580464.
95 int FileTimeToHours(const FILETIME& time) { 96 int FileTimeToHours(const FILETIME& time) {
96 const ULONGLONG k100sNanoSecsToHours = 10000000LL * 60 * 60; 97 const ULONGLONG k100sNanoSecsToHours = 10000000LL * 60 * 60;
97 ULARGE_INTEGER uli = {time.dwLowDateTime, time.dwHighDateTime}; 98 ULARGE_INTEGER uli = {time.dwLowDateTime, time.dwHighDateTime};
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 DWORD len = sizeof(buff); 190 DWORD len = sizeof(buff);
190 PSECURITY_DESCRIPTOR sd = reinterpret_cast<PSECURITY_DESCRIPTOR>(buff); 191 PSECURITY_DESCRIPTOR sd = reinterpret_cast<PSECURITY_DESCRIPTOR>(buff);
191 if (!::GetFileSecurityW(exe.value().c_str(), DACL_SECURITY_INFORMATION, 192 if (!::GetFileSecurityW(exe.value().c_str(), DACL_SECURITY_INFORMATION,
192 sd, len, &len)) { 193 sd, len, &len)) {
193 return false; 194 return false;
194 } 195 }
195 wchar_t* sddl = 0; 196 wchar_t* sddl = 0;
196 if (!::ConvertSecurityDescriptorToStringSecurityDescriptorW(sd, 197 if (!::ConvertSecurityDescriptorToStringSecurityDescriptorW(sd,
197 SDDL_REVISION_1, DACL_SECURITY_INFORMATION, &sddl, NULL)) 198 SDDL_REVISION_1, DACL_SECURITY_INFORMATION, &sddl, NULL))
198 return false; 199 return false;
199 std::wstring new_sddl(sddl); 200 string16 new_sddl(sddl);
200 ::LocalFree(sddl); 201 ::LocalFree(sddl);
201 sd = NULL; 202 sd = NULL;
202 // See MSDN for the security descriptor definition language (SDDL) syntax, 203 // See MSDN for the security descriptor definition language (SDDL) syntax,
203 // in our case we add "A;" generic read 'GR' and generic execute 'GX' for 204 // in our case we add "A;" generic read 'GR' and generic execute 'GX' for
204 // the nt\authenticated_users 'AU' group, that becomes: 205 // the nt\authenticated_users 'AU' group, that becomes:
205 const wchar_t kAllowACE[] = L"(A;;GRGX;;;AU)"; 206 const wchar_t kAllowACE[] = L"(A;;GRGX;;;AU)";
206 // We should check that there are no special ACES for the group we 207 // We should check that there are no special ACES for the group we
207 // are interested, which is nt\authenticated_users. 208 // are interested, which is nt\authenticated_users.
208 if (std::wstring::npos != new_sddl.find(L";AU)")) 209 if (string16::npos != new_sddl.find(L";AU)"))
209 return false; 210 return false;
210 // Specific ACEs (not inherited) need to go to the front. It is ok if we 211 // Specific ACEs (not inherited) need to go to the front. It is ok if we
211 // are the very first one. 212 // are the very first one.
212 size_t pos_insert = new_sddl.find(L"("); 213 size_t pos_insert = new_sddl.find(L"(");
213 if (std::wstring::npos == pos_insert) 214 if (string16::npos == pos_insert)
214 return false; 215 return false;
215 // All good, time to change the dacl. 216 // All good, time to change the dacl.
216 new_sddl.insert(pos_insert, kAllowACE); 217 new_sddl.insert(pos_insert, kAllowACE);
217 if (!::ConvertStringSecurityDescriptorToSecurityDescriptorW(new_sddl.c_str(), 218 if (!::ConvertStringSecurityDescriptorToSecurityDescriptorW(new_sddl.c_str(),
218 SDDL_REVISION_1, &sd, NULL)) 219 SDDL_REVISION_1, &sd, NULL))
219 return false; 220 return false;
220 bool rv = ::SetFileSecurityW(exe.value().c_str(), DACL_SECURITY_INFORMATION, 221 bool rv = ::SetFileSecurityW(exe.value().c_str(), DACL_SECURITY_INFORMATION,
221 sd) == TRUE; 222 sd) == TRUE;
222 ::LocalFree(sd); 223 ::LocalFree(sd);
223 return rv; 224 return rv;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 291
291 GoogleChromeDistribution::GoogleChromeDistribution() 292 GoogleChromeDistribution::GoogleChromeDistribution()
292 : BrowserDistribution(CHROME_BROWSER), 293 : BrowserDistribution(CHROME_BROWSER),
293 product_guid_(kChromeGuid) { 294 product_guid_(kChromeGuid) {
294 } 295 }
295 296
296 // The functions below are not used by the 64-bit Windows binary - 297 // The functions below are not used by the 64-bit Windows binary -
297 // see the comment in google_chrome_distribution_dummy.cc 298 // see the comment in google_chrome_distribution_dummy.cc
298 #ifndef _WIN64 299 #ifndef _WIN64
299 bool GoogleChromeDistribution::BuildUninstallMetricsString( 300 bool GoogleChromeDistribution::BuildUninstallMetricsString(
300 DictionaryValue* uninstall_metrics_dict, std::wstring* metrics) { 301 DictionaryValue* uninstall_metrics_dict, string16* metrics) {
301 DCHECK(NULL != metrics); 302 DCHECK(NULL != metrics);
302 bool has_values = false; 303 bool has_values = false;
303 304
304 for (DictionaryValue::key_iterator iter(uninstall_metrics_dict->begin_keys()); 305 for (DictionaryValue::key_iterator iter(uninstall_metrics_dict->begin_keys());
305 iter != uninstall_metrics_dict->end_keys(); ++iter) { 306 iter != uninstall_metrics_dict->end_keys(); ++iter) {
306 has_values = true; 307 has_values = true;
307 metrics->append(L"&"); 308 metrics->append(L"&");
308 metrics->append(UTF8ToWide(*iter)); 309 metrics->append(UTF8ToWide(*iter));
309 metrics->append(L"="); 310 metrics->append(L"=");
310 311
311 std::string value; 312 std::string value;
312 uninstall_metrics_dict->GetStringWithoutPathExpansion(*iter, &value); 313 uninstall_metrics_dict->GetStringWithoutPathExpansion(*iter, &value);
313 metrics->append(UTF8ToWide(value)); 314 metrics->append(UTF8ToWide(value));
314 } 315 }
315 316
316 return has_values; 317 return has_values;
317 } 318 }
318 319
319 bool GoogleChromeDistribution::ExtractUninstallMetricsFromFile( 320 bool GoogleChromeDistribution::ExtractUninstallMetricsFromFile(
320 const FilePath& file_path, 321 const FilePath& file_path,
321 std::wstring* uninstall_metrics_string) { 322 string16* uninstall_metrics_string) {
322 JSONFileValueSerializer json_serializer(file_path); 323 JSONFileValueSerializer json_serializer(file_path);
323 324
324 std::string json_error_string; 325 std::string json_error_string;
325 scoped_ptr<Value> root(json_serializer.Deserialize(NULL, NULL)); 326 scoped_ptr<Value> root(json_serializer.Deserialize(NULL, NULL));
326 if (!root.get()) 327 if (!root.get())
327 return false; 328 return false;
328 329
329 // Preferences should always have a dictionary root. 330 // Preferences should always have a dictionary root.
330 if (!root->IsType(Value::TYPE_DICTIONARY)) 331 if (!root->IsType(Value::TYPE_DICTIONARY))
331 return false; 332 return false;
332 333
333 return ExtractUninstallMetrics(*static_cast<DictionaryValue*>(root.get()), 334 return ExtractUninstallMetrics(*static_cast<DictionaryValue*>(root.get()),
334 uninstall_metrics_string); 335 uninstall_metrics_string);
335 } 336 }
336 337
337 bool GoogleChromeDistribution::ExtractUninstallMetrics( 338 bool GoogleChromeDistribution::ExtractUninstallMetrics(
338 const DictionaryValue& root, std::wstring* uninstall_metrics_string) { 339 const DictionaryValue& root,
340 string16* uninstall_metrics_string) {
339 // Make sure that the user wants us reporting metrics. If not, don't 341 // Make sure that the user wants us reporting metrics. If not, don't
340 // add our uninstall metrics. 342 // add our uninstall metrics.
341 bool metrics_reporting_enabled = false; 343 bool metrics_reporting_enabled = false;
342 if (!root.GetBoolean(prefs::kMetricsReportingEnabled, 344 if (!root.GetBoolean(prefs::kMetricsReportingEnabled,
343 &metrics_reporting_enabled) || 345 &metrics_reporting_enabled) ||
344 !metrics_reporting_enabled) { 346 !metrics_reporting_enabled) {
345 return false; 347 return false;
346 } 348 }
347 349
348 DictionaryValue* uninstall_metrics_dict; 350 DictionaryValue* uninstall_metrics_dict;
349 if (!root.HasKey(installer::kUninstallMetricsName) || 351 if (!root.HasKey(installer::kUninstallMetricsName) ||
350 !root.GetDictionary(installer::kUninstallMetricsName, 352 !root.GetDictionary(installer::kUninstallMetricsName,
351 &uninstall_metrics_dict)) { 353 &uninstall_metrics_dict)) {
352 return false; 354 return false;
353 } 355 }
354 356
355 if (!BuildUninstallMetricsString(uninstall_metrics_dict, 357 if (!BuildUninstallMetricsString(uninstall_metrics_dict,
356 uninstall_metrics_string)) { 358 uninstall_metrics_string)) {
357 return false; 359 return false;
358 } 360 }
359 361
360 return true; 362 return true;
361 } 363 }
362 #endif 364 #endif
363 365
364 void GoogleChromeDistribution::DoPostUninstallOperations( 366 void GoogleChromeDistribution::DoPostUninstallOperations(
365 const Version& version, 367 const Version& version,
366 const FilePath& local_data_path, 368 const FilePath& local_data_path,
367 const std::wstring& distribution_data) { 369 const string16& distribution_data) {
368 // Send the Chrome version and OS version as params to the form. 370 // Send the Chrome version and OS version as params to the form.
369 // It would be nice to send the locale, too, but I don't see an 371 // It would be nice to send the locale, too, but I don't see an
370 // easy way to get that in the existing code. It's something we 372 // easy way to get that in the existing code. It's something we
371 // can add later, if needed. 373 // can add later, if needed.
372 // We depend on installed_version.GetString() not having spaces or other 374 // We depend on installed_version.GetString() not having spaces or other
373 // characters that need escaping: 0.2.13.4. Should that change, we will 375 // characters that need escaping: 0.2.13.4. Should that change, we will
374 // need to escape the string before using it in a URL. 376 // need to escape the string before using it in a URL.
375 const std::wstring kVersionParam = L"crversion"; 377 const string16 kVersionParam = L"crversion";
376 const std::wstring kOSParam = L"os"; 378 const string16 kOSParam = L"os";
377 base::win::OSInfo::VersionNumber version_number = 379 base::win::OSInfo::VersionNumber version_number =
378 base::win::OSInfo::GetInstance()->version_number(); 380 base::win::OSInfo::GetInstance()->version_number();
379 std::wstring os_version = base::StringPrintf(L"%d.%d.%d", 381 string16 os_version = base::StringPrintf(L"%d.%d.%d",
380 version_number.major, version_number.minor, version_number.build); 382 version_number.major, version_number.minor, version_number.build);
381 383
382 FilePath iexplore; 384 FilePath iexplore;
383 if (!PathService::Get(base::DIR_PROGRAM_FILES, &iexplore)) 385 if (!PathService::Get(base::DIR_PROGRAM_FILES, &iexplore))
384 return; 386 return;
385 387
386 iexplore = iexplore.AppendASCII("Internet Explorer"); 388 iexplore = iexplore.AppendASCII("Internet Explorer");
387 iexplore = iexplore.AppendASCII("iexplore.exe"); 389 iexplore = iexplore.AppendASCII("iexplore.exe");
388 390
389 std::wstring command = iexplore.value() + L" " + GetUninstallSurveyUrl() + 391 string16 command = iexplore.value() + L" " + GetUninstallSurveyUrl() +
390 L"&" + kVersionParam + L"=" + UTF8ToWide(version.GetString()) + L"&" + 392 L"&" + kVersionParam + L"=" + UTF8ToWide(version.GetString()) + L"&" +
391 kOSParam + L"=" + os_version; 393 kOSParam + L"=" + os_version;
392 394
393 std::wstring uninstall_metrics; 395 string16 uninstall_metrics;
394 if (ExtractUninstallMetricsFromFile(local_data_path, &uninstall_metrics)) { 396 if (ExtractUninstallMetricsFromFile(local_data_path, &uninstall_metrics)) {
395 // The user has opted into anonymous usage data collection, so append 397 // The user has opted into anonymous usage data collection, so append
396 // metrics and distribution data. 398 // metrics and distribution data.
397 command += uninstall_metrics; 399 command += uninstall_metrics;
398 if (!distribution_data.empty()) { 400 if (!distribution_data.empty()) {
399 command += L"&"; 401 command += L"&";
400 command += distribution_data; 402 command += distribution_data;
401 } 403 }
402 } 404 }
403 405
404 int pid = 0; 406 int pid = 0;
405 // The reason we use WMI to launch the process is because the uninstall 407 // The reason we use WMI to launch the process is because the uninstall
406 // process runs inside a Job object controlled by the shell. As long as there 408 // process runs inside a Job object controlled by the shell. As long as there
407 // are processes running, the shell will not close the uninstall applet. WMI 409 // are processes running, the shell will not close the uninstall applet. WMI
408 // allows us to escape from the Job object so the applet will close. 410 // allows us to escape from the Job object so the applet will close.
409 installer::WMIProcess::Launch(command, &pid); 411 installer::WMIProcess::Launch(command, &pid);
410 } 412 }
411 413
412 std::wstring GoogleChromeDistribution::GetAppGuid() { 414 string16 GoogleChromeDistribution::GetAppGuid() {
413 return product_guid(); 415 return product_guid();
414 } 416 }
415 417
416 std::wstring GoogleChromeDistribution::GetApplicationName() { 418 string16 GoogleChromeDistribution::GetApplicationName() {
417 // I'd really like to return L ## PRODUCT_FULLNAME_STRING; but that's no good 419 // I'd really like to return L ## PRODUCT_FULLNAME_STRING; but that's no good
418 // since it'd be "Chromium" in a non-Chrome build, which isn't at all what I 420 // since it'd be "Chromium" in a non-Chrome build, which isn't at all what I
419 // want. Sigh. 421 // want. Sigh.
420 return L"Google Chrome"; 422 return L"Google Chrome";
421 } 423 }
422 424
423 std::wstring GoogleChromeDistribution::GetAlternateApplicationName() { 425 string16 GoogleChromeDistribution::GetAppShortCutName() {
424 const std::wstring& alt_product_name = 426 const string16& app_shortcut_name =
427 installer::GetLocalizedString(IDS_PRODUCT_NAME_BASE);
428 return app_shortcut_name;
429 }
430
431 string16 GoogleChromeDistribution::GetAlternateApplicationName() {
432 const string16& alt_product_name =
425 installer::GetLocalizedString(IDS_OEM_MAIN_SHORTCUT_NAME_BASE); 433 installer::GetLocalizedString(IDS_OEM_MAIN_SHORTCUT_NAME_BASE);
426 return alt_product_name; 434 return alt_product_name;
427 } 435 }
428 436
429 std::wstring GoogleChromeDistribution::GetBrowserAppId() { 437 string16 GoogleChromeDistribution::GetBrowserAppId() {
430 return kBrowserAppId; 438 return kBrowserAppId;
431 } 439 }
432 440
433 std::wstring GoogleChromeDistribution::GetInstallSubDir() { 441 string16 GoogleChromeDistribution::GetInstallSubDir() {
434 std::wstring sub_dir(installer::kGoogleChromeInstallSubDir1); 442 string16 sub_dir(installer::kGoogleChromeInstallSubDir1);
435 sub_dir.append(L"\\"); 443 sub_dir.append(L"\\");
436 sub_dir.append(installer::kGoogleChromeInstallSubDir2); 444 sub_dir.append(installer::kGoogleChromeInstallSubDir2);
437 return sub_dir; 445 return sub_dir;
438 } 446 }
439 447
440 std::wstring GoogleChromeDistribution::GetPublisherName() { 448 string16 GoogleChromeDistribution::GetPublisherName() {
441 const std::wstring& publisher_name = 449 const string16& publisher_name =
442 installer::GetLocalizedString(IDS_ABOUT_VERSION_COMPANY_NAME_BASE); 450 installer::GetLocalizedString(IDS_ABOUT_VERSION_COMPANY_NAME_BASE);
443 return publisher_name; 451 return publisher_name;
444 } 452 }
445 453
446 std::wstring GoogleChromeDistribution::GetAppDescription() { 454 string16 GoogleChromeDistribution::GetAppDescription() {
447 const std::wstring& app_description = 455 const string16& app_description =
448 installer::GetLocalizedString(IDS_SHORTCUT_TOOLTIP_BASE); 456 installer::GetLocalizedString(IDS_SHORTCUT_TOOLTIP_BASE);
449 return app_description; 457 return app_description;
450 } 458 }
451 459
452 std::string GoogleChromeDistribution::GetSafeBrowsingName() { 460 std::string GoogleChromeDistribution::GetSafeBrowsingName() {
453 return "googlechrome"; 461 return "googlechrome";
454 } 462 }
455 463
456 std::wstring GoogleChromeDistribution::GetStateKey() { 464 string16 GoogleChromeDistribution::GetStateKey() {
457 std::wstring key(google_update::kRegPathClientState); 465 string16 key(google_update::kRegPathClientState);
458 key.append(L"\\"); 466 key.append(L"\\");
459 key.append(product_guid()); 467 key.append(product_guid());
460 return key; 468 return key;
461 } 469 }
462 470
463 std::wstring GoogleChromeDistribution::GetStateMediumKey() { 471 string16 GoogleChromeDistribution::GetStateMediumKey() {
464 std::wstring key(google_update::kRegPathClientStateMedium); 472 string16 key(google_update::kRegPathClientStateMedium);
465 key.append(L"\\"); 473 key.append(L"\\");
466 key.append(product_guid()); 474 key.append(product_guid());
467 return key; 475 return key;
468 } 476 }
469 477
470 std::wstring GoogleChromeDistribution::GetStatsServerURL() { 478 string16 GoogleChromeDistribution::GetStatsServerURL() {
471 return L"https://clients4.google.com/firefox/metrics/collect"; 479 return L"https://clients4.google.com/firefox/metrics/collect";
472 } 480 }
473 481
474 std::string GoogleChromeDistribution::GetNetworkStatsServer() const { 482 std::string GoogleChromeDistribution::GetNetworkStatsServer() const {
475 return chrome_common_net::kEchoTestServerLocation; 483 return chrome_common_net::kEchoTestServerLocation;
476 } 484 }
477 485
478 std::string GoogleChromeDistribution::GetHttpPipeliningTestServer() const { 486 std::string GoogleChromeDistribution::GetHttpPipeliningTestServer() const {
479 return chrome_common_net::kPipelineTestServerBaseUrl; 487 return chrome_common_net::kPipelineTestServerBaseUrl;
480 } 488 }
481 489
482 std::wstring GoogleChromeDistribution::GetDistributionData(HKEY root_key) { 490 string16 GoogleChromeDistribution::GetDistributionData(HKEY root_key) {
483 std::wstring sub_key(google_update::kRegPathClientState); 491 string16 sub_key(google_update::kRegPathClientState);
484 sub_key.append(L"\\"); 492 sub_key.append(L"\\");
485 sub_key.append(product_guid()); 493 sub_key.append(product_guid());
486 494
487 base::win::RegKey client_state_key(root_key, sub_key.c_str(), KEY_READ); 495 base::win::RegKey client_state_key(root_key, sub_key.c_str(), KEY_READ);
488 std::wstring result; 496 string16 result;
489 std::wstring brand_value; 497 string16 brand_value;
490 if (client_state_key.ReadValue(google_update::kRegRLZBrandField, 498 if (client_state_key.ReadValue(google_update::kRegRLZBrandField,
491 &brand_value) == ERROR_SUCCESS) { 499 &brand_value) == ERROR_SUCCESS) {
492 result = google_update::kRegRLZBrandField; 500 result = google_update::kRegRLZBrandField;
493 result.append(L"="); 501 result.append(L"=");
494 result.append(brand_value); 502 result.append(brand_value);
495 result.append(L"&"); 503 result.append(L"&");
496 } 504 }
497 505
498 std::wstring client_value; 506 string16 client_value;
499 if (client_state_key.ReadValue(google_update::kRegClientField, 507 if (client_state_key.ReadValue(google_update::kRegClientField,
500 &client_value) == ERROR_SUCCESS) { 508 &client_value) == ERROR_SUCCESS) {
501 result.append(google_update::kRegClientField); 509 result.append(google_update::kRegClientField);
502 result.append(L"="); 510 result.append(L"=");
503 result.append(client_value); 511 result.append(client_value);
504 result.append(L"&"); 512 result.append(L"&");
505 } 513 }
506 514
507 std::wstring ap_value; 515 string16 ap_value;
508 // If we fail to read the ap key, send up "&ap=" anyway to indicate 516 // If we fail to read the ap key, send up "&ap=" anyway to indicate
509 // that this was probably a stable channel release. 517 // that this was probably a stable channel release.
510 client_state_key.ReadValue(google_update::kRegApField, &ap_value); 518 client_state_key.ReadValue(google_update::kRegApField, &ap_value);
511 result.append(google_update::kRegApField); 519 result.append(google_update::kRegApField);
512 result.append(L"="); 520 result.append(L"=");
513 result.append(ap_value); 521 result.append(ap_value);
514 522
515 return result; 523 return result;
516 } 524 }
517 525
518 std::wstring GoogleChromeDistribution::GetUninstallLinkName() { 526 string16 GoogleChromeDistribution::GetUninstallLinkName() {
519 const std::wstring& link_name = 527 const string16& link_name =
520 installer::GetLocalizedString(IDS_UNINSTALL_CHROME_BASE); 528 installer::GetLocalizedString(IDS_UNINSTALL_CHROME_BASE);
521 return link_name; 529 return link_name;
522 } 530 }
523 531
524 std::wstring GoogleChromeDistribution::GetUninstallRegPath() { 532 string16 GoogleChromeDistribution::GetUninstallRegPath() {
525 return L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" 533 return L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"
526 L"Google Chrome"; 534 L"Google Chrome";
527 } 535 }
528 536
529 std::wstring GoogleChromeDistribution::GetVersionKey() { 537 string16 GoogleChromeDistribution::GetVersionKey() {
530 std::wstring key(google_update::kRegPathClients); 538 string16 key(google_update::kRegPathClients);
531 key.append(L"\\"); 539 key.append(L"\\");
532 key.append(product_guid()); 540 key.append(product_guid());
533 return key; 541 return key;
534 } 542 }
535 543
536 bool GoogleChromeDistribution::GetDelegateExecuteHandlerData( 544 bool GoogleChromeDistribution::GetDelegateExecuteHandlerData(
537 string16* handler_class_uuid, 545 string16* handler_class_uuid,
538 string16* type_lib_uuid, 546 string16* type_lib_uuid,
539 string16* type_lib_version, 547 string16* type_lib_version,
540 string16* interface_uuid) { 548 string16* interface_uuid) {
(...skipping 28 matching lines...) Expand all
569 product_guid()); 577 product_guid());
570 } 578 }
571 579
572 // The functions below are not used by the 64-bit Windows binary - 580 // The functions below are not used by the 64-bit Windows binary -
573 // see the comment in google_chrome_distribution_dummy.cc 581 // see the comment in google_chrome_distribution_dummy.cc
574 #ifndef _WIN64 582 #ifndef _WIN64
575 // A helper function that writes to HKLM if the handle was passed through the 583 // A helper function that writes to HKLM if the handle was passed through the
576 // command line, but HKCU otherwise. |experiment_group| is the value to write 584 // command line, but HKCU otherwise. |experiment_group| is the value to write
577 // and |last_write| is used when writing to HKLM to determine whether to close 585 // and |last_write| is used when writing to HKLM to determine whether to close
578 // the handle when done. 586 // the handle when done.
579 void SetClient(const std::wstring& experiment_group, bool last_write) { 587 void SetClient(const string16& experiment_group, bool last_write) {
580 static int reg_key_handle = -1; 588 static int reg_key_handle = -1;
581 if (reg_key_handle == -1) { 589 if (reg_key_handle == -1) {
582 // If a specific Toast Results key handle (presumably to our HKLM key) was 590 // If a specific Toast Results key handle (presumably to our HKLM key) was
583 // passed in to the command line (such as for system level installs), we use 591 // passed in to the command line (such as for system level installs), we use
584 // it. Otherwise, we write to the key under HKCU. 592 // it. Otherwise, we write to the key under HKCU.
585 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); 593 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess();
586 if (cmd_line.HasSwitch(installer::switches::kToastResultsKey)) { 594 if (cmd_line.HasSwitch(installer::switches::kToastResultsKey)) {
587 // Get the handle to the key under HKLM. 595 // Get the handle to the key under HKLM.
588 base::StringToInt(cmd_line.GetSwitchValueASCII( 596 base::StringToInt(cmd_line.GetSwitchValueASCII(
589 installer::switches::kToastResultsKey).c_str(), 597 installer::switches::kToastResultsKey).c_str(),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 645
638 // The experiment with the more compact bubble. This one is a bit special 646 // The experiment with the more compact bubble. This one is a bit special
639 // because it is split into two: CAxx is regular style bubble and CBxx is 647 // because it is split into two: CAxx is regular style bubble and CBxx is
640 // compact style bubble. See |compact_bubble| below. 648 // compact style bubble. See |compact_bubble| below.
641 {L"en-US", kBrief, 1, L'C', L'A', 2, { kEnUs3, kEnUs3, 0, 0 } }, 649 {L"en-US", kBrief, 1, L'C', L'A', 2, { kEnUs3, kEnUs3, 0, 0 } },
642 650
643 // Catch-all rules. 651 // Catch-all rules.
644 {kAll, kAll, 1, L'B', L'A', 1, {kEnUs3, 0, 0, 0} }, 652 {kAll, kAll, 1, L'B', L'A', 1, {kEnUs3, 0, 0, 0} },
645 }; 653 };
646 654
647 std::wstring locale; 655 string16 locale;
648 std::wstring brand; 656 string16 brand;
649 657
650 if (!GoogleUpdateSettings::GetLanguage(&locale)) 658 if (!GoogleUpdateSettings::GetLanguage(&locale))
651 locale = ASCIIToWide("en-US"); 659 locale = ASCIIToWide("en-US");
652 if (!GoogleUpdateSettings::GetBrand(&brand)) 660 if (!GoogleUpdateSettings::GetBrand(&brand))
653 brand = ASCIIToWide(""); // Could still be viable for catch-all rules. 661 brand = ASCIIToWide(""); // Could still be viable for catch-all rules.
654 if (brand == kEnterprise) 662 if (brand == kEnterprise)
655 return false; 663 return false;
656 664
657 for (int i = 0; i < arraysize(kExperimentFlavors); ++i) { 665 for (int i = 0; i < arraysize(kExperimentFlavors); ++i) {
658 // A maximum of four flavors are supported at the moment. 666 // A maximum of four flavors are supported at the moment.
659 DCHECK_LE(kExperimentFlavors[i].flavors, kMax); 667 DCHECK_LE(kExperimentFlavors[i].flavors, kMax);
660 DCHECK_GT(kExperimentFlavors[i].flavors, 0); 668 DCHECK_GT(kExperimentFlavors[i].flavors, 0);
661 // Make sure each experiment has valid headings. 669 // Make sure each experiment has valid headings.
662 for (int f = 0; f < kMax; ++f) { 670 for (int f = 0; f < kMax; ++f) {
663 if (f < kExperimentFlavors[i].flavors) { 671 if (f < kExperimentFlavors[i].flavors) {
664 DCHECK_GT(kExperimentFlavors[i].headings[f], 0); 672 DCHECK_GT(kExperimentFlavors[i].headings[f], 0);
665 } else { 673 } else {
666 DCHECK_EQ(kExperimentFlavors[i].headings[f], 0); 674 DCHECK_EQ(kExperimentFlavors[i].headings[f], 0);
667 } 675 }
668 } 676 }
669 // Make sure we don't overflow on the second letter of the experiment code. 677 // Make sure we don't overflow on the second letter of the experiment code.
670 DCHECK(kExperimentFlavors[i].prefix2 + 678 DCHECK(kExperimentFlavors[i].prefix2 +
671 kExperimentFlavors[i].flavors - 1 <= 'Z'); 679 kExperimentFlavors[i].flavors - 1 <= 'Z');
672 680
673 if (kExperimentFlavors[i].locale != locale && 681 if (kExperimentFlavors[i].locale != locale &&
674 kExperimentFlavors[i].locale != ASCIIToWide("*")) 682 kExperimentFlavors[i].locale != ASCIIToWide("*"))
675 continue; 683 continue;
676 684
677 std::vector<std::wstring> brand_codes; 685 std::vector<string16> brand_codes;
678 base::SplitString(kExperimentFlavors[i].brands, L',', &brand_codes); 686 base::SplitString(kExperimentFlavors[i].brands, L',', &brand_codes);
679 if (brand_codes.empty()) 687 if (brand_codes.empty())
680 return false; 688 return false;
681 for (std::vector<std::wstring>::iterator it = brand_codes.begin(); 689 for (std::vector<string16>::iterator it = brand_codes.begin();
682 it != brand_codes.end(); ++it) { 690 it != brand_codes.end(); ++it) {
683 if (*it != brand && *it != L"*") 691 if (*it != brand && *it != L"*")
684 continue; 692 continue;
685 693
686 // We have found our match. 694 // We have found our match.
687 if (flavor < 0) 695 if (flavor < 0)
688 flavor = base::RandInt(0, kExperimentFlavors[i].flavors - 1); 696 flavor = base::RandInt(0, kExperimentFlavors[i].flavors - 1);
689 experiment->flavor = flavor; 697 experiment->flavor = flavor;
690 experiment->heading = kExperimentFlavors[i].headings[flavor]; 698 experiment->heading = kExperimentFlavors[i].headings[flavor];
691 experiment->control_group = kExperimentFlavors[i].control_group; 699 experiment->control_group = kExperimentFlavors[i].control_group;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 } 741 }
734 742
735 // The |flavor| value ends up being processed by TryChromeDialogView to show 743 // The |flavor| value ends up being processed by TryChromeDialogView to show
736 // different experiments. 744 // different experiments.
737 UserExperiment experiment; 745 UserExperiment experiment;
738 if (!GetExperimentDetails(&experiment, -1)) { 746 if (!GetExperimentDetails(&experiment, -1)) {
739 VLOG(1) << "Failed to get experiment details."; 747 VLOG(1) << "Failed to get experiment details.";
740 return; 748 return;
741 } 749 }
742 int flavor = experiment.flavor; 750 int flavor = experiment.flavor;
743 std::wstring base_group = experiment.prefix; 751 string16 base_group = experiment.prefix;
744 752
745 std::wstring brand; 753 string16 brand;
746 if (GoogleUpdateSettings::GetBrand(&brand) && (brand == L"CHXX")) { 754 if (GoogleUpdateSettings::GetBrand(&brand) && (brand == L"CHXX")) {
747 // Testing only: the user automatically qualifies for the experiment. 755 // Testing only: the user automatically qualifies for the experiment.
748 VLOG(1) << "Experiment qualification bypass"; 756 VLOG(1) << "Experiment qualification bypass";
749 } else { 757 } else {
750 // Check browser usage inactivity by the age of the last-write time of the 758 // Check browser usage inactivity by the age of the last-write time of the
751 // chrome user data directory. 759 // chrome user data directory.
752 FilePath user_data_dir(product.GetUserDataPath()); 760 FilePath user_data_dir(product.GetUserDataPath());
753 761
754 const bool experiment_enabled = false; 762 const bool experiment_enabled = false;
755 const int kThirtyDays = 30 * 24; 763 const int kThirtyDays = 30 * 24;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 cmd_line.AppendSwitchASCII(installer::switches::kInactiveUserToast, 798 cmd_line.AppendSwitchASCII(installer::switches::kInactiveUserToast,
791 base::IntToString(flavor)); 799 base::IntToString(flavor));
792 cmd_line.AppendSwitchASCII(installer::switches::kExperimentGroup, 800 cmd_line.AppendSwitchASCII(installer::switches::kExperimentGroup,
793 WideToASCII(base_group)); 801 WideToASCII(base_group));
794 LaunchSetup(&cmd_line, product, system_level); 802 LaunchSetup(&cmd_line, product, system_level);
795 } 803 }
796 804
797 // User qualifies for the experiment. To test, use --try-chrome-again=|flavor| 805 // User qualifies for the experiment. To test, use --try-chrome-again=|flavor|
798 // as a parameter to chrome.exe. 806 // as a parameter to chrome.exe.
799 void GoogleChromeDistribution::InactiveUserToastExperiment(int flavor, 807 void GoogleChromeDistribution::InactiveUserToastExperiment(int flavor,
800 const std::wstring& experiment_group, 808 const string16& experiment_group,
801 const installer::Product& installation, 809 const installer::Product& installation,
802 const FilePath& application_path) { 810 const FilePath& application_path) {
803 bool has_welcome_url = (flavor == 0); 811 bool has_welcome_url = (flavor == 0);
804 // Possibly add a url to launch depending on the experiment flavor. 812 // Possibly add a url to launch depending on the experiment flavor.
805 CommandLine options(CommandLine::NO_PROGRAM); 813 CommandLine options(CommandLine::NO_PROGRAM);
806 options.AppendSwitchNative(switches::kTryChromeAgain, 814 options.AppendSwitchNative(switches::kTryChromeAgain,
807 base::IntToString16(flavor)); 815 base::IntToString16(flavor));
808 if (has_welcome_url) { 816 if (has_welcome_url) {
809 // Prepend the url with a space. 817 // Prepend the url with a space.
810 std::wstring url(GetWelcomeBackUrl()); 818 string16 url(GetWelcomeBackUrl());
811 options.AppendArg("--"); 819 options.AppendArg("--");
812 options.AppendArgNative(url); 820 options.AppendArgNative(url);
813 // The command line should now have the url added as: 821 // The command line should now have the url added as:
814 // "chrome.exe -- <url>" 822 // "chrome.exe -- <url>"
815 DCHECK_NE(std::wstring::npos, 823 DCHECK_NE(string16::npos,
816 options.GetCommandLineString().find(L" -- " + url)); 824 options.GetCommandLineString().find(L" -- " + url));
817 } 825 }
818 // Launch chrome now. It will show the toast UI. 826 // Launch chrome now. It will show the toast UI.
819 int32 exit_code = 0; 827 int32 exit_code = 0;
820 if (!installation.LaunchChromeAndWait(application_path, options, &exit_code)) 828 if (!installation.LaunchChromeAndWait(application_path, options, &exit_code))
821 return; 829 return;
822 830
823 // The chrome process has exited, figure out what happened. 831 // The chrome process has exited, figure out what happened.
824 const wchar_t* outcome = NULL; 832 const wchar_t* outcome = NULL;
825 switch (exit_code) { 833 switch (exit_code) {
(...skipping 20 matching lines...) Expand all
846 // we waited for chrome to exit so the uninstall would not detect chrome 854 // we waited for chrome to exit so the uninstall would not detect chrome
847 // running. 855 // running.
848 bool system_level_toast = CommandLine::ForCurrentProcess()->HasSwitch( 856 bool system_level_toast = CommandLine::ForCurrentProcess()->HasSwitch(
849 installer::switches::kSystemLevelToast); 857 installer::switches::kSystemLevelToast);
850 858
851 CommandLine cmd(InstallUtil::GetChromeUninstallCmd(system_level_toast, 859 CommandLine cmd(InstallUtil::GetChromeUninstallCmd(system_level_toast,
852 GetType())); 860 GetType()));
853 base::LaunchProcess(cmd, base::LaunchOptions(), NULL); 861 base::LaunchProcess(cmd, base::LaunchOptions(), NULL);
854 } 862 }
855 #endif 863 #endif
OLDNEW
« no previous file with comments | « chrome/installer/util/google_chrome_distribution.h ('k') | chrome/installer/util/google_chrome_distribution_dummy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698