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

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

Issue 2710713004: Revert "Use the Windows MDM API to check if the machine is being managed." (Closed)
Patch Set: Created 3 years, 10 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
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 // The value of this constant does not reflect its name (i.e. "domainjoined" 18 const char UpdaterState::kDomainJoined[] = "domainjoined";
19 // vs something like "isenterprisemanaged") because it is used with omaha.
20 // After discussion with omaha team it was decided to leave the value as is to
21 // keep continuity with previous chrome versions.
22 const char UpdaterState::kIsEnterpriseManaged[] = "domainjoined";
23 19
24 UpdaterState::UpdaterState(bool is_machine) : is_machine_(is_machine) {} 20 UpdaterState::UpdaterState(bool is_machine) : is_machine_(is_machine) {}
25 21
26 UpdaterState::~UpdaterState() {} 22 UpdaterState::~UpdaterState() {}
27 23
28 std::unique_ptr<UpdaterState::Attributes> UpdaterState::GetState( 24 std::unique_ptr<UpdaterState::Attributes> UpdaterState::GetState(
29 bool is_machine) { 25 bool is_machine) {
30 #if defined(OS_WIN) 26 #if defined(OS_WIN)
31 UpdaterState updater_state(is_machine); 27 UpdaterState updater_state(is_machine);
32 updater_state.ReadState(); 28 updater_state.ReadState();
33 return base::MakeUnique<Attributes>(updater_state.BuildAttributes()); 29 return base::MakeUnique<Attributes>(updater_state.BuildAttributes());
34 #else 30 #else
35 return nullptr; 31 return nullptr;
36 #endif // OS_WIN 32 #endif // OS_WIN
37 } 33 }
38 34
39 #if defined(OS_WIN) 35 #if defined(OS_WIN)
40 void UpdaterState::ReadState() { 36 void UpdaterState::ReadState() {
41 is_enterprise_managed_ = IsEnterpriseManaged(); 37 is_joined_to_domain_ = IsJoinedToDomain();
42 38
43 #if defined(GOOGLE_CHROME_BUILD) 39 #if defined(GOOGLE_CHROME_BUILD)
44 updater_name_ = GetUpdaterName(); 40 updater_name_ = GetUpdaterName();
45 updater_version_ = GetUpdaterVersion(is_machine_); 41 updater_version_ = GetUpdaterVersion(is_machine_);
46 last_autoupdate_started_ = GetUpdaterLastStartedAU(is_machine_); 42 last_autoupdate_started_ = GetUpdaterLastStartedAU(is_machine_);
47 last_checked_ = GetUpdaterLastChecked(is_machine_); 43 last_checked_ = GetUpdaterLastChecked(is_machine_);
48 is_autoupdate_check_enabled_ = IsAutoupdateCheckEnabled(); 44 is_autoupdate_check_enabled_ = IsAutoupdateCheckEnabled();
49 update_policy_ = GetUpdatePolicy(); 45 update_policy_ = GetUpdatePolicy();
50 #endif // GOOGLE_CHROME_BUILD 46 #endif // GOOGLE_CHROME_BUILD
51 } 47 }
52 #endif // OS_WIN 48 #endif // OS_WIN
53 49
54 UpdaterState::Attributes UpdaterState::BuildAttributes() const { 50 UpdaterState::Attributes UpdaterState::BuildAttributes() const {
55 Attributes attributes; 51 Attributes attributes;
56 52
57 attributes[kIsEnterpriseManaged] = is_enterprise_managed_ ? "1" : "0"; 53 attributes[kDomainJoined] = is_joined_to_domain_ ? "1" : "0";
58 54
59 attributes["name"] = updater_name_; 55 attributes["name"] = updater_name_;
60 56
61 if (updater_version_.IsValid()) 57 if (updater_version_.IsValid())
62 attributes["version"] = updater_version_.GetString(); 58 attributes["version"] = updater_version_.GetString();
63 59
64 const base::Time now = base::Time::NowFromSystemTime(); 60 const base::Time now = base::Time::NowFromSystemTime();
65 if (!last_autoupdate_started_.is_null()) 61 if (!last_autoupdate_started_.is_null())
66 attributes["laststarted"] = 62 attributes["laststarted"] =
67 NormalizeTimeDelta(now - last_autoupdate_started_); 63 NormalizeTimeDelta(now - last_autoupdate_started_);
(...skipping 20 matching lines...) Expand all
88 val = "408"; // 2 weeks in hours. 84 val = "408"; // 2 weeks in hours.
89 } else { 85 } else {
90 val = "1344"; // 2*28 days in hours. 86 val = "1344"; // 2*28 days in hours.
91 } 87 }
92 88
93 DCHECK(!val.empty()); 89 DCHECK(!val.empty());
94 return val; 90 return val;
95 } 91 }
96 92
97 } // namespace update_client 93 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/updater_state.h ('k') | components/update_client/updater_state_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698