123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- // Copyright (c) Microsoft Corporation. All rights reserved.
- // Licensed under the MIT License.
-
- #pragma once
- #include "winrt/Microsoft.ReactNative.h"
- #include "NativeModules.h"
-
- namespace winrt::ReactNativeWebView::implementation {
- class ReactWebViewManager : public winrt::implements<
- ReactWebViewManager,
- winrt::Microsoft::ReactNative::IViewManager,
- winrt::Microsoft::ReactNative::IViewManagerWithReactContext,
- winrt::Microsoft::ReactNative::IViewManagerWithNativeProperties,
- winrt::Microsoft::ReactNative::IViewManagerWithExportedEventTypeConstants,
- winrt::Microsoft::ReactNative::IViewManagerWithCommands> {
- public:
- ReactWebViewManager();
- // IViewManager
- winrt::hstring Name() noexcept;
- winrt::Windows::UI::Xaml::FrameworkElement CreateView() noexcept;
-
- // IViewManagerWithReactContext
- winrt::Microsoft::ReactNative::IReactContext ReactContext() noexcept;
- void ReactContext(winrt::Microsoft::ReactNative::IReactContext reactContext) noexcept;
-
- // IViewManagerWithNativeProperties
- winrt::Windows::Foundation::Collections::
- IMapView<winrt::hstring, winrt::Microsoft::ReactNative::ViewManagerPropertyType>
- NativeProps() noexcept;
-
- void UpdateProperties(
- winrt::Windows::UI::Xaml::FrameworkElement const& view,
- winrt::Microsoft::ReactNative::IJSValueReader const& propertyMapReader) noexcept;
-
- // IViewManagerWithExportedEventTypeConstants
- winrt::Microsoft::ReactNative::ConstantProvider ExportedCustomBubblingEventTypeConstants() noexcept;
- winrt::Microsoft::ReactNative::ConstantProvider ExportedCustomDirectEventTypeConstants() noexcept;
-
- // IViewManagerWithCommands
- winrt::Windows::Foundation::Collections::IMapView<winrt::hstring, int64_t> Commands() noexcept;
-
- void DispatchCommand(
- winrt::Windows::UI::Xaml::FrameworkElement const& view,
- int64_t commandId,
- winrt::Microsoft::ReactNative::IJSValueReader const& commandArgsReader) noexcept;
-
- private:
- winrt::weak_ref<winrt::Windows::UI::Xaml::Controls::WebView> m_webView;
- winrt::Microsoft::ReactNative::IReactContext m_reactContext{ nullptr };
- winrt::Windows::UI::Xaml::Controls::WebView::NavigationCompleted_revoker m_navigationCompletedRevoker{};
-
- void RegisterEvents();
- void SetSource(winrt::Windows::Foundation::Uri const& uri);
- void OnNavigationCompleted(winrt::Windows::UI::Xaml::Controls::WebView const& sender, winrt::Windows::UI::Xaml::Controls::WebViewNavigationCompletedEventArgs const& args);
- };
- } // namespace winrt::ReactWebView::implementation
|