Alex Deymo | c705cc8 | 2014-02-19 11:15:00 -0800 | [diff] [blame] | 1 | // Copyright (c) 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 | |
Gilad Arnold | 2cbb385 | 2014-03-07 12:40:50 -0800 | [diff] [blame] | 5 | #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_POLICY_H_ |
| 6 | #define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_POLICY_H_ |
Alex Deymo | c705cc8 | 2014-02-19 11:15:00 -0800 | [diff] [blame] | 7 | |
Alex Deymo | 0d11c60 | 2014-04-23 20:12:20 -0700 | [diff] [blame^] | 8 | #include <string> |
| 9 | |
Alex Deymo | c705cc8 | 2014-02-19 11:15:00 -0800 | [diff] [blame] | 10 | #include "update_engine/policy_manager/evaluation_context.h" |
Alex Deymo | 2de23f5 | 2014-02-26 14:30:13 -0800 | [diff] [blame] | 11 | #include "update_engine/policy_manager/state.h" |
Alex Deymo | c705cc8 | 2014-02-19 11:15:00 -0800 | [diff] [blame] | 12 | |
| 13 | namespace chromeos_policy_manager { |
| 14 | |
| 15 | // The three different results of a policy request. |
Alex Deymo | e636c3c | 2014-03-11 19:02:08 -0700 | [diff] [blame] | 16 | enum class EvalStatus { |
| 17 | kFailed, |
| 18 | kSucceeded, |
| 19 | kAskMeAgainLater, |
Alex Deymo | c705cc8 | 2014-02-19 11:15:00 -0800 | [diff] [blame] | 20 | }; |
| 21 | |
Alex Deymo | 0d11c60 | 2014-04-23 20:12:20 -0700 | [diff] [blame^] | 22 | std::string ToString(EvalStatus status); |
| 23 | |
| 24 | // Parameters of an update check. These parameters are determined by the |
| 25 | // UpdateCheckAllowed policy. |
| 26 | struct UpdateCheckParams { |
| 27 | bool updates_enabled; // Whether the auto-updates are enabled on this build. |
| 28 | }; |
| 29 | |
| 30 | |
Alex Deymo | c705cc8 | 2014-02-19 11:15:00 -0800 | [diff] [blame] | 31 | // The Policy class is an interface to the ensemble of policy requests that the |
| 32 | // client can make. A derived class includes the policy implementations of |
| 33 | // these. |
| 34 | // |
| 35 | // When compile-time selection of the policy is required due to missing or extra |
| 36 | // parts in a given platform, a different Policy subclass can be used. |
| 37 | class Policy { |
| 38 | public: |
| 39 | virtual ~Policy() {} |
| 40 | |
| 41 | // List of policy requests. A policy request takes an EvaluationContext as the |
Alex Deymo | 2de23f5 | 2014-02-26 14:30:13 -0800 | [diff] [blame] | 42 | // first argument, a State instance, a returned error message, a returned |
| 43 | // value and optionally followed by one or more arbitrary constant arguments. |
Alex Deymo | c705cc8 | 2014-02-19 11:15:00 -0800 | [diff] [blame] | 44 | // |
Alex Deymo | e636c3c | 2014-03-11 19:02:08 -0700 | [diff] [blame] | 45 | // When the implementation fails, the method returns EvalStatus::kFailed and |
| 46 | // sets the |error| string. |
Alex Deymo | c705cc8 | 2014-02-19 11:15:00 -0800 | [diff] [blame] | 47 | |
| 48 | // UpdateCheckAllowed returns whether it is allowed to request an update check |
| 49 | // to Omaha. |
Alex Deymo | 0d11c60 | 2014-04-23 20:12:20 -0700 | [diff] [blame^] | 50 | virtual EvalStatus UpdateCheckAllowed( |
| 51 | EvaluationContext* ec, State* state, std::string* error, |
| 52 | UpdateCheckParams* result) const = 0; |
Alex Deymo | c705cc8 | 2014-02-19 11:15:00 -0800 | [diff] [blame] | 53 | |
Gilad Arnold | af2f6ae | 2014-04-28 14:14:52 -0700 | [diff] [blame] | 54 | // Returns whether an update can be downloaded/applied. |
| 55 | virtual EvalStatus UpdateDownloadAndApplyAllowed(EvaluationContext* ec, |
| 56 | State* state, |
| 57 | std::string* error, |
| 58 | bool* result) const = 0; |
| 59 | |
Alex Deymo | c705cc8 | 2014-02-19 11:15:00 -0800 | [diff] [blame] | 60 | protected: |
| 61 | Policy() {} |
| 62 | |
| 63 | private: |
| 64 | DISALLOW_COPY_AND_ASSIGN(Policy); |
| 65 | }; |
| 66 | |
| 67 | } // namespace chromeos_policy_manager |
| 68 | |
Gilad Arnold | 2cbb385 | 2014-03-07 12:40:50 -0800 | [diff] [blame] | 69 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_POLICY_H_ |