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 <vector> | 10 #include <vector> |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 // Check that the user was not already drafted in this experiment. | 757 // Check that the user was not already drafted in this experiment. |
758 string16 client; | 758 string16 client; |
759 GoogleUpdateSettings::GetClient(&client); | 759 GoogleUpdateSettings::GetClient(&client); |
760 if (client.size() > 2) { | 760 if (client.size() > 2) { |
761 if (base_group == client.substr(0, 2)) { | 761 if (base_group == client.substr(0, 2)) { |
762 VLOG(1) << "User already participated in this experiment"; | 762 VLOG(1) << "User already participated in this experiment"; |
763 return; | 763 return; |
764 } | 764 } |
765 } | 765 } |
766 // Check browser usage inactivity by the age of the last-write time of the | 766 // Check browser usage inactivity by the age of the last-write time of the |
767 // chrome user data directory. | 767 // most recently-used chrome user data directory. |
768 FilePath user_data_dir(product.GetUserDataPath()); | 768 std::vector<FilePath> user_data_dirs; |
| 769 product.GetUserDataPaths(&user_data_dirs); |
| 770 int dir_age_hours = -1; |
| 771 for (size_t i = 0; i < user_data_dirs.size(); ++i) { |
| 772 int this_age = GetDirectoryWriteAgeInHours( |
| 773 user_data_dirs[i].value().c_str()); |
| 774 if (this_age >= 0 && (dir_age_hours < 0 || this_age < dir_age_hours)) |
| 775 dir_age_hours = this_age; |
| 776 } |
769 | 777 |
770 const bool experiment_enabled = false; | 778 const bool experiment_enabled = false; |
771 const int kThirtyDays = 30 * 24; | 779 const int kThirtyDays = 30 * 24; |
772 | 780 |
773 int dir_age_hours = GetDirectoryWriteAgeInHours( | |
774 user_data_dir.value().c_str()); | |
775 if (!experiment_enabled) { | 781 if (!experiment_enabled) { |
776 VLOG(1) << "Toast experiment is disabled."; | 782 VLOG(1) << "Toast experiment is disabled."; |
777 return; | 783 return; |
778 } else if (dir_age_hours < 0) { | 784 } else if (dir_age_hours < 0) { |
779 // This means that we failed to find the user data dir. The most likely | 785 // This means that we failed to find the user data dir. The most likely |
780 // cause is that this user has not ever used chrome at all which can | 786 // cause is that this user has not ever used chrome at all which can |
781 // happen in a system-level install. | 787 // happen in a system-level install. |
782 SetClient(base_group + kToastUDDirFailure, true); | 788 SetClient(base_group + kToastUDDirFailure, true); |
783 return; | 789 return; |
784 } else if (dir_age_hours < kThirtyDays) { | 790 } else if (dir_age_hours < kThirtyDays) { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 // we waited for chrome to exit so the uninstall would not detect chrome | 878 // we waited for chrome to exit so the uninstall would not detect chrome |
873 // running. | 879 // running. |
874 bool system_level_toast = CommandLine::ForCurrentProcess()->HasSwitch( | 880 bool system_level_toast = CommandLine::ForCurrentProcess()->HasSwitch( |
875 installer::switches::kSystemLevelToast); | 881 installer::switches::kSystemLevelToast); |
876 | 882 |
877 CommandLine cmd(InstallUtil::GetChromeUninstallCmd(system_level_toast, | 883 CommandLine cmd(InstallUtil::GetChromeUninstallCmd(system_level_toast, |
878 GetType())); | 884 GetType())); |
879 base::LaunchProcess(cmd, base::LaunchOptions(), NULL); | 885 base::LaunchProcess(cmd, base::LaunchOptions(), NULL); |
880 } | 886 } |
881 #endif | 887 #endif |
OLD | NEW |