Chromium Code Reviews| 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 #include "chrome/installer/util/google_update_settings.h" | 5 #include "chrome/installer/util/google_update_settings.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <limits> | 10 #include <limits> |
| 11 #include <vector> | |
| 11 | 12 |
| 12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 14 #include "base/logging.h" | 15 #include "base/logging.h" |
| 15 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 16 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| 17 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/threading/thread_restrictions.h" | 21 #include "base/threading/thread_restrictions.h" |
| 21 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 22 #include "base/win/registry.h" | 23 #include "base/win/registry.h" |
| 23 #include "base/win/win_util.h" | 24 #include "base/win/win_util.h" |
| 24 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 25 #include "chrome/installer/util/app_registration_data.h" | 26 #include "chrome/installer/util/app_registration_data.h" |
| 26 #include "chrome/installer/util/browser_distribution.h" | 27 #include "chrome/installer/util/browser_distribution.h" |
| 27 #include "chrome/installer/util/channel_info.h" | 28 #include "chrome/installer/util/channel_info.h" |
| 28 #include "chrome/installer/util/google_update_constants.h" | 29 #include "chrome/installer/util/google_update_constants.h" |
| 29 #include "chrome/installer/util/install_util.h" | 30 #include "chrome/installer/util/install_util.h" |
| 30 #include "chrome/installer/util/installation_state.h" | 31 #include "chrome/installer/util/installation_state.h" |
| 31 #include "chrome/installer/util/product.h" | 32 #include "chrome/installer/util/product.h" |
| 32 | 33 |
| 33 using base::win::RegKey; | 34 using base::win::RegKey; |
| 34 using installer::InstallationState; | 35 using installer::InstallationState; |
| 35 | 36 |
| 36 const wchar_t GoogleUpdateSettings::kPoliciesKey[] = | 37 const wchar_t GoogleUpdateSettings::kPoliciesKey[] = |
| 37 L"SOFTWARE\\Policies\\Google\\Update"; | 38 L"SOFTWARE\\Policies\\Google\\Update"; |
| 38 const wchar_t GoogleUpdateSettings::kUpdatePolicyValue[] = L"UpdateDefault"; | 39 const wchar_t GoogleUpdateSettings::kUpdatePolicyValue[] = L"UpdateDefault"; |
| 40 const wchar_t GoogleUpdateSettings::kDownloadPreference[] = | |
| 41 L"DownloadPreference"; | |
| 42 const wchar_t GoogleUpdateSettings::kDownloadPreferenceCacheable[] = | |
| 43 L"cacheable"; | |
| 39 const wchar_t GoogleUpdateSettings::kUpdateOverrideValuePrefix[] = L"Update"; | 44 const wchar_t GoogleUpdateSettings::kUpdateOverrideValuePrefix[] = L"Update"; |
| 40 const wchar_t GoogleUpdateSettings::kCheckPeriodOverrideMinutes[] = | 45 const wchar_t GoogleUpdateSettings::kCheckPeriodOverrideMinutes[] = |
| 41 L"AutoUpdateCheckPeriodMinutes"; | 46 L"AutoUpdateCheckPeriodMinutes"; |
| 42 | 47 |
| 43 // Don't allow update periods longer than six weeks. | 48 // Don't allow update periods longer than six weeks. |
| 44 const int GoogleUpdateSettings::kCheckPeriodOverrideMinutesMax = | 49 const int GoogleUpdateSettings::kCheckPeriodOverrideMinutesMax = |
| 45 60 * 24 * 7 * 6; | 50 60 * 24 * 7 * 6; |
| 46 | 51 |
| 47 const GoogleUpdateSettings::UpdatePolicy | 52 const GoogleUpdateSettings::UpdatePolicy |
| 48 GoogleUpdateSettings::kDefaultUpdatePolicy = | 53 GoogleUpdateSettings::kDefaultUpdatePolicy = |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 763 // permissions to make changes (the most likely reason is that there is no | 768 // permissions to make changes (the most likely reason is that there is no |
| 764 // policy set). Simply return whether or not we think updates are enabled. | 769 // policy set). Simply return whether or not we think updates are enabled. |
| 765 return AreAutoupdatesEnabled(); | 770 return AreAutoupdatesEnabled(); |
| 766 } | 771 } |
| 767 | 772 |
| 768 #endif | 773 #endif |
| 769 // Non Google Chrome isn't going to autoupdate. | 774 // Non Google Chrome isn't going to autoupdate. |
| 770 return true; | 775 return true; |
| 771 } | 776 } |
| 772 | 777 |
| 778 // Reads and sanitizes the value of | |
| 779 // "HKLM\SOFTWARE\Policies\Google\Update\DownloadPreference". The current | |
| 780 // implementation supports only "cacheable" as a valid policy option. | |
|
waffles
2016/01/21 01:56:08
Do we want to consider an alternate sanitization p
Sorin Jianu
2016/01/21 02:53:55
I've sanitized by hand since adding a dependency o
| |
| 781 base::string16 GoogleUpdateSettings::GetDownloadPreference() { | |
| 782 RegKey policy_key; | |
| 783 base::string16 value; | |
| 784 if (policy_key.Open(HKEY_LOCAL_MACHINE, kPoliciesKey, KEY_QUERY_VALUE) == | |
| 785 ERROR_SUCCESS && | |
| 786 policy_key.ReadValue(kDownloadPreference, &value) == ERROR_SUCCESS && | |
| 787 value == GoogleUpdateSettings::kDownloadPreferenceCacheable) { | |
| 788 return value; | |
| 789 } | |
| 790 return base::string16(); | |
| 791 } | |
| 792 | |
| 773 void GoogleUpdateSettings::RecordChromeUpdatePolicyHistograms() { | 793 void GoogleUpdateSettings::RecordChromeUpdatePolicyHistograms() { |
| 774 const bool is_multi_install = InstallUtil::IsMultiInstall( | 794 const bool is_multi_install = InstallUtil::IsMultiInstall( |
| 775 BrowserDistribution::GetDistribution(), IsSystemInstall()); | 795 BrowserDistribution::GetDistribution(), IsSystemInstall()); |
| 776 const base::string16 app_guid = | 796 const base::string16 app_guid = |
| 777 BrowserDistribution::GetSpecificDistribution( | 797 BrowserDistribution::GetSpecificDistribution( |
| 778 is_multi_install ? BrowserDistribution::CHROME_BINARIES : | 798 is_multi_install ? BrowserDistribution::CHROME_BINARIES : |
| 779 BrowserDistribution::CHROME_BROWSER)->GetAppGuid(); | 799 BrowserDistribution::CHROME_BROWSER)->GetAppGuid(); |
| 780 | 800 |
| 781 bool is_overridden = false; | 801 bool is_overridden = false; |
| 782 const UpdatePolicy update_policy = GetAppUpdatePolicy(app_guid, | 802 const UpdatePolicy update_policy = GetAppUpdatePolicy(app_guid, |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 971 } | 991 } |
| 972 | 992 |
| 973 // If the key or value was not present, return the empty string. | 993 // If the key or value was not present, return the empty string. |
| 974 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { | 994 if (result == ERROR_FILE_NOT_FOUND || result == ERROR_PATH_NOT_FOUND) { |
| 975 experiment_labels->clear(); | 995 experiment_labels->clear(); |
| 976 return true; | 996 return true; |
| 977 } | 997 } |
| 978 | 998 |
| 979 return result == ERROR_SUCCESS; | 999 return result == ERROR_SUCCESS; |
| 980 } | 1000 } |
| OLD | NEW |