| 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 // The value of this constant does not reflect its name (i.e. "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. | 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 | 20 // After discussion with omaha team it was decided to leave the value as is to |
| 21 // keep continuity with previous chrome versions. | 21 // keep continuity with previous chrome versions. |
| 22 const char UpdaterState::kIsEnterpriseManaged[] = "domainjoined"; | 22 const char UpdaterState::kIsEnterpriseManaged[] = "domainjoined"; |
| 23 | 23 |
| 24 UpdaterState::UpdaterState(bool is_machine) : is_machine_(is_machine) {} | 24 UpdaterState::UpdaterState(bool is_machine) : is_machine_(is_machine) {} |
| 25 | 25 |
| 26 UpdaterState::~UpdaterState() {} | 26 UpdaterState::~UpdaterState() {} |
| 27 | 27 |
| 28 std::unique_ptr<UpdaterState::Attributes> UpdaterState::GetState( | 28 std::unique_ptr<UpdaterState::Attributes> UpdaterState::GetState( |
| 29 bool is_machine) { | 29 bool is_machine) { |
| 30 #if defined(OS_WIN) | 30 #if defined(OS_WIN) || (defined(OS_MACOSX) && !defined(OS_IOS)) |
| 31 UpdaterState updater_state(is_machine); | 31 UpdaterState updater_state(is_machine); |
| 32 updater_state.ReadState(); | 32 updater_state.ReadState(); |
| 33 return base::MakeUnique<Attributes>(updater_state.BuildAttributes()); | 33 return base::MakeUnique<Attributes>(updater_state.BuildAttributes()); |
| 34 #else | 34 #else |
| 35 return nullptr; | 35 return nullptr; |
| 36 #endif // OS_WIN | 36 #endif // OS_WIN or Mac |
| 37 } | 37 } |
| 38 | 38 |
| 39 #if defined(OS_WIN) | 39 #if defined(OS_WIN) || (defined(OS_MACOSX) && !defined(OS_IOS)) |
| 40 void UpdaterState::ReadState() { | 40 void UpdaterState::ReadState() { |
| 41 is_enterprise_managed_ = IsEnterpriseManaged(); | 41 is_enterprise_managed_ = IsEnterpriseManaged(); |
| 42 | 42 |
| 43 #if defined(GOOGLE_CHROME_BUILD) | 43 #if defined(GOOGLE_CHROME_BUILD) |
| 44 updater_name_ = GetUpdaterName(); | 44 updater_name_ = GetUpdaterName(); |
| 45 updater_version_ = GetUpdaterVersion(is_machine_); | 45 updater_version_ = GetUpdaterVersion(is_machine_); |
| 46 last_autoupdate_started_ = GetUpdaterLastStartedAU(is_machine_); | 46 last_autoupdate_started_ = GetUpdaterLastStartedAU(is_machine_); |
| 47 last_checked_ = GetUpdaterLastChecked(is_machine_); | 47 last_checked_ = GetUpdaterLastChecked(is_machine_); |
| 48 is_autoupdate_check_enabled_ = IsAutoupdateCheckEnabled(); | 48 is_autoupdate_check_enabled_ = IsAutoupdateCheckEnabled(); |
| 49 update_policy_ = GetUpdatePolicy(); | 49 update_policy_ = GetUpdatePolicy(); |
| 50 #endif // GOOGLE_CHROME_BUILD | 50 #endif // GOOGLE_CHROME_BUILD |
| 51 } | 51 } |
| 52 #endif // OS_WIN | 52 #endif // OS_WIN or Mac |
| 53 | 53 |
| 54 UpdaterState::Attributes UpdaterState::BuildAttributes() const { | 54 UpdaterState::Attributes UpdaterState::BuildAttributes() const { |
| 55 Attributes attributes; | 55 Attributes attributes; |
| 56 | 56 |
| 57 attributes[kIsEnterpriseManaged] = is_enterprise_managed_ ? "1" : "0"; | 57 attributes[kIsEnterpriseManaged] = is_enterprise_managed_ ? "1" : "0"; |
| 58 | 58 |
| 59 attributes["name"] = updater_name_; | 59 attributes["name"] = updater_name_; |
| 60 | 60 |
| 61 if (updater_version_.IsValid()) | 61 if (updater_version_.IsValid()) |
| 62 attributes["version"] = updater_version_.GetString(); | 62 attributes["version"] = updater_version_.GetString(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 88 val = "408"; // 2 weeks in hours. | 88 val = "408"; // 2 weeks in hours. |
| 89 } else { | 89 } else { |
| 90 val = "1344"; // 2*28 days in hours. | 90 val = "1344"; // 2*28 days in hours. |
| 91 } | 91 } |
| 92 | 92 |
| 93 DCHECK(!val.empty()); | 93 DCHECK(!val.empty()); |
| 94 return val; | 94 return val; |
| 95 } | 95 } |
| 96 | 96 |
| 97 } // namespace update_client | 97 } // namespace update_client |
| OLD | NEW |