OLD | NEW |
1 | 1 |
2 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 2 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 | 5 |
6 #include "components/update_client/updater_state.h" | 6 #include "components/update_client/updater_state.h" |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 | 15 |
16 namespace update_client { | 16 namespace update_client { |
17 | 17 |
18 const char UpdaterState::kDomainJoined[] = "domainjoined"; | 18 const char UpdaterState::kIsEnterpriseUser[] = "domainjoined"; |
19 | 19 |
20 UpdaterState::UpdaterState(bool is_machine) : is_machine_(is_machine) {} | 20 UpdaterState::UpdaterState(bool is_machine) : is_machine_(is_machine) {} |
21 | 21 |
22 UpdaterState::~UpdaterState() {} | 22 UpdaterState::~UpdaterState() {} |
23 | 23 |
24 std::unique_ptr<UpdaterState::Attributes> UpdaterState::GetState( | 24 std::unique_ptr<UpdaterState::Attributes> UpdaterState::GetState( |
25 bool is_machine) { | 25 bool is_machine) { |
26 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
27 UpdaterState updater_state(is_machine); | 27 UpdaterState updater_state(is_machine); |
28 updater_state.ReadState(); | 28 updater_state.ReadState(); |
29 return base::MakeUnique<Attributes>(updater_state.BuildAttributes()); | 29 return base::MakeUnique<Attributes>(updater_state.BuildAttributes()); |
30 #else | 30 #else |
31 return nullptr; | 31 return nullptr; |
32 #endif // OS_WIN | 32 #endif // OS_WIN |
33 } | 33 } |
34 | 34 |
35 #if defined(OS_WIN) | 35 #if defined(OS_WIN) |
36 void UpdaterState::ReadState() { | 36 void UpdaterState::ReadState() { |
37 is_joined_to_domain_ = IsJoinedToDomain(); | 37 is_enterprise_user_ = IsEnterpriseUser(); |
38 | 38 |
39 #if defined(GOOGLE_CHROME_BUILD) | 39 #if defined(GOOGLE_CHROME_BUILD) |
40 updater_name_ = GetUpdaterName(); | 40 updater_name_ = GetUpdaterName(); |
41 updater_version_ = GetUpdaterVersion(is_machine_); | 41 updater_version_ = GetUpdaterVersion(is_machine_); |
42 last_autoupdate_started_ = GetUpdaterLastStartedAU(is_machine_); | 42 last_autoupdate_started_ = GetUpdaterLastStartedAU(is_machine_); |
43 last_checked_ = GetUpdaterLastChecked(is_machine_); | 43 last_checked_ = GetUpdaterLastChecked(is_machine_); |
44 is_autoupdate_check_enabled_ = IsAutoupdateCheckEnabled(); | 44 is_autoupdate_check_enabled_ = IsAutoupdateCheckEnabled(); |
45 update_policy_ = GetUpdatePolicy(); | 45 update_policy_ = GetUpdatePolicy(); |
46 #endif // GOOGLE_CHROME_BUILD | 46 #endif // GOOGLE_CHROME_BUILD |
47 } | 47 } |
48 #endif // OS_WIN | 48 #endif // OS_WIN |
49 | 49 |
50 UpdaterState::Attributes UpdaterState::BuildAttributes() const { | 50 UpdaterState::Attributes UpdaterState::BuildAttributes() const { |
51 Attributes attributes; | 51 Attributes attributes; |
52 | 52 |
53 attributes[kDomainJoined] = is_joined_to_domain_ ? "1" : "0"; | 53 attributes[kIsEnterpriseUser] = is_enterprise_user_ ? "1" : "0"; |
54 | 54 |
55 attributes["name"] = updater_name_; | 55 attributes["name"] = updater_name_; |
56 | 56 |
57 if (updater_version_.IsValid()) | 57 if (updater_version_.IsValid()) |
58 attributes["version"] = updater_version_.GetString(); | 58 attributes["version"] = updater_version_.GetString(); |
59 | 59 |
60 const base::Time now = base::Time::NowFromSystemTime(); | 60 const base::Time now = base::Time::NowFromSystemTime(); |
61 if (!last_autoupdate_started_.is_null()) | 61 if (!last_autoupdate_started_.is_null()) |
62 attributes["laststarted"] = | 62 attributes["laststarted"] = |
63 NormalizeTimeDelta(now - last_autoupdate_started_); | 63 NormalizeTimeDelta(now - last_autoupdate_started_); |
(...skipping 20 matching lines...) Expand all Loading... |
84 val = "408"; // 2 weeks in hours. | 84 val = "408"; // 2 weeks in hours. |
85 } else { | 85 } else { |
86 val = "1344"; // 2*28 days in hours. | 86 val = "1344"; // 2*28 days in hours. |
87 } | 87 } |
88 | 88 |
89 DCHECK(!val.empty()); | 89 DCHECK(!val.empty()); |
90 return val; | 90 return val; |
91 } | 91 } |
92 | 92 |
93 } // namespace update_client | 93 } // namespace update_client |
OLD | NEW |