OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #pragma comment(lib, "wtsapi32.lib") | 39 #pragma comment(lib, "wtsapi32.lib") |
40 | 40 |
41 namespace { | 41 namespace { |
42 | 42 |
43 const wchar_t kChromeGuid[] = L"{8A69D345-D564-463c-AFF1-A69D9E530F96}"; | 43 const wchar_t kChromeGuid[] = L"{8A69D345-D564-463c-AFF1-A69D9E530F96}"; |
44 const wchar_t kBrowserAppId[] = L"Chrome"; | 44 const wchar_t kBrowserAppId[] = L"Chrome"; |
45 | 45 |
46 // The following strings are the possible outcomes of the toast experiment | 46 // The following strings are the possible outcomes of the toast experiment |
47 // as recorded in the |client| field. Previously the groups used "TSxx" but | 47 // as recorded in the |client| field. Previously the groups used "TSxx" but |
48 // the data captured is not valid. | 48 // the data captured is not valid. |
49 const wchar_t kToastExpControlGroup[] = L"T%lc01"; | 49 const wchar_t kToastExpControlGroup[] = L"S%lc01"; |
50 const wchar_t kToastExpCancelGroup[] = L"T%lc02"; | 50 const wchar_t kToastExpCancelGroup[] = L"S%lc02"; |
51 const wchar_t kToastExpUninstallGroup[] = L"T%lc04"; | 51 const wchar_t kToastExpUninstallGroup[] = L"S%lc04"; |
52 const wchar_t kToastExpTriesOkGroup[] = L"T%lc18"; | 52 const wchar_t kToastExpTriesOkGroup[] = L"S%lc18"; |
53 const wchar_t kToastExpTriesErrorGroup[] = L"T%lc28"; | 53 const wchar_t kToastExpTriesErrorGroup[] = L"S%lc28"; |
54 const wchar_t kToastActiveGroup[] = L"T%lc40"; | 54 const wchar_t kToastActiveGroup[] = L"S%lc40"; |
55 const wchar_t kToastUDDirFailure[] = L"T%lc40"; | 55 const wchar_t kToastUDDirFailure[] = L"S%lc40"; |
56 const wchar_t kToastExpBaseGroup[] = L"T%lc80"; | 56 const wchar_t kToastExpBaseGroup[] = L"S%lc80"; |
57 | 57 |
58 // Generates the actual group string that gets written in the registry. | 58 // Generates the actual group string that gets written in the registry. |
59 // |group| is one of the above kToast* strings and |flavor| is a number | 59 // |group| is one of the above kToast* strings and |flavor| is a number |
60 // from 0 to 3. | 60 // from 0 to 3. |
61 // | 61 // |
62 // The big experiment in Dec 2009 used TGxx and THxx. | 62 // The big experiment in Dec 2009 used TGxx and THxx. |
63 // The big experiment in Feb 2010 used TKxx and TLxx. | 63 // The big experiment in Feb 2010 used TKxx and TLxx. |
64 // The big experiment in Apr 2010 used TMxx and TNxx. | 64 // The big experiment in Apr 2010 used TMxx and TNxx. |
65 // The big experiment in Oct 2010 (current) uses TVxx TWxx TXxx TYxx. | 65 // The big experiment in Oct 2010 used TVxx TWxx TXxx TYxx. |
| 66 // The Japan experiment in Feb 2011 uses S{J,K,L,M}xx |
66 std::wstring GetExperimentGroup(const wchar_t* group, int flavor) { | 67 std::wstring GetExperimentGroup(const wchar_t* group, int flavor) { |
67 wchar_t c = flavor < 4 ? L'V' + flavor : L'Z'; | 68 wchar_t c = flavor < 3 ? L'J' + flavor : L'M'; |
68 return StringPrintf(group, c); | 69 return StringPrintf(group, c); |
69 } | 70 } |
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 std::wstring LocalizeUrl(const wchar_t* url) { |
75 std::wstring language; | 76 std::wstring 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. |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 } | 567 } |
567 } else { | 568 } else { |
568 if ((installer_util::NEW_VERSION_UPDATED != status) && | 569 if ((installer_util::NEW_VERSION_UPDATED != status) && |
569 (installer_util::REENTRY_SYS_UPDATE != status)) { | 570 (installer_util::REENTRY_SYS_UPDATE != status)) { |
570 // We are not updating or in re-launch. Exit. | 571 // We are not updating or in re-launch. Exit. |
571 return; | 572 return; |
572 } | 573 } |
573 } | 574 } |
574 | 575 |
575 // This ends up being processed by ShowTryChromeDialog to show different | 576 // This ends up being processed by ShowTryChromeDialog to show different |
576 // experiments. Only run the experiment in en-US. | 577 // experiments. Use flavor 2 for everyone but Japanese. |
577 int flavor = 0; | 578 int flavor = 2; |
578 std::wstring language; | 579 std::wstring language; |
579 if (GoogleUpdateSettings::GetLanguage(&language) && (language == L"en-US")) | 580 if (GoogleUpdateSettings::GetLanguage(&language) && |
580 flavor = base::RandInt(0, 3); | 581 language == L"ja") { |
| 582 flavor = base::RandInt(0, 2); |
| 583 } |
581 | 584 |
582 std::wstring brand; | 585 std::wstring brand; |
583 if (GoogleUpdateSettings::GetBrand(&brand) && (brand == L"CHXX")) { | 586 if (GoogleUpdateSettings::GetBrand(&brand) && (brand == L"CHXX")) { |
584 // Testing only: the user automatically qualifies for the experiment. | 587 // Testing only: the user automatically qualifies for the experiment. |
585 VLOG(1) << "Experiment qualification bypass"; | 588 VLOG(1) << "Experiment qualification bypass"; |
586 } else { | 589 } else { |
587 // Check browser usage inactivity by the age of the last-write time of the | 590 // Check browser usage inactivity by the age of the last-write time of the |
588 // chrome user data directory. | 591 // chrome user data directory. |
589 std::wstring user_data_dir = installer::GetChromeUserDataPath(); | 592 std::wstring user_data_dir = installer::GetChromeUserDataPath(); |
590 // TODO(cpu): re-enable experiment. | 593 const bool experiment_enabled = true; |
591 const int kThirtyDays = 3000 * 24; | 594 const int kThirtyDays = 30 * 24; |
| 595 |
592 int dir_age_hours = GetDirectoryWriteAgeInHours(user_data_dir.c_str()); | 596 int dir_age_hours = GetDirectoryWriteAgeInHours(user_data_dir.c_str()); |
593 if (dir_age_hours < 0) { | 597 if (!experiment_enabled) { |
| 598 VLOG(1) << "Toast experiment is disabled."; |
| 599 return; |
| 600 } else if (dir_age_hours < 0) { |
594 // This means that we failed to find the user data dir. The most likely | 601 // This means that we failed to find the user data dir. The most likely |
595 // cause is that this user has not ever used chrome at all which can | 602 // cause is that this user has not ever used chrome at all which can |
596 // happen in a system-level install. | 603 // happen in a system-level install. |
597 SetClient(GetExperimentGroup(kToastUDDirFailure, flavor), true); | 604 SetClient(GetExperimentGroup(kToastUDDirFailure, flavor), true); |
598 return; | 605 return; |
599 } else if (dir_age_hours < kThirtyDays) { | 606 } else if (dir_age_hours < kThirtyDays) { |
600 // An active user, so it does not qualify. | 607 // An active user, so it does not qualify. |
601 VLOG(1) << "Chrome used in last " << dir_age_hours << " hours"; | 608 VLOG(1) << "Chrome used in last " << dir_age_hours << " hours"; |
602 SetClient(GetExperimentGroup(kToastActiveGroup, flavor), true); | 609 SetClient(GetExperimentGroup(kToastActiveGroup, flavor), true); |
603 return; | 610 return; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 | 665 |
659 if (outcome != kToastExpUninstallGroup) | 666 if (outcome != kToastExpUninstallGroup) |
660 return; | 667 return; |
661 // The user wants to uninstall. This is a best effort operation. Note that | 668 // The user wants to uninstall. This is a best effort operation. Note that |
662 // we waited for chrome to exit so the uninstall would not detect chrome | 669 // we waited for chrome to exit so the uninstall would not detect chrome |
663 // running. | 670 // running. |
664 base::LaunchApp(InstallUtil::GetChromeUninstallCmd(system_install), | 671 base::LaunchApp(InstallUtil::GetChromeUninstallCmd(system_install), |
665 false, false, NULL); | 672 false, false, NULL); |
666 } | 673 } |
667 #endif | 674 #endif |
OLD | NEW |