OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/chromeos/idle_detector.h" | 5 #include "chrome/browser/chromeos/idle_detector.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "ui/wm/core/user_activity_detector.h" | 9 #include "ui/base/user_activity/user_activity_detector.h" |
10 | 10 |
11 namespace chromeos { | 11 namespace chromeos { |
12 | 12 |
13 IdleDetector::IdleDetector(const base::Closure& on_idle_callback) | 13 IdleDetector::IdleDetector(const base::Closure& on_idle_callback) |
14 : idle_callback_(on_idle_callback) {} | 14 : idle_callback_(on_idle_callback) {} |
15 | 15 |
16 IdleDetector::~IdleDetector() { | 16 IdleDetector::~IdleDetector() { |
17 wm::UserActivityDetector* user_activity_detector = | 17 ui::UserActivityDetector* user_activity_detector = |
18 wm::UserActivityDetector::Get(); | 18 ui::UserActivityDetector::Get(); |
19 if (user_activity_detector && user_activity_detector->HasObserver(this)) | 19 if (user_activity_detector && user_activity_detector->HasObserver(this)) |
20 user_activity_detector->RemoveObserver(this); | 20 user_activity_detector->RemoveObserver(this); |
21 } | 21 } |
22 | 22 |
23 void IdleDetector::OnUserActivity(const ui::Event* event) { | 23 void IdleDetector::OnUserActivity(const ui::Event* event) { |
24 ResetTimer(); | 24 ResetTimer(); |
25 } | 25 } |
26 | 26 |
27 void IdleDetector::Start(const base::TimeDelta& timeout) { | 27 void IdleDetector::Start(const base::TimeDelta& timeout) { |
28 timeout_ = timeout; | 28 timeout_ = timeout; |
29 if (!wm::UserActivityDetector::Get()->HasObserver(this)) | 29 if (!ui::UserActivityDetector::Get()->HasObserver(this)) |
30 wm::UserActivityDetector::Get()->AddObserver(this); | 30 ui::UserActivityDetector::Get()->AddObserver(this); |
31 ResetTimer(); | 31 ResetTimer(); |
32 } | 32 } |
33 | 33 |
34 void IdleDetector::ResetTimer() { | 34 void IdleDetector::ResetTimer() { |
35 if (timer_.IsRunning()) | 35 if (timer_.IsRunning()) |
36 timer_.Reset(); | 36 timer_.Reset(); |
37 else | 37 else |
38 timer_.Start(FROM_HERE, timeout_, idle_callback_); | 38 timer_.Start(FROM_HERE, timeout_, idle_callback_); |
39 } | 39 } |
40 | 40 |
41 } // namespace chromeos | 41 } // namespace chromeos |
OLD | NEW |