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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/plugin/chromoting_plugin.cc
===================================================================
--- remoting/client/plugin/chromoting_plugin.cc (revision 0)
+++ remoting/client/plugin/chromoting_plugin.cc (revision 0)
@@ -0,0 +1,114 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/client/plugin/chromoting_plugin.h"
+
+#include "remoting/client/plugin/client.h"
+
+namespace remoting {
+
+ChromotingPlugin::ChromotingPlugin(NPNetscapeFuncs* browser_funcs,
+ NPP instance)
+ : PepperPlugin(browser_funcs, instance) {
+ device_ = extensions()->acquireDevice(instance, NPPepper2DDevice);
+ client_ = new ChromotingClient(this);
+}
+
+ChromotingPlugin::~ChromotingPlugin() {
+}
+
+NPError ChromotingPlugin::New(NPMIMEType pluginType,
+ int16 argc, char* argn[], char* argv[]) {
+ // Verify the mime type and subtype
+ std::string mime(kMimeType);
+ std::string::size_type type_end = mime.find("/");
+ std::string::size_type subtype_end = mime.find(":", type_end);
+ if (strncmp(pluginType, kMimeType, subtype_end)) {
+ return NPERR_GENERIC_ERROR;
+ }
+
+ // Extract the URL from the arguments.
+ char* url = NULL;
+ for (int i = 0; i < argc; ++i) {
+ if (strcmp(argn[i], "src") == 0) {
+ url = argv[i];
+ break;
+ }
+ }
+
+ if (!url) {
+ return NPERR_GENERIC_ERROR;
+ }
+
+ return NPERR_NO_ERROR;
+}
+
+NPError ChromotingPlugin::Destroy(NPSavedData** save) {
+ return NPERR_NO_ERROR;
+}
+
+void ChromotingPlugin::draw() {
+ NPDeviceContext2D context;
+ NPDeviceContext2DConfig config;
+ device_->initializeContext(instance(), &config, &context);
+
+ client_->draw(width_, height_, &context);
+
+ device_->flushContext(instance(), &context, NULL, NULL);
+}
+
+NPError ChromotingPlugin::SetWindow(NPWindow* window) {
+ width_ = window->width;
+ height_ = window->height;
+
+ client_->set_window();
+
+ draw();
+
+ return NPERR_NO_ERROR;
+}
+
+int16 ChromotingPlugin::HandleEvent(void* event) {
+ NPPepperEvent* npevent = static_cast<NPPepperEvent*>(event);
+ char ch;
+
+ switch (npevent->type) {
+ case NPEventType_MouseDown:
+ // Fall through
+ case NPEventType_MouseUp:
+ // Fall through
+ case NPEventType_MouseMove:
+ // Fall through
+ case NPEventType_MouseEnter:
+ // Fall through
+ case NPEventType_MouseLeave:
+ client_->handle_mouse_event(npevent);
+ break;
+ case NPEventType_MouseWheel:
+ case NPEventType_RawKeyDown:
+ break;
+ case NPEventType_KeyDown:
+ case NPEventType_KeyUp:
+ break;
+ case NPEventType_Char:
+ client_->handle_char_event(npevent);
+ break;
+ case NPEventType_Minimize:
+ case NPEventType_Focus:
+ case NPEventType_Device:
+ break;
+ }
+
+ return false;
+}
+
+NPError ChromotingPlugin::GetValue(NPPVariable variable, void* value) {
+ return NPERR_NO_ERROR;
+}
+
+NPError ChromotingPlugin::SetValue(NPNVariable variable, void* value) {
+ return NPERR_NO_ERROR;
+}
+
+} // namespace remoting
Property changes on: remoting/client/plugin/chromoting_plugin.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« 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