blob: bb26883976ae0de310700deab98672566c4a44d6 [file] [log] [blame]
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/containers/flat_set.h"
#include "ui/events/event_rewriter.h"
namespace aura {
class Window;
} // namespace aura
namespace chromecast {
class CastTouchActivityObserver;
// An event rewriter whose purpose is to discard events (when enabled). This
// class is meant to be installed as the first rewriter in the chain, to handle
// scenarios where all input needs to be disabled, such as when the device
// screen is turned off. Instances of CastTouchActivityObserver can be
// registered to receive notifications of gated events.
class CastTouchEventGate : public ui::EventRewriter {
explicit CastTouchEventGate(aura::Window* root_window);
~CastTouchEventGate() override;
void SetEnabled(bool enabled);
void AddObserver(CastTouchActivityObserver* observer);
void RemoveObserver(CastTouchActivityObserver* observer);
// ui::EventRewriter implementation.
ui::EventDispatchDetails RewriteEvent(
const ui::Event& event,
const Continuation continuation) override;
bool enabled_ = false;
aura::Window* root_window_;
base::flat_set<CastTouchActivityObserver*> observers_;
} // namespace chromecast