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

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

Issue 7471006: Revert 93223 - Reland http://codereview.chromium.org/7452002/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 5 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) 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"
22 #include "ppapi/cpp/completion_callback.h" 23 #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
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);
59 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD);
60 } 58 }
61 59
62 ChromotingInstance::~ChromotingInstance() { 60 ChromotingInstance::~ChromotingInstance() {
63 DCHECK(CurrentlyOnPluginThread()); 61 DCHECK(CurrentlyOnPluginThread());
64 62
65 if (client_.get()) { 63 if (client_.get()) {
66 base::WaitableEvent done_event(true, false); 64 base::WaitableEvent done_event(true, false);
67 client_->Stop(base::Bind(&base::WaitableEvent::Signal, 65 client_->Stop(base::Bind(&base::WaitableEvent::Signal,
68 base::Unretained(&done_event))); 66 base::Unretained(&done_event)));
69 done_event.Wait(); 67 done_event.Wait();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 162
165 void ChromotingInstance::DidChangeView(const pp::Rect& position, 163 void ChromotingInstance::DidChangeView(const pp::Rect& position,
166 const pp::Rect& clip) { 164 const pp::Rect& clip) {
167 // This lets |view_| implement scale-to-fit. But it only specifies a 165 // This lets |view_| implement scale-to-fit. But it only specifies a
168 // sub-rectangle of the plugin window as the rectangle on which the host 166 // sub-rectangle of the plugin window as the rectangle on which the host
169 // screen can be displayed, so |view_| has to make sure the plugin window 167 // screen can be displayed, so |view_| has to make sure the plugin window
170 // is large. 168 // is large.
171 view_->SetScreenSize(clip.width(), clip.height()); 169 view_->SetScreenSize(clip.width(), clip.height());
172 } 170 }
173 171
174 bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) { 172 bool ChromotingInstance::HandleInputEvent(const PP_InputEvent& event) {
175 DCHECK(CurrentlyOnPluginThread()); 173 DCHECK(CurrentlyOnPluginThread());
176 174
177 PepperInputHandler* pih 175 PepperInputHandler* pih
178 = static_cast<PepperInputHandler*>(input_handler_.get()); 176 = static_cast<PepperInputHandler*>(input_handler_.get());
179 177
180 switch (event.GetType()) { 178 switch (event.type) {
181 case PP_INPUTEVENT_TYPE_MOUSEDOWN: { 179 case PP_INPUTEVENT_TYPE_MOUSEDOWN:
182 pih->HandleMouseButtonEvent(true, pp::MouseInputEvent(event)); 180 pih->HandleMouseButtonEvent(true, event.u.mouse);
183 return true; 181 return true;
184 }
185 182
186 case PP_INPUTEVENT_TYPE_MOUSEUP: { 183 case PP_INPUTEVENT_TYPE_MOUSEUP:
187 pih->HandleMouseButtonEvent(false, pp::MouseInputEvent(event)); 184 pih->HandleMouseButtonEvent(false, event.u.mouse);
188 return true; 185 return true;
189 }
190 186
191 case PP_INPUTEVENT_TYPE_MOUSEMOVE: 187 case PP_INPUTEVENT_TYPE_MOUSEMOVE:
192 case PP_INPUTEVENT_TYPE_MOUSEENTER: 188 case PP_INPUTEVENT_TYPE_MOUSEENTER:
193 case PP_INPUTEVENT_TYPE_MOUSELEAVE: { 189 case PP_INPUTEVENT_TYPE_MOUSELEAVE:
194 pih->HandleMouseMoveEvent(pp::MouseInputEvent(event)); 190 pih->HandleMouseMoveEvent(event.u.mouse);
195 return true; 191 return true;
196 }
197 192
198 case PP_INPUTEVENT_TYPE_CONTEXTMENU: { 193 case PP_INPUTEVENT_TYPE_CONTEXTMENU:
199 // We need to return true here or else we'll get a local (plugin) context 194 // We need to return true here or else we'll get a local (plugin) context
200 // menu instead of the mouseup event for the right click. 195 // menu instead of the mouseup event for the right click.
201 return true; 196 return true;
202 }
203 197
204 case PP_INPUTEVENT_TYPE_KEYDOWN: 198 case PP_INPUTEVENT_TYPE_KEYDOWN:
205 case PP_INPUTEVENT_TYPE_KEYUP: { 199 case PP_INPUTEVENT_TYPE_KEYUP:
206 pp::KeyboardInputEvent key_event(event);
207 logger_.VLog(3, "PP_INPUTEVENT_TYPE_KEY%s key=%d", 200 logger_.VLog(3, "PP_INPUTEVENT_TYPE_KEY%s key=%d",
208 (event.GetType()==PP_INPUTEVENT_TYPE_KEYDOWN ? "DOWN" : "UP"), 201 (event.type==PP_INPUTEVENT_TYPE_KEYDOWN ? "DOWN" : "UP"),
209 key_event.GetKeyCode()); 202 event.u.key.key_code);
210 pih->HandleKeyEvent(event.GetType() == PP_INPUTEVENT_TYPE_KEYDOWN, 203 pih->HandleKeyEvent(event.type == PP_INPUTEVENT_TYPE_KEYDOWN,
211 key_event); 204 event.u.key);
212 return true; 205 return true;
213 }
214 206
215 case PP_INPUTEVENT_TYPE_CHAR: { 207 case PP_INPUTEVENT_TYPE_CHAR:
216 pih->HandleCharacterEvent(pp::KeyboardInputEvent(event)); 208 pih->HandleCharacterEvent(event.u.character);
217 return true; 209 return true;
218 }
219 210
220 default: 211 default:
221 break; 212 break;
222 } 213 }
223 214
224 return false; 215 return false;
225 } 216 }
226 217
227 ChromotingScriptableObject* ChromotingInstance::GetScriptableObject() { 218 ChromotingScriptableObject* ChromotingInstance::GetScriptableObject() {
228 pp::VarPrivate object = GetInstanceObject(); 219 pp::VarPrivate object = GetInstanceObject();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 if (!client_.get()) 281 if (!client_.get())
291 return NULL; 282 return NULL;
292 return client_->GetStats(); 283 return client_->GetStats();
293 } 284 }
294 285
295 void ChromotingInstance::ReleaseAllKeys() { 286 void ChromotingInstance::ReleaseAllKeys() {
296 input_handler_->ReleaseAllKeys(); 287 input_handler_->ReleaseAllKeys();
297 } 288 }
298 289
299 } // namespace remoting 290 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/plugin/chromoting_instance.h ('k') | remoting/client/plugin/pepper_input_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698