wez | 14737014 | 2014-11-24 19:10:50 | [diff] [blame] | 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. |
| 4 | |
| 5 | #ifndef REMOTING_CLIENT_PLUGIN_PEPPER_CURSOR_SETTER_H_ |
| 6 | #define REMOTING_CLIENT_PLUGIN_PEPPER_CURSOR_SETTER_H_ |
| 7 | |
avi | 5a080f01 | 2015-12-22 23:15:43 | [diff] [blame] | 8 | #include "base/macros.h" |
wez | 14737014 | 2014-11-24 19:10:50 | [diff] [blame] | 9 | #include "ppapi/cpp/instance_handle.h" |
| 10 | #include "remoting/protocol/cursor_shape_stub.h" |
| 11 | |
| 12 | namespace remoting { |
| 13 | |
| 14 | // Helper that applies supplied cursor shapes to the plugin. |
| 15 | class PepperCursorSetter : public protocol::CursorShapeStub { |
| 16 | public: |
| 17 | explicit PepperCursorSetter(const pp::InstanceHandle& instance); |
| 18 | ~PepperCursorSetter() override; |
| 19 | |
| 20 | // protocol::CursorShapeStub interface. |
| 21 | void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) override; |
| 22 | |
| 23 | // Sets a CursorShapeStub to which the cursor will be delegated if it cannot |
| 24 | // be set via PPAPI. |
| 25 | void set_delegate_stub(protocol::CursorShapeStub* delegate_stub) { |
| 26 | delegate_stub_ = delegate_stub; |
| 27 | } |
| 28 | |
| 29 | // Maximum width and height of a mouse cursor supported by PPAPI. |
| 30 | static const int kMaxCursorWidth = 32; |
| 31 | static const int kMaxCursorHeight = 32; |
| 32 | |
| 33 | private: |
| 34 | // Attempts to set the supplied cursor via PPAPI, returning true on success. |
| 35 | bool SetInstanceCursor(const protocol::CursorShapeInfo& cursor_shape); |
| 36 | |
| 37 | pp::InstanceHandle instance_; |
| 38 | protocol::CursorShapeStub* delegate_stub_; |
| 39 | |
| 40 | DISALLOW_COPY_AND_ASSIGN(PepperCursorSetter); |
| 41 | }; |
| 42 | |
| 43 | } // namespace remoting |
| 44 | |
| 45 | #endif // REMOTING_CLIENT_PLUGIN_PEPPER_CURSOR_SETTER_H_ |