Move GetProcessIntegrityLevel to file_info.h and remove the handle argument.
[chromium-blink-merge.git] / ppapi / tests / manual / delete_plugin.cc
blob788100bfe7d550ff753d9255d5717f433cc92aff
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.
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"
14 class MyInstance : public pp::Instance {
15 public:
16 MyInstance(PP_Instance instance) : pp::Instance(instance) {
17 factory_.Initialize(this);
20 virtual ~MyInstance() {
23 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) {
24 return true;
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;
42 private:
43 void SayHello(int32_t) {
44 pp::Var code("deletePlugin()");
46 When scripting is removed from instance, this is the code that will do the
47 same thing:
48 const PPB_Instance_Trusted* inst =
49 (const PPB_Instance_Trusted*)pp::Module::Get()->GetBrowserInterface(
50 PPB_INSTANCE_TRUSTED_INTERFACE);
51 inst->ExecuteScript(pp_instance(), code.pp_var(), NULL);
53 ExecuteScript(code);
56 pp::CompletionCallbackFactory<MyInstance> factory_;
59 class MyModule : public pp::Module {
60 public:
61 MyModule() : pp::Module() {}
62 virtual ~MyModule() {}
64 virtual pp::Instance* CreateInstance(PP_Instance instance) {
65 return new MyInstance(instance);
69 namespace pp {
71 // Factory function for your specialization of the Module object.
72 Module* CreateModule() {
73 return new MyModule();
76 } // namespace pp