Commit b6400be0 authored by Henrique Grandinetti's avatar Henrique Grandinetti Committed by Commit Bot

Add the BaseTimeLimitProcessor class, needed to implement the BaseTimeLimit...

Add the BaseTimeLimitProcessor class, needed to implement the BaseTimeLimit policy. This does not implement the methods logic, but provides the interface needed to unblock the UI development.

Bug: 823536
Change-Id: Ie8adecaea3bb0de8c20396959a6b37fd08cbca47
Reviewed-on: https://chromium-review.googlesource.com/1066830
Commit-Queue: Henrique Grandinetti <hgrandinetti@google.com>
Reviewed-by: default avatarRahul Chaturvedi <rkc@chromium.org>
Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560827}
parent 706e20c7
...@@ -499,6 +499,8 @@ source_set("chromeos") { ...@@ -499,6 +499,8 @@ source_set("chromeos") {
"child_accounts/screen_time_controller.h", "child_accounts/screen_time_controller.h",
"child_accounts/screen_time_controller_factory.cc", "child_accounts/screen_time_controller_factory.cc",
"child_accounts/screen_time_controller_factory.h", "child_accounts/screen_time_controller_factory.h",
"child_accounts/usage_time_limit_processor.cc",
"child_accounts/usage_time_limit_processor.h",
"chrome_browser_main_chromeos.cc", "chrome_browser_main_chromeos.cc",
"chrome_browser_main_chromeos.h", "chrome_browser_main_chromeos.h",
"chrome_content_browser_client_chromeos_part.cc", "chrome_content_browser_client_chromeos_part.cc",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "usage_time_limit_processor.h"
namespace chromeos {
namespace usage_time_limit {
State GetState(const std::unique_ptr<base::DictionaryValue>& time_limit,
const base::TimeDelta& used_time,
const base::Time& usage_timestamp,
const base::Time& current_time,
const base::Optional<State>& previous_state) {
// TODO: Implement method.
return State();
}
base::Time GetExpectedResetTime(
const std::unique_ptr<base::DictionaryValue>& time_limit,
base::Time current_time) {
// TODO: Implement this method.
return base::Time();
}
} // namespace usage_time_limit
} // namespace chromeos
\ No newline at end of file
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Processor for the UsageTimeLimit policy. Used to determine the current state
// of the client, for example if it is locked and the reason why it may be
// locked.
#ifndef CHROME_BROWSER_CHROMEOS_CHILD_ACCOUNTS_USAGE_TIME_LIMIT_PROCESSOR_H_
#define CHROME_BROWSER_CHROMEOS_CHILD_ACCOUNTS_USAGE_TIME_LIMIT_PROCESSOR_H_
#include <vector>
#include "base/optional.h"
#include "base/time/time.h"
#include "base/values.h"
namespace chromeos {
namespace usage_time_limit {
enum class ActivePolicies {
kNoActivePolicy,
kOverride,
kFixedLimit,
kUsageLimit
};
struct State {
// Whether the device is currently locked.
bool is_locked;
// Which policy is responsible for the current state.
// If it is locked, one of [ override, fixed_limit, usage_limit ]
// If it is not locked, one of [ no_active_policy, override ]
ActivePolicies active_policy;
// Whether time_usage_limit is currently active.
bool is_time_usage_limit_enabled;
// Remaining screen usage quota. Only available if
// is_time_limit_enabled = true
base::TimeDelta remaining_usage;
// Next epoch time that time limit state could change. This could be the
// start time of the next fixed window limit, the end time of the current
// fixed limit, the earliest time a usage limit could be reached, or the
// next time when screen time will start.
base::Time next_state_change_time;
// The policy that will be active in the next state.
ActivePolicies next_state_active_policy;
// Last time the state changed.
base::Time last_state_changed;
};
// Returns the current state of the user session with the given usage time limit
// policy.
State GetState(const std::unique_ptr<base::DictionaryValue>& time_limit,
const base::TimeDelta& used_time,
const base::Time& usage_timestamp,
const base::Time& current_time,
const base::Optional<State>& previous_state);
// Ruturns the expected time that the used time stored should be reseted.
base::Time GetExpectedResetTime(
const std::unique_ptr<base::DictionaryValue>& time_limit,
base::Time current_time);
} // namespace usage_time_limit
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_CHILD_ACCOUNTS_USAGE_TIME_LIMIT_PROCESSOR_H_
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment