| 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 "remoting/host/single_window_input_injector.h" | 5 #include "remoting/host/single_window_input_injector.h" |
| 6 | 6 |
| 7 #include <ApplicationServices/ApplicationServices.h> | 7 #include <ApplicationServices/ApplicationServices.h> |
| 8 #include <Carbon/Carbon.h> | 8 #include <Carbon/Carbon.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/mac/foundation_util.h" | 12 #include "base/mac/foundation_util.h" |
| 13 #include "base/mac/scoped_cftyperef.h" | 13 #include "base/mac/scoped_cftyperef.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" |
| 15 #include "remoting/proto/event.pb.h" | 16 #include "remoting/proto/event.pb.h" |
| 16 #include "third_party/webrtc/modules/desktop_capture/mac/desktop_configuration.h
" | 17 #include "third_party/webrtc/modules/desktop_capture/mac/desktop_configuration.h
" |
| 17 | 18 |
| 18 namespace remoting { | 19 namespace remoting { |
| 19 | 20 |
| 20 using protocol::ClipboardEvent; | 21 using protocol::ClipboardEvent; |
| 21 using protocol::KeyEvent; | 22 using protocol::KeyEvent; |
| 22 using protocol::TextEvent; | 23 using protocol::TextEvent; |
| 23 using protocol::MouseEvent; | 24 using protocol::MouseEvent; |
| 24 using protocol::TouchEvent; | 25 using protocol::TouchEvent; |
| 25 | 26 |
| 26 class SingleWindowInputInjectorMac : public SingleWindowInputInjector { | 27 class SingleWindowInputInjectorMac : public SingleWindowInputInjector { |
| 27 public: | 28 public: |
| 28 SingleWindowInputInjectorMac( | 29 SingleWindowInputInjectorMac(webrtc::WindowId window_id, |
| 29 webrtc::WindowId window_id, | 30 std::unique_ptr<InputInjector> input_injector); |
| 30 scoped_ptr<InputInjector> input_injector); | |
| 31 ~SingleWindowInputInjectorMac() override; | 31 ~SingleWindowInputInjectorMac() override; |
| 32 | 32 |
| 33 // InputInjector interface. | 33 // InputInjector interface. |
| 34 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard) override; | 34 void Start( |
| 35 std::unique_ptr<protocol::ClipboardStub> client_clipboard) override; |
| 35 void InjectKeyEvent(const KeyEvent& event) override; | 36 void InjectKeyEvent(const KeyEvent& event) override; |
| 36 void InjectTextEvent(const TextEvent& event) override; | 37 void InjectTextEvent(const TextEvent& event) override; |
| 37 void InjectMouseEvent(const MouseEvent& event) override; | 38 void InjectMouseEvent(const MouseEvent& event) override; |
| 38 void InjectTouchEvent(const TouchEvent& event) override; | 39 void InjectTouchEvent(const TouchEvent& event) override; |
| 39 void InjectClipboardEvent(const ClipboardEvent& event) override; | 40 void InjectClipboardEvent(const ClipboardEvent& event) override; |
| 40 | 41 |
| 41 private: | 42 private: |
| 42 CGRect FindCGRectOfWindow(); | 43 CGRect FindCGRectOfWindow(); |
| 43 | 44 |
| 44 CGWindowID window_id_; | 45 CGWindowID window_id_; |
| 45 scoped_ptr<InputInjector> input_injector_; | 46 std::unique_ptr<InputInjector> input_injector_; |
| 46 | 47 |
| 47 DISALLOW_COPY_AND_ASSIGN(SingleWindowInputInjectorMac); | 48 DISALLOW_COPY_AND_ASSIGN(SingleWindowInputInjectorMac); |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 SingleWindowInputInjectorMac::SingleWindowInputInjectorMac( | 51 SingleWindowInputInjectorMac::SingleWindowInputInjectorMac( |
| 51 webrtc::WindowId window_id, | 52 webrtc::WindowId window_id, |
| 52 scoped_ptr<InputInjector> input_injector) | 53 std::unique_ptr<InputInjector> input_injector) |
| 53 : window_id_(static_cast<CGWindowID>(window_id)), | 54 : window_id_(static_cast<CGWindowID>(window_id)), |
| 54 input_injector_(std::move(input_injector)) {} | 55 input_injector_(std::move(input_injector)) {} |
| 55 | 56 |
| 56 SingleWindowInputInjectorMac::~SingleWindowInputInjectorMac() {} | 57 SingleWindowInputInjectorMac::~SingleWindowInputInjectorMac() {} |
| 57 | 58 |
| 58 void SingleWindowInputInjectorMac::Start( | 59 void SingleWindowInputInjectorMac::Start( |
| 59 scoped_ptr<protocol::ClipboardStub> client_clipboard) { | 60 std::unique_ptr<protocol::ClipboardStub> client_clipboard) { |
| 60 input_injector_->Start(std::move(client_clipboard)); | 61 input_injector_->Start(std::move(client_clipboard)); |
| 61 } | 62 } |
| 62 | 63 |
| 63 void SingleWindowInputInjectorMac::InjectKeyEvent(const KeyEvent& event) { | 64 void SingleWindowInputInjectorMac::InjectKeyEvent(const KeyEvent& event) { |
| 64 input_injector_->InjectKeyEvent(event); | 65 input_injector_->InjectKeyEvent(event); |
| 65 } | 66 } |
| 66 | 67 |
| 67 void SingleWindowInputInjectorMac::InjectTextEvent(const TextEvent& event) { | 68 void SingleWindowInputInjectorMac::InjectTextEvent(const TextEvent& event) { |
| 68 input_injector_->InjectTextEvent(event); | 69 input_injector_->InjectTextEvent(event); |
| 69 } | 70 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 if (bounds) { | 155 if (bounds) { |
| 155 if (CGRectMakeWithDictionaryRepresentation(bounds, &rect)) { | 156 if (CGRectMakeWithDictionaryRepresentation(bounds, &rect)) { |
| 156 return rect; | 157 return rect; |
| 157 } | 158 } |
| 158 } | 159 } |
| 159 } | 160 } |
| 160 | 161 |
| 161 return CGRectNull; | 162 return CGRectNull; |
| 162 } | 163 } |
| 163 | 164 |
| 164 scoped_ptr<InputInjector> SingleWindowInputInjector::CreateForWindow( | 165 std::unique_ptr<InputInjector> SingleWindowInputInjector::CreateForWindow( |
| 165 webrtc::WindowId window_id, | 166 webrtc::WindowId window_id, |
| 166 scoped_ptr<InputInjector> input_injector) { | 167 std::unique_ptr<InputInjector> input_injector) { |
| 167 return make_scoped_ptr( | 168 return base::WrapUnique( |
| 168 new SingleWindowInputInjectorMac(window_id, std::move(input_injector))); | 169 new SingleWindowInputInjectorMac(window_id, std::move(input_injector))); |
| 169 } | 170 } |
| 170 | 171 |
| 171 } // namespace remoting | 172 } // namespace remoting |
| OLD | NEW |