h_browser.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* This file was generated by Maki Compiler, do not edit manually */
  2. #include <precomp.h>
  3. #include <api/script/objcontroller.h>
  4. #include "h_browser.h"
  5. H_Browser::H_Browser(ScriptObject *o) : H_GuiObject(o)
  6. {
  7. inited = 0;
  8. obj = NULL;
  9. H_hook(o);
  10. }
  11. H_Browser::H_Browser()
  12. {
  13. inited = 0;
  14. obj = NULL;
  15. }
  16. void H_Browser::H_hook(ScriptObject *o)
  17. {
  18. ASSERT(!inited);
  19. ScriptObjectController *controller = o->vcpu_getController();
  20. obj = controller->cast(o, browserGuid);
  21. if (obj != o && obj != NULL)
  22. o = obj;
  23. else
  24. obj = NULL;
  25. addMonitorObject(o, &browserGuid);
  26. int iter = WASABI_API_APP->app_getInitCount();
  27. if (!loaded || loaded != iter)
  28. {
  29. onbeforenavigate_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onBeforeNavigate", this);
  30. ondocumentcomplete_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onDocumentComplete", this);
  31. onmedialink_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onMediaLink", this);
  32. loaded = 1;
  33. }
  34. inited=1;
  35. }
  36. H_Browser::~H_Browser()
  37. {
  38. if (!inited) return;
  39. WASABI_API_MAKI->maki_remDlfRef(this);
  40. }
  41. ScriptObject *H_Browser::getHookedObject()
  42. {
  43. if (obj != NULL) return obj;
  44. return H_BROWSER_PARENT::getHookedObject();
  45. }
  46. int H_Browser::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams)
  47. {
  48. if (object != getHookedObject()) return 0;
  49. if (H_BROWSER_PARENT::eventCallback(object, dlfid, params, nparams)) return 1;
  50. if (dlfid == onbeforenavigate_id)
  51. {
  52. hook_onBeforeNavigate(GET_SCRIPT_STRING(*params[0]), GET_SCRIPT_INT(*params[1]), GET_SCRIPT_STRING(*params[2]));
  53. return 1;
  54. }
  55. else if (dlfid == ondocumentcomplete_id)
  56. {
  57. hook_onDocumentComplete(GET_SCRIPT_STRING(*params[0]));
  58. return 1;
  59. }
  60. else if (dlfid == onmedialink_id)
  61. {
  62. hook_onMediaLink(GET_SCRIPT_STRING(*params[0]));
  63. return 1;
  64. }
  65. return 0;
  66. }
  67. int H_Browser::onbeforenavigate_id=0;
  68. int H_Browser::ondocumentcomplete_id=0;
  69. int H_Browser::onmedialink_id=0;
  70. int H_Browser::loaded=0;