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

Unified Diff: chrome/installer/util/google_update_settings.cc

Issue 1606943007: Implement Windows GPO support for "dlpref" in component updater. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: whitespace comments only Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/installer/util/google_update_settings.cc
diff --git a/chrome/installer/util/google_update_settings.cc b/chrome/installer/util/google_update_settings.cc
index e32e185d354c26607c7908f55f5c52ebb02a78c3..6ed2852de7797fcf4adba45b12e75797bde10438 100644
--- a/chrome/installer/util/google_update_settings.cc
+++ b/chrome/installer/util/google_update_settings.cc
@@ -8,6 +8,7 @@
#include <algorithm>
#include <limits>
+#include <vector>
#include "base/command_line.h"
#include "base/files/file_path.h"
@@ -36,6 +37,8 @@ using installer::InstallationState;
const wchar_t GoogleUpdateSettings::kPoliciesKey[] =
L"SOFTWARE\\Policies\\Google\\Update";
const wchar_t GoogleUpdateSettings::kUpdatePolicyValue[] = L"UpdateDefault";
+const wchar_t GoogleUpdateSettings::kDownloadPreferencePolicyValue[] =
+ L"DownloadPreference";
const wchar_t GoogleUpdateSettings::kUpdateOverrideValuePrefix[] = L"Update";
const wchar_t GoogleUpdateSettings::kCheckPeriodOverrideMinutes[] =
L"AutoUpdateCheckPeriodMinutes";
@@ -770,6 +773,30 @@ bool GoogleUpdateSettings::ReenableAutoupdates() {
return true;
}
+// Reads and sanitizes the value of
+// "HKLM\SOFTWARE\Policies\Google\Update\DownloadPreference". A valid
+// group policy option must be a single alpha numeric word of up to 32
+// characters.
+base::string16 GoogleUpdateSettings::GetDownloadPreference() {
+ RegKey policy_key;
+ base::string16 value;
+ if (policy_key.Open(HKEY_LOCAL_MACHINE, kPoliciesKey, KEY_QUERY_VALUE) ==
+ ERROR_SUCCESS &&
+ policy_key.ReadValue(kDownloadPreferencePolicyValue, &value) ==
+ ERROR_SUCCESS) {
+ // Validates that |value| matches `[a-zA-z]{0-32}`.
+ const size_t kMaxValueLength = 32;
+ if (value.size() > kMaxValueLength)
+ return base::string16();
+ for (auto ch : value) {
+ if (!base::IsAsciiAlpha(ch))
+ return base::string16();
+ }
+ return value;
+ }
+ return base::string16();
+}
+
void GoogleUpdateSettings::RecordChromeUpdatePolicyHistograms() {
const bool is_multi_install = InstallUtil::IsMultiInstall(
BrowserDistribution::GetDistribution(), IsSystemInstall());
« no previous file with comments | « chrome/installer/util/google_update_settings.h ('k') | chrome/installer/util/google_update_settings_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698