diff options
Diffstat (limited to 'content/browser/media/capture/window_activity_tracker.h')
-rw-r--r-- | content/browser/media/capture/window_activity_tracker.h | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/content/browser/media/capture/window_activity_tracker.h b/content/browser/media/capture/window_activity_tracker.h index d7b8d0f..7bdef1e 100644 --- a/content/browser/media/capture/window_activity_tracker.h +++ b/content/browser/media/capture/window_activity_tracker.h @@ -5,9 +5,11 @@ #ifndef CONTENT_BROWSER_MEDIA_CAPTURE_WINDOW_ACTIVITY_TRACKER_H_ #define CONTENT_BROWSER_MEDIA_CAPTURE_WINDOW_ACTIVITY_TRACKER_H_ +#include "base/callback.h" #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "content/common/content_export.h" +#include "ui/gfx/native_widget_types.h" namespace content { @@ -15,20 +17,39 @@ namespace content { // whether the user is actively interacting with UI. class CONTENT_EXPORT WindowActivityTracker { public: - virtual ~WindowActivityTracker() {} + static scoped_ptr<WindowActivityTracker> Create(gfx::NativeView view); + + WindowActivityTracker(); + virtual ~WindowActivityTracker(); // Returns true if UI interaction is active. - virtual bool IsUiInteractionActive() const = 0; + bool IsUiInteractionActive() const; // Reports on every mouse movement activity on the window. - virtual void RegisterMouseInteractionObserver( - const base::Closure& observer) {} + void RegisterMouseInteractionObserver(const base::Closure& observer); // Resets any previous UI activity tracked. - virtual void Reset() = 0; + void Reset(); // Returns a weak pointer. virtual base::WeakPtr<WindowActivityTracker> GetWeakPtr() = 0; + + protected: + void OnMouseActivity(); + + private: + // The last time a UI event was detected. + base::TimeTicks last_time_ui_event_detected_; + + // Runs on any mouse interaction from user. + base::Closure mouse_interaction_observer_; + + // The number of UI events detected so far. In case of continuous events + // such as mouse movement, a single continuous movement is treated + // as one event. + int ui_events_count_; + + DISALLOW_COPY_AND_ASSIGN(WindowActivityTracker); }; } // namespace content |