Index: chrome/installer/util/update_active_setup_version_work_item.cc |
diff --git a/chrome/installer/util/update_active_setup_version_work_item.cc b/chrome/installer/util/update_active_setup_version_work_item.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..fa504f480a7dfcc0ff1e063ddf970e48e83ac1f0 |
--- /dev/null |
+++ b/chrome/installer/util/update_active_setup_version_work_item.cc |
@@ -0,0 +1,63 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/installer/util/update_active_setup_version_work_item.h" |
+ |
+#include <vector> |
+ |
+#include "base/bind.h" |
+#include "base/logging.h" |
+#include "base/strings/string_number_conversions.h" |
+#include "base/strings/string_split.h" |
+#include "base/strings/string_util.h" |
+ |
+namespace { |
+ |
+// The major version and first component of the version identifying the work |
+// done by setup.exe --configure-user-settings on user login by way of Active |
+// Setup. Increase this value if the work done when handling Active Setup |
+// should be executed again for all existing users. |
+const base::char16 kActiveSetupMajorVersion[] = L"43"; |
+ |
+} // namespace |
+ |
+UpdateActiveSetupVersionWorkItem::UpdateActiveSetupVersionWorkItem( |
+ const base::string16& active_setup_path, |
+ Operation operation) |
+ : SetRegValueWorkItem( |
+ HKEY_LOCAL_MACHINE, |
+ active_setup_path, |
+ WorkItem::kWow64Default, |
+ L"Version", |
+ base::Bind( |
+ &UpdateActiveSetupVersionWorkItem::GetUpdatedActiveSetupVersion, |
+ base::Unretained(this))), |
+ operation_(operation) { |
+} |
+ |
+base::string16 UpdateActiveSetupVersionWorkItem::GetUpdatedActiveSetupVersion( |
+ const base::string16& existing_version) { |
+ std::vector<base::string16> version_components = base::SplitString( |
+ existing_version, L",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
+ |
+ // If |existing_version| was empty or otherwise corrupted, turn it into a |
+ // valid one. |
+ if (version_components.size() != 4U) |
+ version_components.assign(4U, L"0"); |
+ |
+ // Unconditionally update the major version. |
+ version_components[MAJOR] = kActiveSetupMajorVersion; |
+ |
+ if (operation_ == UPDATE_AND_BUMP_OS_UPGRADES_COMPONENT) { |
+ unsigned previous_value; |
grt (UTC plus 2)
2015/07/09 14:23:53
please use uint32_t here even though StringToUint
gab
2015/07/09 20:36:38
Done, but curious what's the reasoning behind this
grt (UTC plus 2)
2015/07/10 15:37:27
http://google-styleguide.googlecode.com/svn/trunk/
|
+ if (!base::StringToUint(version_components[OS_UPGRADES], &previous_value)) { |
+ LOG(WARNING) << "Couldn't process previous OS_UPGRADES Active Setup " |
+ << "version component: " << version_components[OS_UPGRADES]; |
grt (UTC plus 2)
2015/07/09 14:23:53
nit: remove first << so that the compiler can conc
gab
2015/07/09 20:36:37
Done.
|
+ previous_value = 0; |
+ } |
+ version_components[OS_UPGRADES] = base::UintToString16(previous_value + 1); |
+ } |
+ |
+ return JoinString(version_components, L','); |
+} |