Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Unified Diff: ui/base/user_activity/user_activity_detector.cc

Issue 1024583003: Fix for menus blocking user activity detection (Retry 2). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/base/user_activity/user_activity_detector.cc
diff --git a/ui/base/user_activity/user_activity_detector.cc b/ui/base/user_activity/user_activity_detector.cc
index d6a4e4385278ab04012bdd158f96f62f1a6b335e..41256fc8583659598bf8c575691ac95f42b41101 100644
--- a/ui/base/user_activity/user_activity_detector.cc
+++ b/ui/base/user_activity/user_activity_detector.cc
@@ -8,7 +8,8 @@
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "ui/base/user_activity/user_activity_observer.h"
-#include "ui/events/event.h"
+#include "ui/events/event_utils.h"
+#include "ui/events/platform/platform_event_source.h"
namespace ui {
@@ -48,9 +49,24 @@ const int UserActivityDetector::kDisplayPowerChangeIgnoreMouseMs = 1000;
UserActivityDetector::UserActivityDetector() {
CHECK(!g_instance);
g_instance = this;
+
+ ui::PlatformEventSource* platform_event_source =
+ ui::PlatformEventSource::GetInstance();
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
+ CHECK(platform_event_source);
+#endif
+ if (platform_event_source)
+ platform_event_source->AddPlatformEventObserver(this);
}
UserActivityDetector::~UserActivityDetector() {
+ ui::PlatformEventSource* platform_event_source =
+ ui::PlatformEventSource::GetInstance();
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
+ CHECK(platform_event_source);
+#endif
+ if (platform_event_source)
+ platform_event_source->RemovePlatformEventObserver(this);
g_instance = nullptr;
}
@@ -77,36 +93,31 @@ void UserActivityDetector::OnDisplayPowerChanging() {
base::TimeDelta::FromMilliseconds(kDisplayPowerChangeIgnoreMouseMs);
}
-void UserActivityDetector::OnKeyEvent(ui::KeyEvent* event) {
- HandleActivity(event);
+void UserActivityDetector::WillProcessEvent(
+ const PlatformEvent& platform_event) {
+ scoped_ptr<ui::Event> event(ui::EventFromNative(platform_event));
+ ProcessReceivedEvent(event.get());
}
-void UserActivityDetector::OnMouseEvent(ui::MouseEvent* event) {
- if (event->flags() & ui::EF_IS_SYNTHESIZED)
- return;
- if (!honor_mouse_events_time_.is_null() &&
- GetCurrentTime() < honor_mouse_events_time_)
- return;
-
- HandleActivity(event);
+base::TimeTicks UserActivityDetector::GetCurrentTime() const {
+ return !now_for_test_.is_null() ? now_for_test_ : base::TimeTicks::Now();
}
-void UserActivityDetector::OnScrollEvent(ui::ScrollEvent* event) {
- HandleActivity(event);
-}
+void UserActivityDetector::ProcessReceivedEvent(const ui::Event* event) {
+ if (!event)
+ return;
-void UserActivityDetector::OnTouchEvent(ui::TouchEvent* event) {
- HandleActivity(event);
-}
+ if (event->IsMouseEvent() || event->IsMouseWheelEvent()) {
+ if (event->flags() & ui::EF_IS_SYNTHESIZED)
+ return;
+ if (!honor_mouse_events_time_.is_null()
+ && GetCurrentTime() < honor_mouse_events_time_)
+ return;
+ }
-void UserActivityDetector::OnGestureEvent(ui::GestureEvent* event) {
HandleActivity(event);
}
-base::TimeTicks UserActivityDetector::GetCurrentTime() const {
- return !now_for_test_.is_null() ? now_for_test_ : base::TimeTicks::Now();
-}
-
void UserActivityDetector::HandleActivity(const ui::Event* event) {
base::TimeTicks now = GetCurrentTime();
last_activity_time_ = now;
« no previous file with comments | « ui/base/user_activity/user_activity_detector.h ('k') | ui/base/user_activity/user_activity_detector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698