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

Side by Side Diff: components/update_client/updater_state_win.cc

Issue 2863993003: Refactor windows dependency out of UpdaterState class. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « components/update_client/updater_state.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/update_client/updater_state.h" 5 #include "components/update_client/updater_state.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 24 matching lines...) Expand all
35 35
36 // Google Update registry settings. 36 // Google Update registry settings.
37 const wchar_t kRegPathGoogleUpdate[] = L"Software\\Google\\Update"; 37 const wchar_t kRegPathGoogleUpdate[] = L"Software\\Google\\Update";
38 const wchar_t kRegPathClientsGoogleUpdate[] = 38 const wchar_t kRegPathClientsGoogleUpdate[] =
39 L"Software\\Google\\Update\\Clients\\" 39 L"Software\\Google\\Update\\Clients\\"
40 L"{430FD4D0-B729-4F61-AA34-91526481799D}"; 40 L"{430FD4D0-B729-4F61-AA34-91526481799D}";
41 const wchar_t kRegValueGoogleUpdatePv[] = L"pv"; 41 const wchar_t kRegValueGoogleUpdatePv[] = L"pv";
42 const wchar_t kRegValueLastStartedAU[] = L"LastStartedAU"; 42 const wchar_t kRegValueLastStartedAU[] = L"LastStartedAU";
43 const wchar_t kRegValueLastChecked[] = L"LastChecked"; 43 const wchar_t kRegValueLastChecked[] = L"LastChecked";
44 44
45 base::Time GetUpdaterTimeValue(bool is_machine, const wchar_t* value_name) {
46 const HKEY root_key = is_machine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
47 base::win::RegKey update_key;
48
49 if (update_key.Open(root_key, kRegPathGoogleUpdate,
50 KEY_QUERY_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS) {
51 DWORD value(0);
52 if (update_key.ReadValueDW(value_name, &value) == ERROR_SUCCESS) {
53 return base::Time::FromTimeT(value);
54 }
55 }
56
57 return base::Time();
58 }
59
45 } // namespace 60 } // namespace
46 61
47 std::string UpdaterState::GetUpdaterName() { 62 std::string UpdaterState::GetUpdaterName() {
48 return std::string("Omaha"); 63 return std::string("Omaha");
49 } 64 }
50 65
51 base::Version UpdaterState::GetUpdaterVersion(bool is_machine) { 66 base::Version UpdaterState::GetUpdaterVersion(bool is_machine) {
52 const HKEY root_key = is_machine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; 67 const HKEY root_key = is_machine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
53 base::string16 version; 68 base::string16 version;
54 base::win::RegKey key; 69 base::win::RegKey key;
55 70
56 if (key.Open(root_key, kRegPathClientsGoogleUpdate, 71 if (key.Open(root_key, kRegPathClientsGoogleUpdate,
57 KEY_QUERY_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS && 72 KEY_QUERY_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS &&
58 key.ReadValue(kRegValueGoogleUpdatePv, &version) == ERROR_SUCCESS) { 73 key.ReadValue(kRegValueGoogleUpdatePv, &version) == ERROR_SUCCESS) {
59 return base::Version(base::UTF16ToUTF8(version)); 74 return base::Version(base::UTF16ToUTF8(version));
60 } 75 }
61 76
62 return base::Version(); 77 return base::Version();
63 } 78 }
64 79
65 base::Time UpdaterState::GetUpdaterLastStartedAU(bool is_machine) { 80 base::Time UpdaterState::GetUpdaterLastStartedAU(bool is_machine) {
66 return GetUpdaterTimeValue(is_machine, kRegValueLastStartedAU); 81 return GetUpdaterTimeValue(is_machine, kRegValueLastStartedAU);
67 } 82 }
68 83
69 base::Time UpdaterState::GetUpdaterLastChecked(bool is_machine) { 84 base::Time UpdaterState::GetUpdaterLastChecked(bool is_machine) {
70 return GetUpdaterTimeValue(is_machine, kRegValueLastChecked); 85 return GetUpdaterTimeValue(is_machine, kRegValueLastChecked);
71 } 86 }
72 87
73 base::Time UpdaterState::GetUpdaterTimeValue(bool is_machine,
74 const wchar_t* value_name) {
75 const HKEY root_key = is_machine ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
76 base::win::RegKey update_key;
77
78 if (update_key.Open(root_key, kRegPathGoogleUpdate,
79 KEY_QUERY_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS) {
80 DWORD value(0);
81 if (update_key.ReadValueDW(value_name, &value) == ERROR_SUCCESS) {
82 return base::Time::FromTimeT(value);
83 }
84 }
85
86 return base::Time();
87 }
88
89 bool UpdaterState::IsAutoupdateCheckEnabled() { 88 bool UpdaterState::IsAutoupdateCheckEnabled() {
90 // Check the auto-update check period override. If it is 0 or exceeds the 89 // Check the auto-update check period override. If it is 0 or exceeds the
91 // maximum timeout, then for all intents and purposes auto updates are 90 // maximum timeout, then for all intents and purposes auto updates are
92 // disabled. 91 // disabled.
93 base::win::RegKey policy_key; 92 base::win::RegKey policy_key;
94 DWORD value = 0; 93 DWORD value = 0;
95 if (policy_key.Open(HKEY_LOCAL_MACHINE, kGoogleUpdatePoliciesKey, 94 if (policy_key.Open(HKEY_LOCAL_MACHINE, kGoogleUpdatePoliciesKey,
96 KEY_QUERY_VALUE) == ERROR_SUCCESS && 95 KEY_QUERY_VALUE) == ERROR_SUCCESS &&
97 policy_key.ReadValueDW(kCheckPeriodOverrideMinutes, &value) == 96 policy_key.ReadValueDW(kCheckPeriodOverrideMinutes, &value) ==
98 ERROR_SUCCESS && 97 ERROR_SUCCESS &&
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 130 }
132 131
133 return -1; 132 return -1;
134 } 133 }
135 134
136 bool UpdaterState::IsEnterpriseManaged() { 135 bool UpdaterState::IsEnterpriseManaged() {
137 return base::win::IsEnterpriseManaged(); 136 return base::win::IsEnterpriseManaged();
138 } 137 }
139 138
140 } // namespace update_client 139 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/updater_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698