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

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

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

Powered by Google App Engine
This is Rietveld 408576698