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

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

Powered by Google App Engine
This is Rietveld 408576698