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 | #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_REAL_CONFIG_PROVIDER_H_ |
| 6 | #define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_REAL_CONFIG_PROVIDER_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include <base/memory/scoped_ptr.h> |
| 11 | |
| 12 | #include "update_engine/hardware_interface.h" |
| 13 | #include "update_engine/policy_manager/config_provider.h" |
| 14 | #include "update_engine/policy_manager/generic_variables.h" |
| 15 | |
| 16 | namespace chromeos_policy_manager { |
| 17 | |
| 18 | // ConfigProvider concrete implementation. |
| 19 | class RealConfigProvider : public ConfigProvider { |
| 20 | public: |
| 21 | explicit RealConfigProvider( |
| 22 | chromeos_update_engine::HardwareInterface* hardware) |
| 23 | : hardware_(hardware) {} |
| 24 | |
Alex Deymo | 42c30c3 | 2014-04-24 18:41:18 -0700 | [diff] [blame^] | 25 | // Initializes the provider and returns whether it succeeded. |
| 26 | bool Init(); |
| 27 | |
Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 28 | Variable<bool>* var_is_oobe_enabled() override { |
| 29 | return var_is_oobe_enabled_.get(); |
| 30 | } |
| 31 | |
| 32 | private: |
| 33 | friend class PmRealConfigProviderTest; |
| 34 | |
Alex Deymo | f9f1263 | 2014-04-17 13:51:26 -0700 | [diff] [blame] | 35 | // Used for testing. Sets the root prefix, which is by default "". Call this |
| 36 | // method before calling Init() in order to mock out the place where the files |
| 37 | // are being read from. |
| 38 | void SetRootPrefix(const std::string& prefix) { |
| 39 | root_prefix_ = prefix; |
| 40 | } |
| 41 | |
| 42 | scoped_ptr<ConstCopyVariable<bool>> var_is_oobe_enabled_; |
| 43 | |
| 44 | chromeos_update_engine::HardwareInterface* hardware_; |
| 45 | |
| 46 | // Prefix to prepend to the file paths. Useful for testing. |
| 47 | std::string root_prefix_; |
| 48 | |
| 49 | DISALLOW_COPY_AND_ASSIGN(RealConfigProvider); |
| 50 | }; |
| 51 | |
| 52 | } // namespace chromeos_policy_manager |
| 53 | |
| 54 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_REAL_CONFIG_PROVIDER_H_ |