blob: 7bdef1ea03205d8f7b9726ed3503ac63a2408126 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
// Copyright (c) 2015 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.
#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 {
// WindowActivityTracker is an interface that can be implememented to report
// whether the user is actively interacting with UI.
class CONTENT_EXPORT WindowActivityTracker {
public:
static scoped_ptr<WindowActivityTracker> Create(gfx::NativeView view);
WindowActivityTracker();
virtual ~WindowActivityTracker();
// Returns true if UI interaction is active.
bool IsUiInteractionActive() const;
// Reports on every mouse movement activity on the window.
void RegisterMouseInteractionObserver(const base::Closure& observer);
// Resets any previous UI activity tracked.
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
#endif // CONTENT_BROWSER_MEDIA_CAPTURE_WINDOW_ACTIVITY_TRACKER_H_
|