Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/client/plugin/chromoting_instance.h" | 5 #include "remoting/client/plugin/chromoting_instance.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
| 14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
| 15 #include "base/task.h" | 15 #include "base/task.h" |
| 16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
| 17 // TODO(sergeyu): We should not depend on renderer here. Instead P2P | 17 // TODO(sergeyu): We should not depend on renderer here. Instead P2P |
| 18 // Pepper API should be used. Remove this dependency. | 18 // Pepper API should be used. Remove this dependency. |
| 19 // crbug.com/74951 | 19 // crbug.com/74951 |
| 20 #include "content/renderer/p2p/ipc_network_manager.h" | 20 #include "content/renderer/p2p/ipc_network_manager.h" |
| 21 #include "content/renderer/p2p/ipc_socket_factory.h" | 21 #include "content/renderer/p2p/ipc_socket_factory.h" |
| 22 #include "ppapi/c/pp_input_event.h" | |
| 23 #include "ppapi/cpp/completion_callback.h" | 22 #include "ppapi/cpp/completion_callback.h" |
| 23 #include "ppapi/cpp/input_event.h" | |
| 24 #include "ppapi/cpp/rect.h" | 24 #include "ppapi/cpp/rect.h" |
| 25 // TODO(wez): Remove this when crbug.com/86353 is complete. | 25 // TODO(wez): Remove this when crbug.com/86353 is complete. |
| 26 #include "ppapi/cpp/private/var_private.h" | 26 #include "ppapi/cpp/private/var_private.h" |
| 27 #include "remoting/client/client_config.h" | 27 #include "remoting/client/client_config.h" |
| 28 #include "remoting/client/chromoting_client.h" | 28 #include "remoting/client/chromoting_client.h" |
| 29 #include "remoting/client/rectangle_update_decoder.h" | 29 #include "remoting/client/rectangle_update_decoder.h" |
| 30 #include "remoting/client/plugin/chromoting_scriptable_object.h" | 30 #include "remoting/client/plugin/chromoting_scriptable_object.h" |
| 31 #include "remoting/client/plugin/pepper_client_logger.h" | 31 #include "remoting/client/plugin/pepper_client_logger.h" |
| 32 #include "remoting/client/plugin/pepper_input_handler.h" | 32 #include "remoting/client/plugin/pepper_input_handler.h" |
| 33 #include "remoting/client/plugin/pepper_port_allocator_session.h" | 33 #include "remoting/client/plugin/pepper_port_allocator_session.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 48 #include "webkit/plugins/ppapi/resource_tracker.h" | 48 #include "webkit/plugins/ppapi/resource_tracker.h" |
| 49 | 49 |
| 50 namespace remoting { | 50 namespace remoting { |
| 51 | 51 |
| 52 const char* ChromotingInstance::kMimeType = "pepper-application/x-chromoting"; | 52 const char* ChromotingInstance::kMimeType = "pepper-application/x-chromoting"; |
| 53 | 53 |
| 54 ChromotingInstance::ChromotingInstance(PP_Instance pp_instance) | 54 ChromotingInstance::ChromotingInstance(PP_Instance pp_instance) |
| 55 : pp::InstancePrivate(pp_instance), | 55 : pp::InstancePrivate(pp_instance), |
| 56 initialized_(false), | 56 initialized_(false), |
| 57 logger_(this) { | 57 logger_(this) { |
| 58 RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE | PP_INPUTEVENT_CLASS_WHEEL); | |
| 59 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD); | |
| 58 } | 60 } |
| 59 | 61 |
| 60 ChromotingInstance::~ChromotingInstance() { | 62 ChromotingInstance::~ChromotingInstance() { |
| 61 DCHECK(CurrentlyOnPluginThread()); | 63 DCHECK(CurrentlyOnPluginThread()); |
| 62 | 64 |
| 63 if (client_.get()) { | 65 if (client_.get()) { |
| 64 base::WaitableEvent done_event(true, false); | 66 base::WaitableEvent done_event(true, false); |
| 65 client_->Stop(base::Bind(&base::WaitableEvent::Signal, | 67 client_->Stop(base::Bind(&base::WaitableEvent::Signal, |
| 66 base::Unretained(&done_event))); | 68 base::Unretained(&done_event))); |
| 67 done_event.Wait(); | 69 done_event.Wait(); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 | 164 |
| 163 void ChromotingInstance::DidChangeView(const pp::Rect& position, | 165 void ChromotingInstance::DidChangeView(const pp::Rect& position, |
| 164 const pp::Rect& clip) { | 166 const pp::Rect& clip) { |
| 165 // This lets |view_| implement scale-to-fit. But it only specifies a | 167 // This lets |view_| implement scale-to-fit. But it only specifies a |
| 166 // sub-rectangle of the plugin window as the rectangle on which the host | 168 // sub-rectangle of the plugin window as the rectangle on which the host |
| 167 // screen can be displayed, so |view_| has to make sure the plugin window | 169 // screen can be displayed, so |view_| has to make sure the plugin window |
| 168 // is large. | 170 // is large. |
| 169 view_->SetScreenSize(clip.width(), clip.height()); | 171 view_->SetScreenSize(clip.width(), clip.height()); |
| 170 } | 172 } |
| 171 | 173 |
| 172 bool ChromotingInstance::HandleInputEvent(const PP_InputEvent& event) { | 174 bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) { |
| 173 DCHECK(CurrentlyOnPluginThread()); | 175 DCHECK(CurrentlyOnPluginThread()); |
| 174 | 176 |
| 175 PepperInputHandler* pih | 177 PepperInputHandler* pih |
| 176 = static_cast<PepperInputHandler*>(input_handler_.get()); | 178 = static_cast<PepperInputHandler*>(input_handler_.get()); |
| 177 | 179 |
| 178 switch (event.type) { | 180 switch (event.GetType()) { |
| 179 case PP_INPUTEVENT_TYPE_MOUSEDOWN: | 181 case PP_INPUTEVENT_TYPE_MOUSEDOWN: |
| 180 pih->HandleMouseButtonEvent(true, event.u.mouse); | 182 pih->HandleMouseButtonEvent(true, pp::MouseInputEvent(event)); |
| 181 return true; | 183 return true; |
| 182 | 184 |
| 183 case PP_INPUTEVENT_TYPE_MOUSEUP: | 185 case PP_INPUTEVENT_TYPE_MOUSEUP: |
| 184 pih->HandleMouseButtonEvent(false, event.u.mouse); | 186 pih->HandleMouseButtonEvent(false, pp::MouseInputEvent(event)); |
| 185 return true; | 187 return true; |
| 186 | 188 |
| 187 case PP_INPUTEVENT_TYPE_MOUSEMOVE: | 189 case PP_INPUTEVENT_TYPE_MOUSEMOVE: |
| 188 case PP_INPUTEVENT_TYPE_MOUSEENTER: | 190 case PP_INPUTEVENT_TYPE_MOUSEENTER: |
| 189 case PP_INPUTEVENT_TYPE_MOUSELEAVE: | 191 case PP_INPUTEVENT_TYPE_MOUSELEAVE: |
| 190 pih->HandleMouseMoveEvent(event.u.mouse); | 192 pih->HandleMouseMoveEvent(pp::MouseInputEvent(event)); |
| 191 return true; | 193 return true; |
| 192 | 194 |
| 193 case PP_INPUTEVENT_TYPE_CONTEXTMENU: | 195 case PP_INPUTEVENT_TYPE_CONTEXTMENU: |
| 194 // We need to return true here or else we'll get a local (plugin) context | 196 // We need to return true here or else we'll get a local (plugin) context |
| 195 // menu instead of the mouseup event for the right click. | 197 // menu instead of the mouseup event for the right click. |
| 196 return true; | 198 return true; |
| 197 | 199 |
| 198 case PP_INPUTEVENT_TYPE_KEYDOWN: | 200 case PP_INPUTEVENT_TYPE_KEYDOWN: |
| 199 case PP_INPUTEVENT_TYPE_KEYUP: | 201 case PP_INPUTEVENT_TYPE_KEYUP: |
| 200 logger_.VLog(3, "PP_INPUTEVENT_TYPE_KEY%s key=%d", | 202 { |
| 201 (event.type==PP_INPUTEVENT_TYPE_KEYDOWN ? "DOWN" : "UP"), | 203 pp::KeyboardInputEvent key = pp::KeyboardInputEvent(event); |
| 202 event.u.key.key_code); | 204 logger_.VLog(3, "PP_INPUTEVENT_TYPE_KEY%s key=%d", |
| 203 pih->HandleKeyEvent(event.type == PP_INPUTEVENT_TYPE_KEYDOWN, | 205 (event.GetType()==PP_INPUTEVENT_TYPE_KEYDOWN ? "DOWN" : "UP"), |
|
dmac
2011/07/20 00:34:31
space between ) and ==
garykac
2011/07/20 18:55:28
Done.
| |
| 204 event.u.key); | 206 key.GetKeyCode()); |
| 205 return true; | 207 pih->HandleKeyEvent(event.GetType() == PP_INPUTEVENT_TYPE_KEYDOWN, key); |
|
Wez
2011/07/20 00:58:35
nit: Why use event.GetType() == foo here, but not
garykac
2011/07/20 18:55:28
made consistent
| |
| 208 return true; | |
| 209 } | |
| 206 | 210 |
| 207 case PP_INPUTEVENT_TYPE_CHAR: | 211 case PP_INPUTEVENT_TYPE_CHAR: |
| 208 pih->HandleCharacterEvent(event.u.character); | 212 pih->HandleCharacterEvent(pp::KeyboardInputEvent(event)); |
| 209 return true; | 213 return true; |
| 210 | 214 |
| 211 default: | 215 default: |
| 216 LOG(INFO) << "Unhandled input event: " << event.GetType(); | |
| 212 break; | 217 break; |
| 213 } | 218 } |
| 214 | 219 |
| 215 return false; | 220 return false; |
| 216 } | 221 } |
| 217 | 222 |
| 218 ChromotingScriptableObject* ChromotingInstance::GetScriptableObject() { | 223 ChromotingScriptableObject* ChromotingInstance::GetScriptableObject() { |
| 219 pp::VarPrivate object = GetInstanceObject(); | 224 pp::VarPrivate object = GetInstanceObject(); |
| 220 if (!object.is_undefined()) { | 225 if (!object.is_undefined()) { |
| 221 pp::deprecated::ScriptableObject* so = object.AsScriptableObject(); | 226 pp::deprecated::ScriptableObject* so = object.AsScriptableObject(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 if (!client_.get()) | 286 if (!client_.get()) |
| 282 return NULL; | 287 return NULL; |
| 283 return client_->GetStats(); | 288 return client_->GetStats(); |
| 284 } | 289 } |
| 285 | 290 |
| 286 void ChromotingInstance::ReleaseAllKeys() { | 291 void ChromotingInstance::ReleaseAllKeys() { |
| 287 input_handler_->ReleaseAllKeys(); | 292 input_handler_->ReleaseAllKeys(); |
| 288 } | 293 } |
| 289 | 294 |
| 290 } // namespace remoting | 295 } // namespace remoting |
| OLD | NEW |