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

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

Issue 2690003: Copy the (early prototype of) remoting in Chrome into the public tree.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 #include "remoting/client/plugin/chromoting_plugin.h"
6
7 #include "remoting/client/plugin/client.h"
8
9 namespace remoting {
10
11 ChromotingPlugin::ChromotingPlugin(NPNetscapeFuncs* browser_funcs,
12 NPP instance)
13 : PepperPlugin(browser_funcs, instance) {
14 device_ = extensions()->acquireDevice(instance, NPPepper2DDevice);
15 client_ = new ChromotingClient(this);
16 }
17
18 ChromotingPlugin::~ChromotingPlugin() {
19 }
20
21 NPError ChromotingPlugin::New(NPMIMEType pluginType,
22 int16 argc, char* argn[], char* argv[]) {
23 // Verify the mime type and subtype
24 std::string mime(kMimeType);
25 std::string::size_type type_end = mime.find("/");
26 std::string::size_type subtype_end = mime.find(":", type_end);
27 if (strncmp(pluginType, kMimeType, subtype_end)) {
28 return NPERR_GENERIC_ERROR;
29 }
30
31 // Extract the URL from the arguments.
32 char* url = NULL;
33 for (int i = 0; i < argc; ++i) {
34 if (strcmp(argn[i], "src") == 0) {
35 url = argv[i];
36 break;
37 }
38 }
39
40 if (!url) {
41 return NPERR_GENERIC_ERROR;
42 }
43
44 return NPERR_NO_ERROR;
45 }
46
47 NPError ChromotingPlugin::Destroy(NPSavedData** save) {
48 return NPERR_NO_ERROR;
49 }
50
51 void ChromotingPlugin::draw() {
52 NPDeviceContext2D context;
53 NPDeviceContext2DConfig config;
54 device_->initializeContext(instance(), &config, &context);
55
56 client_->draw(width_, height_, &context);
57
58 device_->flushContext(instance(), &context, NULL, NULL);
59 }
60
61 NPError ChromotingPlugin::SetWindow(NPWindow* window) {
62 width_ = window->width;
63 height_ = window->height;
64
65 client_->set_window();
66
67 draw();
68
69 return NPERR_NO_ERROR;
70 }
71
72 int16 ChromotingPlugin::HandleEvent(void* event) {
73 NPPepperEvent* npevent = static_cast<NPPepperEvent*>(event);
74 char ch;
75
76 switch (npevent->type) {
77 case NPEventType_MouseDown:
78 // Fall through
79 case NPEventType_MouseUp:
80 // Fall through
81 case NPEventType_MouseMove:
82 // Fall through
83 case NPEventType_MouseEnter:
84 // Fall through
85 case NPEventType_MouseLeave:
86 client_->handle_mouse_event(npevent);
87 break;
88 case NPEventType_MouseWheel:
89 case NPEventType_RawKeyDown:
90 break;
91 case NPEventType_KeyDown:
92 case NPEventType_KeyUp:
93 break;
94 case NPEventType_Char:
95 client_->handle_char_event(npevent);
96 break;
97 case NPEventType_Minimize:
98 case NPEventType_Focus:
99 case NPEventType_Device:
100 break;
101 }
102
103 return false;
104 }
105
106 NPError ChromotingPlugin::GetValue(NPPVariable variable, void* value) {
107 return NPERR_NO_ERROR;
108 }
109
110 NPError ChromotingPlugin::SetValue(NPNVariable variable, void* value) {
111 return NPERR_NO_ERROR;
112 }
113
114 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/plugin/chromoting_plugin.h ('k') | remoting/client/plugin/chromoting_plugin_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698