Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 1 | // Copyright 2014 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "update_engine/policy_manager/real_config_provider.h" |
| 6 | |
| 7 | #include <base/logging.h> |
| 8 | |
| 9 | #include "update_engine/constants.h" |
| 10 | #include "update_engine/policy_manager/generic_variables.h" |
| 11 | #include "update_engine/simple_key_value_store.h" |
| 12 | #include "update_engine/utils.h" |
| 13 | |
| 14 | using chromeos_update_engine::KeyValueStore; |
| 15 | using std::string; |
| 16 | |
| 17 | namespace { |
| 18 | |
| 19 | const char* kConfigFilePath = "/etc/policy_manager.conf"; |
| 20 | |
| 21 | // Config options: |
| 22 | const char* kConfigOptsIsOOBEEnabled = "is_oobe_enabled"; |
| 23 | |
| 24 | } // namespace |
| 25 | |
| 26 | namespace chromeos_policy_manager { |
| 27 | |
Alex Deymo | 42c30c3 | 2014-04-24 18:41:18 -0700 | [diff] [blame^] | 28 | bool RealConfigProvider::Init() { |
Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 29 | KeyValueStore store; |
| 30 | |
| 31 | if (hardware_->IsNormalBootMode()) { |
| 32 | store.Load(root_prefix_ + kConfigFilePath); |
| 33 | } else { |
| 34 | if (store.Load(root_prefix_ + chromeos_update_engine::kStatefulPartition + |
| 35 | kConfigFilePath)) { |
| 36 | LOG(INFO) << "PolicyManager Config loaded from stateful partition."; |
| 37 | } else { |
| 38 | store.Load(root_prefix_ + kConfigFilePath); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | bool is_oobe_enabled; |
| 43 | if (!store.GetBoolean(kConfigOptsIsOOBEEnabled, &is_oobe_enabled)) |
| 44 | is_oobe_enabled = true; // Default value. |
| 45 | var_is_oobe_enabled_.reset( |
| 46 | new ConstCopyVariable<bool>(kConfigOptsIsOOBEEnabled, is_oobe_enabled)); |
| 47 | |
| 48 | return true; |
| 49 | } |
| 50 | |
| 51 | } // namespace chromeos_policy_manager |