| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/location.h" |
| 6 #include "base/logging.h" | 7 #include "base/logging.h" |
| 7 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" |
| 8 #include "ui/aura/client/screen_position_client.h" | 11 #include "ui/aura/client/screen_position_client.h" |
| 9 #include "ui/aura/env.h" | 12 #include "ui/aura/env.h" |
| 10 #include "ui/aura/test/aura_test_utils.h" | 13 #include "ui/aura/test/aura_test_utils.h" |
| 11 #include "ui/aura/test/ui_controls_factory_aura.h" | 14 #include "ui/aura/test/ui_controls_factory_aura.h" |
| 12 #include "ui/aura/window_tree_host.h" | 15 #include "ui/aura/window_tree_host.h" |
| 13 #include "ui/base/test/ui_controls_aura.h" | 16 #include "ui/base/test/ui_controls_aura.h" |
| 14 #include "ui/events/event_utils.h" | 17 #include "ui/events/event_utils.h" |
| 15 #include "ui/events/test/events_test_utils.h" | 18 #include "ui/events/test/events_test_utils.h" |
| 16 | 19 |
| 17 namespace aura { | 20 namespace aura { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 169 |
| 167 RunClosureAfterAllPendingUIEvents(closure); | 170 RunClosureAfterAllPendingUIEvents(closure); |
| 168 return true; | 171 return true; |
| 169 } | 172 } |
| 170 bool SendMouseClick(ui_controls::MouseButton type) override { | 173 bool SendMouseClick(ui_controls::MouseButton type) override { |
| 171 return SendMouseEvents(type, ui_controls::UP | ui_controls::DOWN); | 174 return SendMouseEvents(type, ui_controls::UP | ui_controls::DOWN); |
| 172 } | 175 } |
| 173 void RunClosureAfterAllPendingUIEvents( | 176 void RunClosureAfterAllPendingUIEvents( |
| 174 const base::Closure& closure) override { | 177 const base::Closure& closure) override { |
| 175 if (!closure.is_null()) | 178 if (!closure.is_null()) |
| 176 base::MessageLoop::current()->PostTask(FROM_HERE, closure); | 179 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure); |
| 177 } | 180 } |
| 178 | 181 |
| 179 private: | 182 private: |
| 180 void SendEventToProcessor(ui::Event* event) { | 183 void SendEventToProcessor(ui::Event* event) { |
| 181 ui::EventSourceTestApi event_source_test(host_->GetEventSource()); | 184 ui::EventSourceTestApi event_source_test(host_->GetEventSource()); |
| 182 ui::EventDispatchDetails details = | 185 ui::EventDispatchDetails details = |
| 183 event_source_test.SendEventToProcessor(event); | 186 event_source_test.SendEventToProcessor(event); |
| 184 if (details.dispatcher_destroyed) | 187 if (details.dispatcher_destroyed) |
| 185 return; | 188 return; |
| 186 } | 189 } |
| 187 | 190 |
| 188 void PostKeyEvent(ui::EventType type, ui::KeyboardCode key_code, int flags) { | 191 void PostKeyEvent(ui::EventType type, ui::KeyboardCode key_code, int flags) { |
| 189 base::MessageLoop::current()->PostTask( | 192 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 190 FROM_HERE, | 193 FROM_HERE, base::Bind(&UIControlsOzone::PostKeyEventTask, |
| 191 base::Bind(&UIControlsOzone::PostKeyEventTask, | 194 base::Unretained(this), type, key_code, flags)); |
| 192 base::Unretained(this), | |
| 193 type, | |
| 194 key_code, | |
| 195 flags)); | |
| 196 } | 195 } |
| 197 | 196 |
| 198 void PostKeyEventTask(ui::EventType type, | 197 void PostKeyEventTask(ui::EventType type, |
| 199 ui::KeyboardCode key_code, | 198 ui::KeyboardCode key_code, |
| 200 int flags) { | 199 int flags) { |
| 201 // Do not rewrite injected events. See crbug.com/136465. | 200 // Do not rewrite injected events. See crbug.com/136465. |
| 202 flags |= ui::EF_FINAL; | 201 flags |= ui::EF_FINAL; |
| 203 | 202 |
| 204 ui::KeyEvent key_event(type, key_code, flags); | 203 ui::KeyEvent key_event(type, key_code, flags); |
| 205 SendEventToProcessor(&key_event); | 204 SendEventToProcessor(&key_event); |
| 206 } | 205 } |
| 207 | 206 |
| 208 void PostMouseEvent(ui::EventType type, | 207 void PostMouseEvent(ui::EventType type, |
| 209 const gfx::Point& host_location, | 208 const gfx::Point& host_location, |
| 210 int flags, | 209 int flags, |
| 211 int changed_button_flags) { | 210 int changed_button_flags) { |
| 212 base::MessageLoop::current()->PostTask( | 211 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 213 FROM_HERE, | 212 FROM_HERE, |
| 214 base::Bind(&UIControlsOzone::PostMouseEventTask, base::Unretained(this), | 213 base::Bind(&UIControlsOzone::PostMouseEventTask, base::Unretained(this), |
| 215 type, host_location, flags, changed_button_flags)); | 214 type, host_location, flags, changed_button_flags)); |
| 216 } | 215 } |
| 217 | 216 |
| 218 void PostMouseEventTask(ui::EventType type, | 217 void PostMouseEventTask(ui::EventType type, |
| 219 const gfx::Point& host_location, | 218 const gfx::Point& host_location, |
| 220 int flags, | 219 int flags, |
| 221 int changed_button_flags) { | 220 int changed_button_flags) { |
| 222 ui::MouseEvent mouse_event(type, host_location, host_location, | 221 ui::MouseEvent mouse_event(type, host_location, host_location, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 238 }; | 237 }; |
| 239 | 238 |
| 240 } // namespace | 239 } // namespace |
| 241 | 240 |
| 242 ui_controls::UIControlsAura* CreateUIControlsAura(WindowTreeHost* host) { | 241 ui_controls::UIControlsAura* CreateUIControlsAura(WindowTreeHost* host) { |
| 243 return new UIControlsOzone(host); | 242 return new UIControlsOzone(host); |
| 244 } | 243 } |
| 245 | 244 |
| 246 } // namespace test | 245 } // namespace test |
| 247 } // namespace aura | 246 } // namespace aura |
| OLD | NEW |