OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/policy/enterprise_install_attributes.h" | 5 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 registration_mode_(DEVICE_MODE_PENDING), | 74 registration_mode_(DEVICE_MODE_PENDING), |
75 cryptohome_client_(cryptohome_client), | 75 cryptohome_client_(cryptohome_client), |
76 weak_ptr_factory_(this) { | 76 weak_ptr_factory_(this) { |
77 } | 77 } |
78 | 78 |
79 EnterpriseInstallAttributes::~EnterpriseInstallAttributes() {} | 79 EnterpriseInstallAttributes::~EnterpriseInstallAttributes() {} |
80 | 80 |
81 void EnterpriseInstallAttributes::Init(const base::FilePath& cache_file) { | 81 void EnterpriseInstallAttributes::Init(const base::FilePath& cache_file) { |
82 DCHECK_EQ(false, device_locked_); | 82 DCHECK_EQ(false, device_locked_); |
83 | 83 |
84 // The actual check happens asynchronously, thus it is ok to trigger it before | 84 cryptohome_client_->WaitForServiceToBeAvailable(base::Bind( |
85 // Init() has completed. | 85 &EnterpriseInstallAttributes::OnCryptohomeServiceInitiallyAvailable, |
86 TriggerConsistencyCheck(kDbusRetryCount * kDbusRetryIntervalInSeconds); | 86 weak_ptr_factory_.GetWeakPtr())); |
Daniel Erat
2016/08/11 21:34:43
the multiplication by kDbusRetryIntervalInSeconds
Mattias Nissler (ping if slow)
2016/09/07 19:47:24
Agreed.
Daniel Erat
2016/09/07 20:46:52
Acknowledged.
| |
87 | 87 |
88 if (!base::PathExists(cache_file)) | 88 if (!base::PathExists(cache_file)) |
89 return; | 89 return; |
90 | 90 |
91 device_locked_ = true; | 91 device_locked_ = true; |
92 | 92 |
93 char buf[16384]; | 93 char buf[16384]; |
94 int len = base::ReadFile(cache_file, buf, sizeof(buf)); | 94 int len = base::ReadFile(cache_file, buf, sizeof(buf)); |
95 if (len == -1 || len >= static_cast<int>(sizeof(buf))) { | 95 if (len == -1 || len >= static_cast<int>(sizeof(buf))) { |
96 PLOG(ERROR) << "Failed to read " << cache_file.value(); | 96 PLOG(ERROR) << "Failed to read " << cache_file.value(); |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
418 "enterprise.domain"; | 418 "enterprise.domain"; |
419 const char EnterpriseInstallAttributes::kAttrEnterpriseMode[] = | 419 const char EnterpriseInstallAttributes::kAttrEnterpriseMode[] = |
420 "enterprise.mode"; | 420 "enterprise.mode"; |
421 const char EnterpriseInstallAttributes::kAttrEnterpriseOwned[] = | 421 const char EnterpriseInstallAttributes::kAttrEnterpriseOwned[] = |
422 "enterprise.owned"; | 422 "enterprise.owned"; |
423 const char EnterpriseInstallAttributes::kAttrEnterpriseUser[] = | 423 const char EnterpriseInstallAttributes::kAttrEnterpriseUser[] = |
424 "enterprise.user"; | 424 "enterprise.user"; |
425 const char EnterpriseInstallAttributes::kAttrConsumerKioskEnabled[] = | 425 const char EnterpriseInstallAttributes::kAttrConsumerKioskEnabled[] = |
426 "consumer.app_kiosk_enabled"; | 426 "consumer.app_kiosk_enabled"; |
427 | 427 |
428 void EnterpriseInstallAttributes::OnCryptohomeServiceInitiallyAvailable( | |
429 bool service_is_ready) { | |
430 if (!service_is_ready) | |
431 LOG(ERROR) << "Failed waiting for cryptohome D-Bus service availability"; | |
432 | |
433 // Start the consistency check even if we failed to wait for availability; | |
434 // hopefully the service will become available eventually. | |
435 TriggerConsistencyCheck(kDbusRetryCount); | |
Daniel Erat
2016/08/11 21:34:43
calling this asynchronously when the service becom
Mattias Nissler (ping if slow)
2016/09/07 19:47:25
I'd just set consistency_check_running_ to true in
Daniel Erat
2016/09/07 20:46:52
Done.
| |
436 } | |
437 | |
428 std::string EnterpriseInstallAttributes::GetDeviceModeString(DeviceMode mode) { | 438 std::string EnterpriseInstallAttributes::GetDeviceModeString(DeviceMode mode) { |
429 switch (mode) { | 439 switch (mode) { |
430 case DEVICE_MODE_CONSUMER: | 440 case DEVICE_MODE_CONSUMER: |
431 return EnterpriseInstallAttributes::kConsumerDeviceMode; | 441 return EnterpriseInstallAttributes::kConsumerDeviceMode; |
432 case DEVICE_MODE_ENTERPRISE: | 442 case DEVICE_MODE_ENTERPRISE: |
433 return EnterpriseInstallAttributes::kEnterpriseDeviceMode; | 443 return EnterpriseInstallAttributes::kEnterpriseDeviceMode; |
434 case DEVICE_MODE_LEGACY_RETAIL_MODE: | 444 case DEVICE_MODE_LEGACY_RETAIL_MODE: |
435 return EnterpriseInstallAttributes::kLegacyRetailDeviceMode; | 445 return EnterpriseInstallAttributes::kLegacyRetailDeviceMode; |
436 case DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH: | 446 case DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH: |
437 return EnterpriseInstallAttributes::kConsumerKioskDeviceMode; | 447 return EnterpriseInstallAttributes::kConsumerKioskDeviceMode; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 &consumer_kiosk_enabled) && | 501 &consumer_kiosk_enabled) && |
492 consumer_kiosk_enabled == "true") { | 502 consumer_kiosk_enabled == "true") { |
493 registration_mode_ = DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH; | 503 registration_mode_ = DEVICE_MODE_CONSUMER_KIOSK_AUTOLAUNCH; |
494 } else if (enterprise_user.empty() && enterprise_owned != "true") { | 504 } else if (enterprise_user.empty() && enterprise_owned != "true") { |
495 // |registration_user_| is empty on consumer devices. | 505 // |registration_user_| is empty on consumer devices. |
496 registration_mode_ = DEVICE_MODE_CONSUMER; | 506 registration_mode_ = DEVICE_MODE_CONSUMER; |
497 } | 507 } |
498 } | 508 } |
499 | 509 |
500 } // namespace policy | 510 } // namespace policy |
OLD | NEW |