| 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/location.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 bool SendMouseClick(ui_controls::MouseButton type) override { | 173 bool SendMouseClick(ui_controls::MouseButton type) override { |
| 174 return SendMouseEvents(type, ui_controls::UP | ui_controls::DOWN); | 174 return SendMouseEvents(type, ui_controls::UP | ui_controls::DOWN); |
| 175 } | 175 } |
| 176 void RunClosureAfterAllPendingUIEvents( | 176 void RunClosureAfterAllPendingUIEvents( |
| 177 const base::Closure& closure) override { | 177 const base::Closure& closure) override { |
| 178 if (!closure.is_null()) | 178 if (!closure.is_null()) |
| 179 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure); | 179 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure); |
| 180 } | 180 } |
| 181 | 181 |
| 182 private: | 182 private: |
| 183 void SendEventToProcessor(ui::Event* event) { | 183 void SendEventToSink(ui::Event* event) { |
| 184 ui::EventSourceTestApi event_source_test(host_->GetEventSource()); | 184 ui::EventSourceTestApi event_source_test(host_->GetEventSource()); |
| 185 ui::EventDispatchDetails details = | 185 ui::EventDispatchDetails details = event_source_test.SendEventToSink(event); |
| 186 event_source_test.SendEventToProcessor(event); | |
| 187 if (details.dispatcher_destroyed) | 186 if (details.dispatcher_destroyed) |
| 188 return; | 187 return; |
| 189 } | 188 } |
| 190 | 189 |
| 191 void PostKeyEvent(ui::EventType type, ui::KeyboardCode key_code, int flags) { | 190 void PostKeyEvent(ui::EventType type, ui::KeyboardCode key_code, int flags) { |
| 192 base::ThreadTaskRunnerHandle::Get()->PostTask( | 191 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 193 FROM_HERE, base::Bind(&UIControlsOzone::PostKeyEventTask, | 192 FROM_HERE, base::Bind(&UIControlsOzone::PostKeyEventTask, |
| 194 base::Unretained(this), type, key_code, flags)); | 193 base::Unretained(this), type, key_code, flags)); |
| 195 } | 194 } |
| 196 | 195 |
| 197 void PostKeyEventTask(ui::EventType type, | 196 void PostKeyEventTask(ui::EventType type, |
| 198 ui::KeyboardCode key_code, | 197 ui::KeyboardCode key_code, |
| 199 int flags) { | 198 int flags) { |
| 200 // Do not rewrite injected events. See crbug.com/136465. | 199 // Do not rewrite injected events. See crbug.com/136465. |
| 201 flags |= ui::EF_FINAL; | 200 flags |= ui::EF_FINAL; |
| 202 | 201 |
| 203 ui::KeyEvent key_event(type, key_code, flags); | 202 ui::KeyEvent key_event(type, key_code, flags); |
| 204 SendEventToProcessor(&key_event); | 203 SendEventToSink(&key_event); |
| 205 } | 204 } |
| 206 | 205 |
| 207 void PostMouseEvent(ui::EventType type, | 206 void PostMouseEvent(ui::EventType type, |
| 208 const gfx::Point& host_location, | 207 const gfx::Point& host_location, |
| 209 int flags, | 208 int flags, |
| 210 int changed_button_flags) { | 209 int changed_button_flags) { |
| 211 base::ThreadTaskRunnerHandle::Get()->PostTask( | 210 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 212 FROM_HERE, | 211 FROM_HERE, |
| 213 base::Bind(&UIControlsOzone::PostMouseEventTask, base::Unretained(this), | 212 base::Bind(&UIControlsOzone::PostMouseEventTask, base::Unretained(this), |
| 214 type, host_location, flags, changed_button_flags)); | 213 type, host_location, flags, changed_button_flags)); |
| 215 } | 214 } |
| 216 | 215 |
| 217 void PostMouseEventTask(ui::EventType type, | 216 void PostMouseEventTask(ui::EventType type, |
| 218 const gfx::Point& host_location, | 217 const gfx::Point& host_location, |
| 219 int flags, | 218 int flags, |
| 220 int changed_button_flags) { | 219 int changed_button_flags) { |
| 221 ui::MouseEvent mouse_event(type, host_location, host_location, | 220 ui::MouseEvent mouse_event(type, host_location, host_location, |
| 222 ui::EventTimeForNow(), flags, | 221 ui::EventTimeForNow(), flags, |
| 223 changed_button_flags); | 222 changed_button_flags); |
| 224 | 223 |
| 225 // This hack is necessary to set the repeat count for clicks. | 224 // This hack is necessary to set the repeat count for clicks. |
| 226 ui::MouseEvent mouse_event2(&mouse_event); | 225 ui::MouseEvent mouse_event2(&mouse_event); |
| 227 | 226 |
| 228 SendEventToProcessor(&mouse_event2); | 227 SendEventToSink(&mouse_event2); |
| 229 } | 228 } |
| 230 | 229 |
| 231 WindowTreeHost* host_; | 230 WindowTreeHost* host_; |
| 232 | 231 |
| 233 // Mask of the mouse buttons currently down. | 232 // Mask of the mouse buttons currently down. |
| 234 unsigned button_down_mask_ = 0; | 233 unsigned button_down_mask_ = 0; |
| 235 | 234 |
| 236 DISALLOW_COPY_AND_ASSIGN(UIControlsOzone); | 235 DISALLOW_COPY_AND_ASSIGN(UIControlsOzone); |
| 237 }; | 236 }; |
| 238 | 237 |
| 239 } // namespace | 238 } // namespace |
| 240 | 239 |
| 241 ui_controls::UIControlsAura* CreateUIControlsAura(WindowTreeHost* host) { | 240 ui_controls::UIControlsAura* CreateUIControlsAura(WindowTreeHost* host) { |
| 242 return new UIControlsOzone(host); | 241 return new UIControlsOzone(host); |
| 243 } | 242 } |
| 244 | 243 |
| 245 } // namespace test | 244 } // namespace test |
| 246 } // namespace aura | 245 } // namespace aura |
| OLD | NEW |