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

Side by Side Diff: ppapi/tests/manual/delete_plugin.cc

Issue 6881012: Keep the module in scope when executing scripts. This prevents a crash when the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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) 2011 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 "ppapi/c/pp_errors.h"
6 #include "ppapi/c/pp_input_event.h"
7 #include "ppapi/c/ppb_var.h"
8 #include "ppapi/c/trusted/ppb_instance_trusted.h"
9 #include "ppapi/cpp/completion_callback.h"
10 #include "ppapi/cpp/instance.h"
11 #include "ppapi/cpp/module.h"
12 #include "ppapi/cpp/private/var_private.h"
13
14 class MyInstance : public pp::Instance {
15 public:
16 MyInstance(PP_Instance instance) : pp::Instance(instance) {
17 factory_.Initialize(this);
18 }
19
20 virtual ~MyInstance() {
21 }
22
23 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) {
24 return true;
25 }
26
27 virtual bool HandleInputEvent(const PP_InputEvent& event) {
28 switch (event.type) {
29 case PP_INPUTEVENT_TYPE_MOUSEDOWN:
30 pp::Module::Get()->core()->CallOnMainThread(100,
31 factory_.NewCallback(&MyInstance::SayHello));
32 return true;
33 case PP_INPUTEVENT_TYPE_MOUSEMOVE:
34 return true;
35 case PP_INPUTEVENT_TYPE_KEYDOWN:
36 return true;
37 default:
38 return false;
39 }
40 }
41
42 private:
43 void SayHello(int32_t) {
44 pp::Var code("deletePlugin()");
45 /*
viettrungluu 2011/04/18 19:53:41 Could you add a comment on why it's commented out?
46 const PPB_Instance_Trusted* inst =
47 (const PPB_Instance_Trusted*)pp::Module::Get()->GetBrowserInterface(
48 PPB_INSTANCE_TRUSTED_INTERFACE);
49 inst->ExecuteScript(pp_instance(), code.pp_var(), NULL);
50 */
51 ExecuteScript(code);
52 }
53
54 pp::CompletionCallbackFactory<MyInstance> factory_;
55 };
56
57 class MyModule : public pp::Module {
58 public:
59 MyModule() : pp::Module() {}
60 virtual ~MyModule() {}
61
62 virtual pp::Instance* CreateInstance(PP_Instance instance) {
63 return new MyInstance(instance);
64 }
65 };
66
67 namespace pp {
68
69 // Factory function for your specialization of the Module object.
70 Module* CreateModule() {
71 return new MyModule();
72 }
73
74 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698