SCefBrowser.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // Copyright aXiuShen. All Rights Reserved.
  2. #pragma once
  3. #include "CoreMinimal.h"
  4. #include "Layout/Visibility.h"
  5. #include "Input/Reply.h"
  6. #include "Widgets/DeclarativeSyntaxSupport.h"
  7. #include "Widgets/SCompoundWidget.h"
  8. #include "Framework/SlateDelegates.h"
  9. #include "ImitateInput.h"
  10. #include "Styling/SlateTypes.h"
  11. #include "warp_macro.h"
  12. #include "BaseBrowser.h"
  13. class UWebCoreData;
  14. class CEFBROWSER_DLL SCefBrowser
  15. : public SBaseBrowser
  16. {
  17. public:
  18. BASEBROWSER_PARAMS(SCefBrowser)
  19. /**
  20. * Load the specified URL.
  21. * @param NewURL New URL to load.
  22. */
  23. virtual void LoadURL(FString NewURL, FString PostData = FString(), bool need_response=false) override;
  24. virtual void LoadString(FString DummyURL, FString Content) override;
  25. /**
  26. * reopen a new render to replace old render.
  27. * @param NewURL New URL to load.
  28. * if NewURL is empty,will Assign old URL.
  29. */
  30. virtual void ReopenRender(FString NewURL) override;
  31. /** Get the current title of the web page. */
  32. virtual FText GetTitleText() const override;
  33. /** Stop loading the page. */
  34. virtual void StopLoad() override;
  35. /** Reload the current page. */
  36. virtual void Reload() override;
  37. /** Reload the current page. */
  38. virtual bool Isloaded() override;
  39. /** Whether the document is currently being loaded. */
  40. virtual bool IsLoading() const override;
  41. /** Execute javascript on the current window */
  42. virtual void ExecuteJavascript(const FString& ScriptText) override;
  43. /** Returns true if the browser can navigate backwards. */
  44. virtual bool CanGoBack() const override;
  45. /** Returns true if the browser can navigate forwards. */
  46. virtual bool CanGoForward() const override;
  47. /** Navigate backwards. */
  48. virtual void GoBack()override;
  49. virtual bool CallJsonStr(const FString& Function, const FString& Data)override;
  50. virtual bool CallJson(const FString& Function, const FMatureJsonValue& Data)override;
  51. virtual void PopupURL(const FString& URL)override;
  52. /**
  53. * Gets the currently loaded URL.
  54. * @return The URL, or empty string if no document is loaded.
  55. */
  56. virtual FString GetUrl() const override;
  57. /** Navigate forwards. */
  58. virtual void GoForward()override;
  59. /** Set Page Zoom level */
  60. virtual void ZoomLevel(float zoomlevel)override;
  61. /** Set Page pixel */
  62. virtual void WebPixel(FIntPoint pixel)override;
  63. /** show or hide address bar */
  64. virtual void ShowAddress(bool isShow)override;
  65. /**
  66. * Expose a UObject instance to the browser runtime.
  67. * Properties and Functions will be accessible from JavaScript side.
  68. * As all communication with the rendering procesis asynchronous, return values (both for properties and function results) are wrapped into JS Future objects.
  69. * @param Name The name of the object. The object will show up as window.ue4.{Name} on the javascript side. If there is an existing object of the same name, this object will replace it. If bIsPermanent is false and there is an existing permanent binding, the permanent binding will be restored when the temporary one is removed.
  70. * @param Object The object instance.
  71. * @param bIsPermanent If true, the object will be visible to all pages loaded through this browser widget, otherwise, it will be deleted when navigating away from the current page. Non-permanent bindings should be registered from inside an OnLoadStarted event handler in order to be available before JS code starts loading.
  72. */
  73. virtual void BindUObject(const FString& Name, UObject* Object, bool bIsPermanent = true)override;
  74. /**
  75. * Remove an existing script binding registered by BindUObject.
  76. * @param Name The name of the object to remove.
  77. * @param Object The object will only be removed if it is the same object as the one passed in.
  78. * @param bIsPermanent Must match the bIsPermanent argument passed to BindUObject.
  79. */
  80. virtual void UnbindUObject(const FString& Name, UObject* Object, bool bIsPermanent = true)override;
  81. //
  82. virtual void StopRender(bool hidden)override;
  83. //
  84. virtual void ShowDevTools()override;
  85. //
  86. virtual void KeyboardMode(WebView_Keyboard_Mode)override;
  87. //
  88. virtual void Close()override;
  89. //
  90. virtual void Silent(bool onoff=true)override;
  91. //
  92. virtual void SetImitateInput(const FImitateInput& ImitateInput)override;
  93. //
  94. virtual void PenetrateThreshold(uint8_t value)override;
  95. public:
  96. /** Default constructor. */
  97. SCefBrowser();
  98. ~SCefBrowser();
  99. /**
  100. * Construct the widget.
  101. * @param InArgs Declaration from which to construct the widget.
  102. */
  103. void Construct(const FArguments& InArgs,const bool isFirst=true);
  104. private:
  105. //
  106. virtual void Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override;
  107. virtual void OnDragEnter(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override;
  108. virtual void OnDragLeave(const FDragDropEvent& DragDropEvent) override;
  109. virtual FReply OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override;
  110. virtual FReply OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent)override;
  111. private:
  112. TSharedPtr<UWebCoreData> _WebCoreData;
  113. };