blob: 334a5bd5780fd30282d97e36202c8698d2be1156 [file] [log] [blame]
Alex Deymoc705cc82014-02-19 11:15:00 -08001// 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 Arnold2cbb3852014-03-07 12:40:50 -08005#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_POLICY_H_
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_POLICY_H_
Alex Deymoc705cc82014-02-19 11:15:00 -08007
Alex Deymo0d11c602014-04-23 20:12:20 -07008#include <string>
9
Alex Deymoc705cc82014-02-19 11:15:00 -080010#include "update_engine/policy_manager/evaluation_context.h"
Alex Deymo2de23f52014-02-26 14:30:13 -080011#include "update_engine/policy_manager/state.h"
Alex Deymoc705cc82014-02-19 11:15:00 -080012
13namespace chromeos_policy_manager {
14
15// The three different results of a policy request.
Alex Deymoe636c3c2014-03-11 19:02:08 -070016enum class EvalStatus {
17 kFailed,
18 kSucceeded,
19 kAskMeAgainLater,
Alex Deymoc705cc82014-02-19 11:15:00 -080020};
21
Alex Deymo0d11c602014-04-23 20:12:20 -070022std::string ToString(EvalStatus status);
23
24// Parameters of an update check. These parameters are determined by the
25// UpdateCheckAllowed policy.
26struct UpdateCheckParams {
27 bool updates_enabled; // Whether the auto-updates are enabled on this build.
28};
29
30
Alex Deymoc705cc82014-02-19 11:15:00 -080031// 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.
37class Policy {
38 public:
39 virtual ~Policy() {}
40
41 // List of policy requests. A policy request takes an EvaluationContext as the
Alex Deymo2de23f52014-02-26 14:30:13 -080042 // first argument, a State instance, a returned error message, a returned
43 // value and optionally followed by one or more arbitrary constant arguments.
Alex Deymoc705cc82014-02-19 11:15:00 -080044 //
Alex Deymoe636c3c2014-03-11 19:02:08 -070045 // When the implementation fails, the method returns EvalStatus::kFailed and
46 // sets the |error| string.
Alex Deymoc705cc82014-02-19 11:15:00 -080047
48 // UpdateCheckAllowed returns whether it is allowed to request an update check
49 // to Omaha.
Alex Deymo0d11c602014-04-23 20:12:20 -070050 virtual EvalStatus UpdateCheckAllowed(
51 EvaluationContext* ec, State* state, std::string* error,
52 UpdateCheckParams* result) const = 0;
Alex Deymoc705cc82014-02-19 11:15:00 -080053
Gilad Arnoldaf2f6ae2014-04-28 14:14:52 -070054 // 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 Deymoc705cc82014-02-19 11:15:00 -080060 protected:
61 Policy() {}
62
63 private:
64 DISALLOW_COPY_AND_ASSIGN(Policy);
65};
66
67} // namespace chromeos_policy_manager
68
Gilad Arnold2cbb3852014-03-07 12:40:50 -080069#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_POLICY_H_