#include "extensions/browser/api/idle/idle_manager.h"
#include <utility>
#include "base/memory/raw_ptr.h"
#include "build/chromeos_buildflags.h"
#include "content/public/browser/browser_context.h"
#include "extensions/browser/api/idle/idle_api_constants.h"
#include "extensions/browser/event_router.h"
#include "extensions/common/api/idle.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_id.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/dbus/power/power_policy_controller.h"
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chromeos/lacros/lacros_service.h"
#include "chromeos/lacros/system_idle_cache.h"
#endif
keys;
idle;
namespace extensions {
namespace {
const int kDefaultIdleThreshold = …;
const int kPollInterval = …;
class DefaultEventDelegate : public IdleManager::EventDelegate { … };
DefaultEventDelegate::DefaultEventDelegate(content::BrowserContext* context)
: … { … }
DefaultEventDelegate::~DefaultEventDelegate() { … }
void DefaultEventDelegate::OnStateChanged(const ExtensionId& extension_id,
ui::IdleState new_state) { … }
void DefaultEventDelegate::RegisterObserver(EventRouter::Observer* observer) { … }
void DefaultEventDelegate::UnregisterObserver(EventRouter::Observer* observer) { … }
class DefaultIdleProvider : public IdleManager::IdleTimeProvider { … };
DefaultIdleProvider::DefaultIdleProvider() { … }
DefaultIdleProvider::~DefaultIdleProvider() { … }
ui::IdleState DefaultIdleProvider::CalculateIdleState(int idle_threshold) { … }
int DefaultIdleProvider::CalculateIdleTime() { … }
bool DefaultIdleProvider::CheckIdleStateIsLocked() { … }
ui::IdleState IdleTimeToIdleState(bool locked,
int idle_time,
int idle_threshold) { … }
}
IdleMonitor::IdleMonitor(ui::IdleState initial_state)
: … { … }
IdleManager::IdleManager(content::BrowserContext* context)
: … { … }
IdleManager::~IdleManager() { … }
void IdleManager::Init() { … }
void IdleManager::Shutdown() { … }
void IdleManager::OnExtensionUnloaded(content::BrowserContext* browser_context,
const Extension* extension,
UnloadedExtensionReason reason) { … }
void IdleManager::OnListenerAdded(const EventListenerInfo& details) { … }
void IdleManager::OnListenerRemoved(const EventListenerInfo& details) { … }
ui::IdleState IdleManager::QueryState(int threshold) { … }
void IdleManager::SetThreshold(const ExtensionId& extension_id, int threshold) { … }
int IdleManager::GetThresholdForTest(const ExtensionId& extension_id) const { … }
base::TimeDelta IdleManager::GetAutoLockDelay() const { … }
base::Value IdleManager::CreateIdleValue(ui::IdleState idle_state) { … }
void IdleManager::SetEventDelegateForTest(
std::unique_ptr<EventDelegate> event_delegate) { … }
void IdleManager::SetIdleTimeProviderForTest(
std::unique_ptr<IdleTimeProvider> idle_time_provider) { … }
IdleMonitor* IdleManager::GetMonitor(const ExtensionId& extension_id) { … }
void IdleManager::StartPolling() { … }
void IdleManager::StopPolling() { … }
void IdleManager::UpdateIdleState() { … }
}