Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: remoting/client/plugin/chromoting_instance.h

Issue 10025001: Add APIs to the client plugin to re-map and trap key events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // TODO(ajwong): We need to come up with a better description of the 5 // TODO(ajwong): We need to come up with a better description of the
6 // responsibilities for each thread. 6 // responsibilities for each thread.
7 7
8 #ifndef REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_ 8 #ifndef REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_
9 #define REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_ 9 #define REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_
10 10
11 #include <string> 11 #include <string>
12 12
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "ppapi/c/pp_instance.h" 16 #include "ppapi/c/pp_instance.h"
17 #include "ppapi/c/pp_rect.h" 17 #include "ppapi/c/pp_rect.h"
18 #include "ppapi/c/pp_resource.h" 18 #include "ppapi/c/pp_resource.h"
19 #include "ppapi/cpp/var.h" 19 #include "ppapi/cpp/var.h"
20 20
21 // Windows defines 'PostMessage', so we have to undef it before we 21 // Windows defines 'PostMessage', so we have to undef it before we
22 // include instance_private.h 22 // include instance_private.h
23 #if defined(PostMessage) 23 #if defined(PostMessage)
24 #undef PostMessage 24 #undef PostMessage
25 #endif 25 #endif
26 26
27 #include "ppapi/cpp/private/instance_private.h" 27 #include "ppapi/cpp/private/instance_private.h"
28 #include "remoting/base/scoped_thread_proxy.h" 28 #include "remoting/base/scoped_thread_proxy.h"
29 #include "remoting/client/client_context.h" 29 #include "remoting/client/client_context.h"
30 #include "remoting/client/key_event_mapper.h"
30 #include "remoting/client/plugin/pepper_plugin_thread_delegate.h" 31 #include "remoting/client/plugin/pepper_plugin_thread_delegate.h"
31 #include "remoting/proto/event.pb.h" 32 #include "remoting/proto/event.pb.h"
32 #include "remoting/protocol/clipboard_stub.h" 33 #include "remoting/protocol/clipboard_stub.h"
33 #include "remoting/protocol/connection_to_host.h" 34 #include "remoting/protocol/connection_to_host.h"
34 35
35 namespace base { 36 namespace base {
36 class DictionaryValue; 37 class DictionaryValue;
37 } // namespace base 38 } // namespace base
38 39
39 namespace pp { 40 namespace pp {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // Convenience wrapper to get the ChromotingScriptableObject. 135 // Convenience wrapper to get the ChromotingScriptableObject.
135 ChromotingScriptableObject* GetScriptableObject(); 136 ChromotingScriptableObject* GetScriptableObject();
136 137
137 // Message handlers for messages that come from JavaScript. Called 138 // Message handlers for messages that come from JavaScript. Called
138 // from HandleMessage() and ChromotingScriptableObject. 139 // from HandleMessage() and ChromotingScriptableObject.
139 void Connect(const ClientConfig& config); 140 void Connect(const ClientConfig& config);
140 void Disconnect(); 141 void Disconnect();
141 void OnIncomingIq(const std::string& iq); 142 void OnIncomingIq(const std::string& iq);
142 void ReleaseAllKeys(); 143 void ReleaseAllKeys();
143 void InjectKeyEvent(const protocol::KeyEvent& event); 144 void InjectKeyEvent(const protocol::KeyEvent& event);
145 void RemapKey(uint32 in_usb_keycode, uint32 out_usb_keycode);
146 void TrapKey(uint32 usb_keycode, bool trap);
144 void SendClipboardItem(const std::string& mime_type, const std::string& item); 147 void SendClipboardItem(const std::string& mime_type, const std::string& item);
145 148
146 // Return statistics record by ChromotingClient. 149 // Return statistics record by ChromotingClient.
147 // If no connection is currently active then NULL will be returned. 150 // If no connection is currently active then NULL will be returned.
148 ChromotingStats* GetStats(); 151 ChromotingStats* GetStats();
149 152
150 // Registers a global log message handler that redirects the log output to 153 // Registers a global log message handler that redirects the log output to
151 // our plugin instance. 154 // our plugin instance.
152 // This is called by the plugin's PPP_InitializeModule. 155 // This is called by the plugin's PPP_InitializeModule.
153 // Note that no logging will be processed unless a ChromotingInstance has been 156 // Note that no logging will be processed unless a ChromotingInstance has been
(...skipping 15 matching lines...) Expand all
169 static bool LogToUI(int severity, const char* file, int line, 172 static bool LogToUI(int severity, const char* file, int line,
170 size_t message_start, const std::string& str); 173 size_t message_start, const std::string& str);
171 174
172 private: 175 private:
173 FRIEND_TEST_ALL_PREFIXES(ChromotingInstanceTest, TestCaseSetup); 176 FRIEND_TEST_ALL_PREFIXES(ChromotingInstanceTest, TestCaseSetup);
174 177
175 // Helper method to post messages to the webapp. 178 // Helper method to post messages to the webapp.
176 void PostChromotingMessage(const std::string& method, 179 void PostChromotingMessage(const std::string& method,
177 scoped_ptr<base::DictionaryValue> data); 180 scoped_ptr<base::DictionaryValue> data);
178 181
182 // Posts trapped keys to the web-app to handle.
183 void SendTrappedKey(uint32 usb_keycode, bool pressed);
184
179 // Callback for PepperXmppProxy. 185 // Callback for PepperXmppProxy.
180 void SendOutgoingIq(const std::string& iq); 186 void SendOutgoingIq(const std::string& iq);
181 187
182 void SendPerfStats(); 188 void SendPerfStats();
183 189
184 void ProcessLogToUI(const std::string& message); 190 void ProcessLogToUI(const std::string& message);
185 191
186 bool initialized_; 192 bool initialized_;
187 193
188 PepperPluginThreadDelegate plugin_thread_delegate_; 194 PepperPluginThreadDelegate plugin_thread_delegate_;
189 scoped_refptr<PluginMessageLoopProxy> plugin_message_loop_; 195 scoped_refptr<PluginMessageLoopProxy> plugin_message_loop_;
190 ClientContext context_; 196 ClientContext context_;
191 scoped_ptr<protocol::ConnectionToHost> host_connection_; 197 scoped_ptr<protocol::ConnectionToHost> host_connection_;
192 scoped_ptr<PepperView> view_; 198 scoped_ptr<PepperView> view_;
193 199
194 scoped_refptr<RectangleUpdateDecoder> rectangle_decoder_; 200 scoped_refptr<RectangleUpdateDecoder> rectangle_decoder_;
195 scoped_ptr<MouseInputFilter> mouse_input_filter_; 201 scoped_ptr<MouseInputFilter> mouse_input_filter_;
196 scoped_ptr<protocol::InputEventTracker> input_tracker_; 202 scoped_ptr<protocol::InputEventTracker> input_tracker_;
203 KeyEventMapper key_mapper_;
197 scoped_ptr<PepperInputHandler> input_handler_; 204 scoped_ptr<PepperInputHandler> input_handler_;
198 scoped_ptr<ChromotingClient> client_; 205 scoped_ptr<ChromotingClient> client_;
199 206
200 // XmppProxy is a refcounted interface used to perform thread-switching and 207 // XmppProxy is a refcounted interface used to perform thread-switching and
201 // detaching between objects whose lifetimes are controlled by pepper, and 208 // detaching between objects whose lifetimes are controlled by pepper, and
202 // jingle_glue objects. This is used when if we start a sandboxed jingle 209 // jingle_glue objects. This is used when if we start a sandboxed jingle
203 // connection. 210 // connection.
204 scoped_refptr<PepperXmppProxy> xmpp_proxy_; 211 scoped_refptr<PepperXmppProxy> xmpp_proxy_;
205 212
206 // JavaScript interface to control this instance. 213 // JavaScript interface to control this instance.
207 // This wraps a ChromotingScriptableObject in a pp::Var. 214 // This wraps a ChromotingScriptableObject in a pp::Var.
208 pp::Var instance_object_; 215 pp::Var instance_object_;
209 216
210 scoped_ptr<ScopedThreadProxy> thread_proxy_; 217 scoped_ptr<ScopedThreadProxy> thread_proxy_;
211 218
212 DISALLOW_COPY_AND_ASSIGN(ChromotingInstance); 219 DISALLOW_COPY_AND_ASSIGN(ChromotingInstance);
213 }; 220 };
214 221
215 } // namespace remoting 222 } // namespace remoting
216 223
217 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_ 224 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_INSTANCE_H_
OLDNEW
« no previous file with comments | « remoting/client/key_event_mapper_unittest.cc ('k') | remoting/client/plugin/chromoting_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698