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

Side by Side Diff: chrome/installer/util/update_active_setup_version_work_item.cc

Issue 1223953003: Introduce UpdateActiveSetupVersionWorkItem (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@a1_active_setup_onosup_addCB_API
Patch Set: Do not support negative values (operate on unsigned ints) Created 5 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/installer/util/update_active_setup_version_work_item.h"
6
7 #include <vector>
8
9 #include "base/bind.h"
10 #include "base/logging.h"
11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_split.h"
13 #include "base/strings/string_util.h"
14
15 namespace {
16
17 // The major version and first component of the version identifying the work
18 // done by setup.exe --configure-user-settings on user login by way of Active
19 // Setup. Increase this value if the work done when handling Active Setup
20 // should be executed again for all existing users.
21 const base::char16 kActiveSetupMajorVersion[] = L"43";
22
23 } // namespace
24
25 UpdateActiveSetupVersionWorkItem::UpdateActiveSetupVersionWorkItem(
26 const base::string16& active_setup_path,
27 Operation operation)
28 : SetRegValueWorkItem(
29 HKEY_LOCAL_MACHINE,
30 active_setup_path,
31 WorkItem::kWow64Default,
32 L"Version",
33 base::Bind(
34 &UpdateActiveSetupVersionWorkItem::GetUpdatedActiveSetupVersion,
35 base::Unretained(this))),
36 operation_(operation) {
37 }
38
39 base::string16 UpdateActiveSetupVersionWorkItem::GetUpdatedActiveSetupVersion(
40 const base::string16& existing_version) {
41 std::vector<base::string16> version_components = base::SplitString(
42 existing_version, L",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
43
44 // If |existing_version| was empty or otherwise corrupted, turn it into a
45 // valid one.
46 if (version_components.size() != 4U)
47 version_components.assign(4U, L"0");
48
49 // Unconditionally update the major version.
50 version_components[MAJOR] = kActiveSetupMajorVersion;
51
52 if (operation_ == UPDATE_AND_BUMP_OS_UPGRADES_COMPONENT) {
53 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/
54 if (!base::StringToUint(version_components[OS_UPGRADES], &previous_value)) {
55 LOG(WARNING) << "Couldn't process previous OS_UPGRADES Active Setup "
56 << "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.
57 previous_value = 0;
58 }
59 version_components[OS_UPGRADES] = base::UintToString16(previous_value + 1);
60 }
61
62 return JoinString(version_components, L',');
63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698