OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/installer/util/user_experiment.h" | 5 #include "chrome/installer/util/user_experiment.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <sddl.h> | 8 #include <sddl.h> |
9 #include <wtsapi32.h> | 9 #include <wtsapi32.h> |
10 #include <vector> | 10 #include <vector> |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 bool system_level) { | 388 bool system_level) { |
389 if (system_level) { | 389 if (system_level) { |
390 if (NEW_VERSION_UPDATED == status) { | 390 if (NEW_VERSION_UPDATED == status) { |
391 CommandLine cmd_line(base_cmd_line); | 391 CommandLine cmd_line(base_cmd_line); |
392 cmd_line.AppendSwitch(switches::kSystemLevelToast); | 392 cmd_line.AppendSwitch(switches::kSystemLevelToast); |
393 // We need to relaunch as the interactive user. | 393 // We need to relaunch as the interactive user. |
394 LaunchSetupAsConsoleUser(&cmd_line); | 394 LaunchSetupAsConsoleUser(&cmd_line); |
395 return; | 395 return; |
396 } | 396 } |
397 } else { | 397 } else { |
398 if ((NEW_VERSION_UPDATED != status) && (REENTRY_SYS_UPDATE != status)) { | 398 if (status != NEW_VERSION_UPDATED && status != REENTRY_SYS_UPDATE) { |
399 // We are not updating or in re-launch. Exit. | 399 // We are not updating or in re-launch. Exit. |
400 return; | 400 return; |
401 } | 401 } |
402 } | 402 } |
403 | 403 |
404 // The |flavor| value ends up being processed by TryChromeDialogView to show | 404 // The |flavor| value ends up being processed by TryChromeDialogView to show |
405 // different experiments. | 405 // different experiments. |
406 ExperimentDetails experiment; | 406 ExperimentDetails experiment; |
407 if (!CreateExperimentDetails(-1, &experiment)) { | 407 if (!CreateExperimentDetails(-1, &experiment)) { |
408 VLOG(1) << "Failed to get experiment details."; | 408 VLOG(1) << "Failed to get experiment details."; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 base::IntToString(flavor)); | 477 base::IntToString(flavor)); |
478 cmd_line.AppendSwitchASCII(switches::kExperimentGroup, | 478 cmd_line.AppendSwitchASCII(switches::kExperimentGroup, |
479 WideToASCII(base_group)); | 479 WideToASCII(base_group)); |
480 LaunchSetup(&cmd_line, system_level); | 480 LaunchSetup(&cmd_line, system_level); |
481 } | 481 } |
482 | 482 |
483 // User qualifies for the experiment. To test, use --try-chrome-again=|flavor| | 483 // User qualifies for the experiment. To test, use --try-chrome-again=|flavor| |
484 // as a parameter to chrome.exe. | 484 // as a parameter to chrome.exe. |
485 void InactiveUserToastExperiment(int flavor, | 485 void InactiveUserToastExperiment(int flavor, |
486 const string16& experiment_group, | 486 const string16& experiment_group, |
487 const Product& installation, | 487 const Product& product, |
488 const base::FilePath& application_path) { | 488 const base::FilePath& application_path) { |
489 // Add the 'welcome back' url for chrome to show. | 489 // Add the 'welcome back' url for chrome to show. |
490 CommandLine options(CommandLine::NO_PROGRAM); | 490 CommandLine options(CommandLine::NO_PROGRAM); |
491 options.AppendSwitchNative(::switches::kTryChromeAgain, | 491 options.AppendSwitchNative(::switches::kTryChromeAgain, |
492 base::IntToString16(flavor)); | 492 base::IntToString16(flavor)); |
493 // Prepend the url with a space. | 493 // Prepend the url with a space. |
494 string16 url(GetWelcomeBackUrl()); | 494 string16 url(GetWelcomeBackUrl()); |
495 options.AppendArg("--"); | 495 options.AppendArg("--"); |
496 options.AppendArgNative(url); | 496 options.AppendArgNative(url); |
497 // The command line should now have the url added as: | 497 // The command line should now have the url added as: |
498 // "chrome.exe -- <url>" | 498 // "chrome.exe -- <url>" |
499 DCHECK_NE(string16::npos, | 499 DCHECK_NE(string16::npos, |
500 options.GetCommandLineString().find(L" -- " + url)); | 500 options.GetCommandLineString().find(L" -- " + url)); |
501 | 501 |
502 // Launch chrome now. It will show the toast UI. | 502 // Launch chrome now. It will show the toast UI. |
503 int32 exit_code = 0; | 503 int32 exit_code = 0; |
504 if (!installation.LaunchChromeAndWait(application_path, options, &exit_code)) | 504 if (!product.LaunchChromeAndWait(application_path, options, &exit_code)) |
505 return; | 505 return; |
506 | 506 |
507 // The chrome process has exited, figure out what happened. | 507 // The chrome process has exited, figure out what happened. |
508 const wchar_t* outcome = NULL; | 508 const wchar_t* outcome = NULL; |
509 switch (exit_code) { | 509 switch (exit_code) { |
510 case content::RESULT_CODE_NORMAL_EXIT: | 510 case content::RESULT_CODE_NORMAL_EXIT: |
511 outcome = kToastExpTriesOkGroup; | 511 outcome = kToastExpTriesOkGroup; |
512 break; | 512 break; |
513 case chrome::RESULT_CODE_NORMAL_EXIT_CANCEL: | 513 case chrome::RESULT_CODE_NORMAL_EXIT_CANCEL: |
514 outcome = kToastExpCancelGroup; | 514 outcome = kToastExpCancelGroup; |
515 break; | 515 break; |
516 case chrome::RESULT_CODE_NORMAL_EXIT_EXP2: | 516 case chrome::RESULT_CODE_NORMAL_EXIT_EXP2: |
517 outcome = kToastExpUninstallGroup; | 517 outcome = kToastExpUninstallGroup; |
518 break; | 518 break; |
519 default: | 519 default: |
520 outcome = kToastExpTriesErrorGroup; | 520 outcome = kToastExpTriesErrorGroup; |
521 }; | 521 }; |
522 // Write to the |client| key for the last time. | 522 // Write to the |client| key for the last time. |
523 SetClient(experiment_group + outcome, true); | 523 SetClient(experiment_group + outcome, true); |
524 | 524 |
525 if (outcome != kToastExpUninstallGroup) | 525 if (outcome != kToastExpUninstallGroup) |
526 return; | 526 return; |
527 // The user wants to uninstall. This is a best effort operation. Note that | 527 // The user wants to uninstall. This is a best effort operation. Note that |
528 // we waited for chrome to exit so the uninstall would not detect chrome | 528 // we waited for chrome to exit so the uninstall would not detect chrome |
529 // running. | 529 // running. |
530 bool system_level_toast = CommandLine::ForCurrentProcess()->HasSwitch( | 530 bool system_level_toast = CommandLine::ForCurrentProcess()->HasSwitch( |
531 switches::kSystemLevelToast); | 531 switches::kSystemLevelToast); |
532 | 532 |
533 CommandLine cmd(InstallUtil::GetChromeUninstallCmd(system_level_toast, | 533 CommandLine cmd(InstallUtil::GetChromeUninstallCmd( |
534 installation.distribution()->GetType())); | 534 system_level_toast, product.distribution()->GetType())); |
535 base::LaunchProcess(cmd, base::LaunchOptions(), NULL); | 535 base::LaunchProcess(cmd, base::LaunchOptions(), NULL); |
536 } | 536 } |
537 | 537 |
538 } // namespace installer | 538 } // namespace installer |
OLD | NEW |