Няма описание

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (c) Microsoft Corporation. All rights reserved.
  2. // Licensed under the MIT License.
  3. #pragma once
  4. #include "winrt/Microsoft.ReactNative.h"
  5. #include "NativeModules.h"
  6. #include "ReactWebView.g.h"
  7. namespace winrt::ReactNativeWebView::implementation {
  8. class ReactWebView : public ReactWebViewT<ReactWebView> {
  9. public:
  10. ReactWebView(Microsoft::ReactNative::IReactContext const& reactContext);
  11. winrt::Windows::UI::Xaml::Controls::WebView GetView();
  12. void PostMessage(winrt::hstring const& message);
  13. private:
  14. winrt::Windows::UI::Xaml::Controls::WebView m_webView{ nullptr };
  15. Microsoft::ReactNative::IReactContext m_reactContext{ nullptr };
  16. winrt::Windows::UI::Xaml::Controls::WebView::NavigationStarting_revoker m_navigationStartingRevoker{};
  17. winrt::Windows::UI::Xaml::Controls::WebView::NavigationCompleted_revoker m_navigationCompletedRevoker{};
  18. winrt::Windows::UI::Xaml::Controls::WebView::NavigationFailed_revoker m_navigationFailedRevoker{};
  19. winrt::Windows::UI::Xaml::Controls::WebView::ScriptNotify_revoker m_scriptNotifyRevoker{};
  20. winrt::Windows::UI::Xaml::Controls::WebView::PermissionRequested_revoker m_permissionReguestRevoker{};
  21. void RegisterEvents();
  22. void WriteWebViewNavigationEventArg(winrt::Microsoft::ReactNative::IJSValueWriter const& eventDataWriter);
  23. void OnNavigationStarting(winrt::Windows::UI::Xaml::Controls::WebView const& sender, winrt::Windows::UI::Xaml::Controls::WebViewNavigationStartingEventArgs const& args);
  24. void OnNavigationCompleted(winrt::Windows::UI::Xaml::Controls::WebView const& sender, winrt::Windows::UI::Xaml::Controls::WebViewNavigationCompletedEventArgs const& args);
  25. void OnNavigationFailed(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::WebViewNavigationFailedEventArgs const& args);
  26. void OnScriptNotify(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::NotifyEventArgs const& args);
  27. void OnPremissionRequested(winrt::Windows::UI::Xaml::Controls::WebView const& webView, winrt::Windows::UI::Xaml::Controls::WebViewPermissionRequestedEventArgs const& args);
  28. };
  29. } // namespace winrt::ReactNativeWebView::implementation
  30. namespace winrt::ReactNativeWebView::factory_implementation {
  31. struct ReactWebView : ReactWebViewT<ReactWebView, implementation::ReactWebView> {};
  32. } // namespace winrt::ReactNativeWebView::factory_implementation