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
3 // found in the LICENSE file.
5 #include "ui/views/event_monitor_aura.h"
7 #include "base/logging.h"
8 #include "ui/aura/env.h"
9 #include "ui/aura/window.h"
10 #include "ui/events/event_target.h"
15 scoped_ptr
<EventMonitor
> EventMonitor::CreateApplicationMonitor(
16 ui::EventHandler
* event_handler
) {
17 return make_scoped_ptr(
18 new EventMonitorAura(event_handler
, aura::Env::GetInstance()));
22 scoped_ptr
<EventMonitor
> EventMonitor::CreateWindowMonitor(
23 ui::EventHandler
* event_handler
,
24 gfx::NativeWindow target_window
) {
25 return make_scoped_ptr(new EventMonitorAura(event_handler
, target_window
));
29 gfx::Point
EventMonitor::GetLastMouseLocation() {
30 return aura::Env::GetInstance()->last_mouse_location();
33 EventMonitorAura::EventMonitorAura(ui::EventHandler
* event_handler
,
34 ui::EventTarget
* event_target
)
35 : event_handler_(event_handler
), event_target_(event_target
) {
36 DCHECK(event_handler_
);
37 DCHECK(event_target_
);
38 event_target_
->AddPreTargetHandler(event_handler_
);
41 EventMonitorAura::~EventMonitorAura() {
42 event_target_
->RemovePreTargetHandler(event_handler_
);