Flutter Windows Embedder
platform_view_plugin.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_PLATFORM_VIEW_PLUGIN_H_
6 #define FLUTTER_SHELL_PLATFORM_WINDOWS_PLATFORM_VIEW_PLUGIN_H_
7 
9 
10 #include <functional>
11 #include <map>
12 #include <optional>
13 
14 namespace flutter {
15 
16 // The concrete implementation of PlatformViewManager that keeps track of
17 // existing platform view types and instances, and handles their instantiation.
19  public:
20  PlatformViewPlugin(BinaryMessenger* messenger, TaskRunner* task_runner);
21 
23 
24  // Find the HWND corresponding to a platform view id. Returns null if the id
25  // has no associated platform view.
26  std::optional<HWND> GetNativeHandleForId(PlatformViewId id) const;
27 
28  // The runner-facing API calls this method to register a window type
29  // corresponding to a platform view identifier supplied to the widget tree.
30  void RegisterPlatformViewType(std::string_view type_name,
32 
33  // | PlatformViewManager |
34  // type_name must correspond to a string that has already been registered
35  // with RegisterPlatformViewType.
36  bool AddPlatformView(PlatformViewId id, std::string_view type_name) override;
37 
38  // Create a queued platform view instance after it has been added.
39  // id must correspond to an identifier that has already been added with
40  // AddPlatformView.
41  // This method will create the platform view within a task queued to the
42  // engine's TaskRunner, which will run on the UI thread.
44 
45  // | PlatformViewManager |
46  // id must correspond to an identifier that has already been added with
47  // AddPlatformView.
49  FocusChangeDirection direction,
50  bool focus) override;
51 
52  private:
53  std::unordered_map<std::string, FlutterPlatformViewTypeEntry>
54  platform_view_types_;
55 
56  std::unordered_map<PlatformViewId, HWND> platform_views_;
57 
58  std::unordered_map<PlatformViewId, std::function<HWND()>>
59  pending_platform_views_;
60 
61  // Pointer to the task runner of the associated engine.
62  TaskRunner* task_runner_;
63 };
64 
65 } // namespace flutter
66 
67 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_PLATFORM_VIEW_PLUGIN_H_
flutter::PlatformViewPlugin::RegisterPlatformViewType
void RegisterPlatformViewType(std::string_view type_name, const FlutterPlatformViewTypeEntry &type)
Definition: platform_view_plugin.cc:24
flutter::PlatformViewPlugin::AddPlatformView
bool AddPlatformView(PlatformViewId id, std::string_view type_name) override
Definition: platform_view_plugin.cc:34
flutter::PlatformViewPlugin
Definition: platform_view_plugin.h:18
PlatformViewId
int64_t PlatformViewId
Definition: flutter_windows_internal.h:42
flutter::PlatformViewPlugin::GetNativeHandleForId
std::optional< HWND > GetNativeHandleForId(PlatformViewId id) const
Definition: platform_view_plugin.cc:17
platform_view_manager.h
flutter::PlatformViewPlugin::~PlatformViewPlugin
~PlatformViewPlugin()
Definition: platform_view_plugin.cc:13
flutter::BinaryMessenger
Definition: binary_messenger.h:28
FlutterPlatformViewTypeEntry
Definition: flutter_windows_internal.h:57
flutter::PlatformViewPlugin::FocusPlatformView
bool FocusPlatformView(PlatformViewId id, FocusChangeDirection direction, bool focus) override
Definition: platform_view_plugin.cc:41
flutter::PlatformViewPlugin::InstantiatePlatformView
void InstantiatePlatformView(PlatformViewId id)
Definition: platform_view_plugin.cc:30
flutter::FocusChangeDirection
FocusChangeDirection
Definition: platform_view_manager.h:17
flutter
Definition: accessibility_bridge_windows.cc:11
flutter::TaskRunner
Definition: task_runner.h:26
type
enum flutter::testing::@88::KeyboardChange::Type type
flutter::PlatformViewPlugin::PlatformViewPlugin
PlatformViewPlugin(BinaryMessenger *messenger, TaskRunner *task_runner)
Definition: platform_view_plugin.cc:9
flutter::PlatformViewManager
Definition: platform_view_manager.h:27