OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ash/system/chromeos/power/user_activity_notifier.h" | 5 #include "ash/system/chromeos/power/user_activity_notifier.h" |
6 | 6 |
7 #include "chromeos/dbus/dbus_thread_manager.h" | 7 #include "chromeos/dbus/dbus_thread_manager.h" |
8 #include "chromeos/dbus/power_manager_client.h" | 8 #include "chromeos/dbus/power_manager_client.h" |
9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
10 #include "ui/events/event_constants.h" | 10 #include "ui/events/event_constants.h" |
11 #include "ui/events/keycodes/keyboard_codes_posix.h" | 11 #include "ui/events/keycodes/keyboard_codes_posix.h" |
12 #include "ui/wm/core/user_activity_detector.h" | 12 #include "ui/wm/core/user_activity_detector.h" |
13 | 13 |
14 namespace ash { | 14 namespace ash { |
15 namespace internal { | |
16 | |
17 namespace { | 15 namespace { |
18 | 16 |
19 // Minimum number of seconds between notifications. | 17 // Minimum number of seconds between notifications. |
20 const int kNotifyIntervalSec = 5; | 18 const int kNotifyIntervalSec = 5; |
21 | 19 |
22 // Returns a UserActivityType describing |event|. | 20 // Returns a UserActivityType describing |event|. |
23 power_manager::UserActivityType GetUserActivityTypeForEvent( | 21 power_manager::UserActivityType GetUserActivityTypeForEvent( |
24 const ui::Event* event) { | 22 const ui::Event* event) { |
25 if (!event || event->type() != ui::ET_KEY_PRESSED) | 23 if (!event || event->type() != ui::ET_KEY_PRESSED) |
26 return power_manager::USER_ACTIVITY_OTHER; | 24 return power_manager::USER_ACTIVITY_OTHER; |
(...skipping 30 matching lines...) Expand all Loading... |
57 // InSeconds() truncates rather than rounding, so it's fine for this | 55 // InSeconds() truncates rather than rounding, so it's fine for this |
58 // comparison. | 56 // comparison. |
59 if (last_notify_time_.is_null() || | 57 if (last_notify_time_.is_null() || |
60 (now - last_notify_time_).InSeconds() >= kNotifyIntervalSec) { | 58 (now - last_notify_time_).InSeconds() >= kNotifyIntervalSec) { |
61 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 59 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
62 NotifyUserActivity(GetUserActivityTypeForEvent(event)); | 60 NotifyUserActivity(GetUserActivityTypeForEvent(event)); |
63 last_notify_time_ = now; | 61 last_notify_time_ = now; |
64 } | 62 } |
65 } | 63 } |
66 | 64 |
67 } // namespace internal | |
68 } // namespace ash | 65 } // namespace ash |
OLD | NEW |