| 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 "ui/events/platform/platform_event_source.h" | 5 #include "ui/events/platform/platform_event_source.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" |
| 9 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 10 #include "ui/events/platform/platform_event_dispatcher.h" | 11 #include "ui/events/platform/platform_event_dispatcher.h" |
| 11 #include "ui/events/platform/platform_event_observer.h" | 12 #include "ui/events/platform/platform_event_observer.h" |
| 12 #include "ui/events/platform/scoped_event_dispatcher.h" | 13 #include "ui/events/platform/scoped_event_dispatcher.h" |
| 13 | 14 |
| 14 namespace ui { | 15 namespace ui { |
| 15 | 16 |
| 16 // static | 17 // static |
| 17 PlatformEventSource* PlatformEventSource::instance_ = NULL; | 18 PlatformEventSource* PlatformEventSource::instance_ = NULL; |
| 18 | 19 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 36 dispatchers_.AddObserver(dispatcher); | 37 dispatchers_.AddObserver(dispatcher); |
| 37 OnDispatcherListChanged(); | 38 OnDispatcherListChanged(); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void PlatformEventSource::RemovePlatformEventDispatcher( | 41 void PlatformEventSource::RemovePlatformEventDispatcher( |
| 41 PlatformEventDispatcher* dispatcher) { | 42 PlatformEventDispatcher* dispatcher) { |
| 42 dispatchers_.RemoveObserver(dispatcher); | 43 dispatchers_.RemoveObserver(dispatcher); |
| 43 OnDispatcherListChanged(); | 44 OnDispatcherListChanged(); |
| 44 } | 45 } |
| 45 | 46 |
| 46 scoped_ptr<ScopedEventDispatcher> PlatformEventSource::OverrideDispatcher( | 47 std::unique_ptr<ScopedEventDispatcher> PlatformEventSource::OverrideDispatcher( |
| 47 PlatformEventDispatcher* dispatcher) { | 48 PlatformEventDispatcher* dispatcher) { |
| 48 CHECK(dispatcher); | 49 CHECK(dispatcher); |
| 49 overridden_dispatcher_restored_ = false; | 50 overridden_dispatcher_restored_ = false; |
| 50 return make_scoped_ptr( | 51 return base::WrapUnique( |
| 51 new ScopedEventDispatcher(&overridden_dispatcher_, dispatcher)); | 52 new ScopedEventDispatcher(&overridden_dispatcher_, dispatcher)); |
| 52 } | 53 } |
| 53 | 54 |
| 54 void PlatformEventSource::StopCurrentEventStream() { | 55 void PlatformEventSource::StopCurrentEventStream() { |
| 55 } | 56 } |
| 56 | 57 |
| 57 void PlatformEventSource::AddPlatformEventObserver( | 58 void PlatformEventSource::AddPlatformEventObserver( |
| 58 PlatformEventObserver* observer) { | 59 PlatformEventObserver* observer) { |
| 59 CHECK(observer); | 60 CHECK(observer); |
| 60 observers_.AddObserver(observer); | 61 observers_.AddObserver(observer); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 103 |
| 103 void PlatformEventSource::OnDispatcherListChanged() { | 104 void PlatformEventSource::OnDispatcherListChanged() { |
| 104 } | 105 } |
| 105 | 106 |
| 106 void PlatformEventSource::OnOverriddenDispatcherRestored() { | 107 void PlatformEventSource::OnOverriddenDispatcherRestored() { |
| 107 CHECK(overridden_dispatcher_); | 108 CHECK(overridden_dispatcher_); |
| 108 overridden_dispatcher_restored_ = true; | 109 overridden_dispatcher_restored_ = true; |
| 109 } | 110 } |
| 110 | 111 |
| 111 } // namespace ui | 112 } // namespace ui |
| OLD | NEW |