Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / renderer / idle_user_detector.cc
blobdff78d1ab07976a065b90a254d143fd91bb74d01
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
3 // found in the LICENSE file.
5 #include "content/renderer/idle_user_detector.h"
7 #include "base/logging.h"
8 #include "content/common/input_messages.h"
9 #include "content/public/renderer/content_renderer_client.h"
10 #include "content/renderer/render_thread_impl.h"
12 namespace content {
14 IdleUserDetector::IdleUserDetector(RenderView* render_view)
15 : RenderViewObserver(render_view){
18 IdleUserDetector::~IdleUserDetector() {
21 bool IdleUserDetector::OnMessageReceived(const IPC::Message& message) {
22 IPC_BEGIN_MESSAGE_MAP(IdleUserDetector, message)
23 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent)
24 IPC_END_MESSAGE_MAP()
25 return false;
28 void IdleUserDetector::OnHandleInputEvent(const blink::WebInputEvent* event,
29 const ui::LatencyInfo& latency_info,
30 bool is_keyboard_shortcut) {
31 if (GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) {
32 RenderThreadImpl* render_thread = RenderThreadImpl::current();
33 if (render_thread != NULL) {
34 render_thread->PostponeIdleNotification();
39 } // namespace content