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

Side by Side Diff: ppapi/example/example.cc

Issue 7285010: Implement an input event resource. (Closed) Base URL: svn://chrome-svn/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 <math.h> 5 #include <math.h>
6 #include <stdio.h> // FIXME(brettw) erase me. 6 #include <stdio.h> // FIXME(brettw) erase me.
7 #ifndef _WIN32 7 #ifndef _WIN32
8 #include <sys/time.h> 8 #include <sys/time.h>
9 #else 9 #else
10 #include <windows.h> 10 #include <windows.h>
11 #endif 11 #endif
12 #include <time.h> 12 #include <time.h>
13 13
14 #include <algorithm> 14 #include <algorithm>
15 15
16 #include "ppapi/c/dev/ppb_console_dev.h" 16 #include "ppapi/c/dev/ppb_console_dev.h"
17 #include "ppapi/c/dev/ppb_cursor_control_dev.h" 17 #include "ppapi/c/dev/ppb_cursor_control_dev.h"
18 #include "ppapi/c/dev/ppp_printing_dev.h" 18 #include "ppapi/c/dev/ppp_printing_dev.h"
19 #include "ppapi/c/pp_errors.h" 19 #include "ppapi/c/pp_errors.h"
20 #include "ppapi/c/pp_input_event.h"
21 #include "ppapi/c/pp_rect.h" 20 #include "ppapi/c/pp_rect.h"
22 #include "ppapi/cpp/completion_callback.h" 21 #include "ppapi/cpp/completion_callback.h"
23 #include "ppapi/cpp/dev/scriptable_object_deprecated.h" 22 #include "ppapi/cpp/dev/scriptable_object_deprecated.h"
24 #include "ppapi/cpp/graphics_2d.h" 23 #include "ppapi/cpp/graphics_2d.h"
25 #include "ppapi/cpp/image_data.h" 24 #include "ppapi/cpp/image_data.h"
25 #include "ppapi/cpp/input_event.h"
26 #include "ppapi/cpp/private/instance_private.h" 26 #include "ppapi/cpp/private/instance_private.h"
27 #include "ppapi/cpp/module.h" 27 #include "ppapi/cpp/module.h"
28 #include "ppapi/cpp/private/var_private.h" 28 #include "ppapi/cpp/private/var_private.h"
29 #include "ppapi/cpp/rect.h" 29 #include "ppapi/cpp/rect.h"
30 #include "ppapi/cpp/url_loader.h" 30 #include "ppapi/cpp/url_loader.h"
31 #include "ppapi/cpp/url_request_info.h" 31 #include "ppapi/cpp/url_request_info.h"
32 #include "ppapi/cpp/var.h" 32 #include "ppapi/cpp/var.h"
33 33
34 static const int kStepsPerCircle = 800; 34 static const int kStepsPerCircle = 800;
35 35
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 class MyInstance : public pp::InstancePrivate, public MyFetcherClient { 162 class MyInstance : public pp::InstancePrivate, public MyFetcherClient {
163 public: 163 public:
164 MyInstance(PP_Instance instance) 164 MyInstance(PP_Instance instance)
165 : pp::InstancePrivate(instance), 165 : pp::InstancePrivate(instance),
166 time_at_last_check_(0.0), 166 time_at_last_check_(0.0),
167 fetcher_(NULL), 167 fetcher_(NULL),
168 width_(0), 168 width_(0),
169 height_(0), 169 height_(0),
170 animation_counter_(0), 170 animation_counter_(0),
171 print_settings_valid_(false), 171 print_settings_valid_(false),
172 showing_custom_cursor_(false) {} 172 showing_custom_cursor_(false) {
173 RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
174 }
173 175
174 virtual ~MyInstance() { 176 virtual ~MyInstance() {
175 if (fetcher_) { 177 if (fetcher_) {
176 delete fetcher_; 178 delete fetcher_;
177 fetcher_ = NULL; 179 fetcher_ = NULL;
178 } 180 }
179 } 181 }
180 182
181 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) { 183 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) {
182 return true; 184 return true;
183 } 185 }
184 186
185 void Log(PP_LogLevel_Dev level, const pp::Var& value) { 187 void Log(PP_LogLevel_Dev level, const pp::Var& value) {
186 const PPB_Console_Dev* console = reinterpret_cast<const PPB_Console_Dev*>( 188 const PPB_Console_Dev* console = reinterpret_cast<const PPB_Console_Dev*>(
187 pp::Module::Get()->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE)); 189 pp::Module::Get()->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE));
188 if (!console) 190 if (!console)
189 return; 191 return;
190 console->Log(pp_instance(), level, value.pp_var()); 192 console->Log(pp_instance(), level, value.pp_var());
191 } 193 }
192 194
193 virtual bool HandleDocumentLoad(const pp::URLLoader& loader) { 195 virtual bool HandleDocumentLoad(const pp::URLLoader& loader) {
194 fetcher_ = new MyFetcher(); 196 fetcher_ = new MyFetcher();
195 fetcher_->StartWithOpenedLoader(loader, this); 197 fetcher_->StartWithOpenedLoader(loader, this);
196 return true; 198 return true;
197 } 199 }
198 200
199 virtual bool HandleInputEvent(const PP_InputEvent& event) { 201 virtual bool HandleInputEvent(const pp::InputEvent& event) {
200 switch (event.type) { 202 switch (event.GetEventType()) {
201 case PP_INPUTEVENT_TYPE_MOUSEDOWN: 203 case PP_INPUTEVENT_TYPE_MOUSEDOWN:
202 SayHello(); 204 SayHello();
203 ToggleCursor(); 205 ToggleCursor();
204 return true; 206 return true;
205 case PP_INPUTEVENT_TYPE_MOUSEMOVE: 207 case PP_INPUTEVENT_TYPE_MOUSEMOVE:
206 return true; 208 return true;
207 case PP_INPUTEVENT_TYPE_KEYDOWN: 209 case PP_INPUTEVENT_TYPE_KEYDOWN:
208 return true; 210 return true;
209 default: 211 default:
210 return false; 212 return false;
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 }; 484 };
483 485
484 namespace pp { 486 namespace pp {
485 487
486 // Factory function for your specialization of the Module object. 488 // Factory function for your specialization of the Module object.
487 Module* CreateModule() { 489 Module* CreateModule() {
488 return new MyModule(); 490 return new MyModule();
489 } 491 }
490 492
491 } // namespace pp 493 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698