Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
8#include "flutter/shell/platform/windows/platform_view_manager.h"
9
10#include <functional>
11#include <map>
12#include <optional>
13
14namespace 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_
void RegisterPlatformViewType(std::string_view type_name, const FlutterPlatformViewTypeEntry &type)
std::optional< HWND > GetNativeHandleForId(PlatformViewId id) const
bool FocusPlatformView(PlatformViewId id, FocusChangeDirection direction, bool focus) override
bool AddPlatformView(PlatformViewId id, std::string_view type_name) override
void InstantiatePlatformView(PlatformViewId id)
int64_t PlatformViewId