OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/idle_user_detector.h" | 5 #include "content/renderer/idle_user_detector.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/common/input_messages.h" | 8 #include "content/common/input_messages.h" |
9 #include "content/public/renderer/content_renderer_client.h" | 9 #include "content/public/renderer/content_renderer_client.h" |
10 #include "content/renderer/render_thread_impl.h" | 10 #include "content/renderer/render_thread_impl.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 IdleUserDetector::IdleUserDetector(RenderView* render_view) | 14 IdleUserDetector::IdleUserDetector(RenderView* render_view) |
15 : RenderViewObserver(render_view){ | 15 : RenderViewObserver(render_view) {} |
16 } | |
17 | 16 |
18 IdleUserDetector::~IdleUserDetector() { | 17 IdleUserDetector::~IdleUserDetector() {} |
19 } | |
20 | 18 |
21 bool IdleUserDetector::OnMessageReceived(const IPC::Message& message) { | 19 bool IdleUserDetector::OnMessageReceived(const IPC::Message& message) { |
22 IPC_BEGIN_MESSAGE_MAP(IdleUserDetector, message) | 20 IPC_BEGIN_MESSAGE_MAP(IdleUserDetector, message) |
23 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) | 21 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) |
24 IPC_END_MESSAGE_MAP() | 22 IPC_END_MESSAGE_MAP() |
25 return false; | 23 return false; |
26 } | 24 } |
27 | 25 |
28 void IdleUserDetector::OnHandleInputEvent( | 26 void IdleUserDetector::ActivityDetected() { |
29 const blink::WebInputEvent* event, | |
30 const std::vector<const blink::WebInputEvent*>& coalesced_events, | |
31 const ui::LatencyInfo& latency_info, | |
32 InputEventDispatchType dispatch_type) { | |
33 if (GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 27 if (GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
34 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | 28 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
35 if (render_thread != NULL) { | 29 if (render_thread != NULL) { |
36 render_thread->PostponeIdleNotification(); | 30 render_thread->PostponeIdleNotification(); |
37 } | 31 } |
38 } | 32 } |
39 } | 33 } |
40 | 34 |
41 void IdleUserDetector::OnDestruct() { | 35 void IdleUserDetector::OnHandleInputEvent( |
42 delete this; | 36 const blink::WebInputEvent* event, |
| 37 const std::vector<const blink::WebInputEvent*>& coalesced_events, |
| 38 const ui::LatencyInfo& latency_info, |
| 39 InputEventDispatchType dispatch_type) { |
| 40 ActivityDetected(); |
43 } | 41 } |
44 | 42 |
| 43 void IdleUserDetector::OnDestruct() {} |
| 44 |
45 } // namespace content | 45 } // namespace content |
OLD | NEW |