Ei kuvausta

ReactWebView.h 2.2KB

123456789101112131415161718192021222324252627282930313233343536
  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. private:
  13. winrt::Windows::UI::Xaml::Controls::WebView m_webView{ nullptr };
  14. Microsoft::ReactNative::IReactContext m_reactContext{ nullptr };
  15. winrt::Windows::UI::Xaml::Controls::WebView::NavigationStarting_revoker m_navigationStartingRevoker{};
  16. winrt::Windows::UI::Xaml::Controls::WebView::NavigationCompleted_revoker m_navigationCompletedRevoker{};
  17. winrt::Windows::UI::Xaml::Controls::WebView::NavigationFailed_revoker m_navigationFailedRevoker{};
  18. winrt::Windows::UI::Xaml::Controls::WebView::ScriptNotify_revoker m_scriptNotifyRevoker{};
  19. void RegisterEvents();
  20. void WriteWebViewNavigationEventArg(winrt::Microsoft::ReactNative::IJSValueWriter const& eventDataWriter);
  21. void OnNavigationStarting(winrt::Windows::UI::Xaml::Controls::WebView const& sender, winrt::Windows::UI::Xaml::Controls::WebViewNavigationStartingEventArgs const& args);
  22. void OnNavigationCompleted(winrt::Windows::UI::Xaml::Controls::WebView const& sender, winrt::Windows::UI::Xaml::Controls::WebViewNavigationCompletedEventArgs const& args);
  23. void OnNavigationFailed(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::WebViewNavigationFailedEventArgs const& args);
  24. void OnScriptNotify(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::NotifyEventArgs const& args);
  25. };
  26. } // namespace winrt::ReactNativeWebView::implementation
  27. namespace winrt::ReactNativeWebView::factory_implementation {
  28. struct ReactWebView : ReactWebViewT<ReactWebView, implementation::ReactWebView> {};
  29. } // namespace winrt::ReactNativeWebView::factory_implementation