From a9edfd88e1b479c3cbf37c5a1987b4e3b4f81da1 Mon Sep 17 00:00:00 2001 From: schectman Date: Thu, 4 May 2023 10:35:52 -0400 Subject: [PATCH 01/21] Listen for binding register --- .../windows/flutter_windows_engine.cc | 25 +++++++++++-------- .../platform/windows/flutter_windows_engine.h | 4 +++ .../flutter_windows_engine_unittests.cc | 4 +++ shell/platform/windows/platform_handler.cc | 4 +++ 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/shell/platform/windows/flutter_windows_engine.cc b/shell/platform/windows/flutter_windows_engine.cc index 39dbe8ea6be05..8f8b7ae6960e7 100644 --- a/shell/platform/windows/flutter_windows_engine.cc +++ b/shell/platform/windows/flutter_windows_engine.cc @@ -204,17 +204,6 @@ FlutterWindowsEngine::FlutterWindowsEngine( std::make_unique(this, gl_procs_); surface_manager_ = AngleSurfaceManager::Create(); window_proc_delegate_manager_ = std::make_unique(); - window_proc_delegate_manager_->RegisterTopLevelWindowProcDelegate( - [](HWND hwnd, UINT msg, WPARAM wpar, LPARAM lpar, void* user_data, - LRESULT* result) { - BASE_DCHECK(user_data); - FlutterWindowsEngine* that = - static_cast(user_data); - BASE_DCHECK(that->lifecycle_manager_); - return that->lifecycle_manager_->WindowProc(hwnd, msg, wpar, lpar, - result); - }, - static_cast(this)); // Set up internal channels. // TODO: Replace this with an embedder.h API. See @@ -778,4 +767,18 @@ void FlutterWindowsEngine::OnDwmCompositionChanged() { view_->OnDwmCompositionChanged(); } +void FlutterWindowsEngine::OnServiceBindingsRegistered() { + window_proc_delegate_manager_->RegisterTopLevelWindowProcDelegate( + [](HWND hwnd, UINT msg, WPARAM wpar, LPARAM lpar, void* user_data, + LRESULT* result) { + BASE_DCHECK(user_data); + FlutterWindowsEngine* that = + static_cast(user_data); + BASE_DCHECK(that->lifecycle_manager_); + return that->lifecycle_manager_->WindowProc(hwnd, msg, wpar, lpar, + result); + }, + static_cast(this)); +} + } // namespace flutter diff --git a/shell/platform/windows/flutter_windows_engine.h b/shell/platform/windows/flutter_windows_engine.h index 797cc2142da3c..2e903e0ad0f08 100644 --- a/shell/platform/windows/flutter_windows_engine.h +++ b/shell/platform/windows/flutter_windows_engine.h @@ -269,6 +269,10 @@ class FlutterWindowsEngine { // Called when a WM_DWMCOMPOSITIONCHANGED message is received. void OnDwmCompositionChanged(); + // Called in response to the framework registering a ServiceBindings. + // Registers the top level handler for the WM_CLOSE window message. + void OnServiceBindingsRegistered(); + protected: // Creates the keyboard key handler. // diff --git a/shell/platform/windows/flutter_windows_engine_unittests.cc b/shell/platform/windows/flutter_windows_engine_unittests.cc index 161181cd11fda..e33fff7f9b9dc 100644 --- a/shell/platform/windows/flutter_windows_engine_unittests.cc +++ b/shell/platform/windows/flutter_windows_engine_unittests.cc @@ -645,6 +645,7 @@ TEST_F(FlutterWindowsEngineTest, TestExit) { MockFlutterWindowsView view(std::move(window_binding_handler)); view.SetEngine(builder.Build()); FlutterWindowsEngine* engine = view.GetEngine(); + engine->OnServiceBindingsRegistered(); EngineModifier modifier(engine); modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; }; @@ -681,6 +682,7 @@ TEST_F(FlutterWindowsEngineTest, TestExitCancel) { MockFlutterWindowsView view(std::move(window_binding_handler)); view.SetEngine(builder.Build()); FlutterWindowsEngine* engine = view.GetEngine(); + engine->OnServiceBindingsRegistered(); EngineModifier modifier(engine); modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; }; @@ -731,6 +733,7 @@ TEST_F(FlutterWindowsEngineTest, TestExitSecondCloseMessage) { MockFlutterWindowsView view(std::move(window_binding_handler)); view.SetEngine(builder.Build()); FlutterWindowsEngine* engine = view.GetEngine(); + engine->OnServiceBindingsRegistered(); EngineModifier modifier(engine); modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; }; @@ -792,6 +795,7 @@ TEST_F(FlutterWindowsEngineTest, TestExitCloseMultiWindow) { MockFlutterWindowsView view(std::move(window_binding_handler)); view.SetEngine(builder.Build()); FlutterWindowsEngine* engine = view.GetEngine(); + engine->OnServiceBindingsRegistered(); EngineModifier modifier(engine); modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; }; diff --git a/shell/platform/windows/platform_handler.cc b/shell/platform/windows/platform_handler.cc index ab9a79a6a0390..7847f135834b8 100644 --- a/shell/platform/windows/platform_handler.cc +++ b/shell/platform/windows/platform_handler.cc @@ -24,6 +24,7 @@ static constexpr char kSetClipboardDataMethod[] = "Clipboard.setData"; static constexpr char kExitApplicationMethod[] = "System.exitApplication"; static constexpr char kRequestAppExitMethod[] = "System.requestAppExit"; static constexpr char kPlaySoundMethod[] = "SystemSound.play"; +static constexpr char kRegisterBinding[] = "System.registerBinding"; static constexpr char kExitCodeKey[] = "exitCode"; @@ -495,6 +496,9 @@ void PlatformHandler::HandleMethodCall( const rapidjson::Value& sound_type = method_call.arguments()[0]; SystemSoundPlay(sound_type.GetString(), std::move(result)); + } else if (method.compare(kRegisterBinding) == 0) { + engine_->OnServiceBindingsRegistered(); + result->Success(); } else { result->NotImplemented(); } From 248630acec01bb21662fb2646792ea8413b18a6f Mon Sep 17 00:00:00 2001 From: schectman Date: Thu, 4 May 2023 10:41:17 -0400 Subject: [PATCH 02/21] Consume message on mac, linux --- shell/platform/darwin/macos/framework/Source/FlutterEngine.mm | 2 ++ shell/platform/linux/fl_platform_plugin.cc | 3 +++ shell/platform/windows/platform_handler.cc | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index 3d3c60b69ff45..e5e42d73a877f 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -1031,6 +1031,8 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { result(@{@"value" : @([self clipboardHasStrings])}); } else if ([call.method isEqualToString:@"System.exitApplication"]) { [[self terminationHandler] handleRequestAppExitMethodCall:call.arguments result:result]; + } else if ([call.method isEqualToString:@"System.registerBinding"]) { + result(nil); } else { result(FlutterMethodNotImplemented); } diff --git a/shell/platform/linux/fl_platform_plugin.cc b/shell/platform/linux/fl_platform_plugin.cc index 2a2065bbb3a8a..402c9980f5ffe 100644 --- a/shell/platform/linux/fl_platform_plugin.cc +++ b/shell/platform/linux/fl_platform_plugin.cc @@ -20,6 +20,7 @@ static constexpr char kSetClipboardDataMethod[] = "Clipboard.setData"; static constexpr char kClipboardHasStringsMethod[] = "Clipboard.hasStrings"; static constexpr char kExitApplicationMethod[] = "System.exitApplication"; static constexpr char kRequestAppExitMethod[] = "System.requestAppExit"; +static constexpr char kRegisterBindingMethod[] = "System.registerBinding"; static constexpr char kPlaySoundMethod[] = "SystemSound.play"; static constexpr char kSystemNavigatorPopMethod[] = "SystemNavigator.pop"; static constexpr char kTextKey[] = "text"; @@ -335,6 +336,8 @@ static void method_call_cb(FlMethodChannel* channel, response = system_sound_play(self, args); } else if (strcmp(method, kSystemNavigatorPopMethod) == 0) { response = system_navigator_pop(self); + } else if () { + response = FL_METHOD_RESPONSE(fl_method_success_respons_new(fl_value_new_null())); } else { response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new()); } diff --git a/shell/platform/windows/platform_handler.cc b/shell/platform/windows/platform_handler.cc index 7847f135834b8..41a627c9223c8 100644 --- a/shell/platform/windows/platform_handler.cc +++ b/shell/platform/windows/platform_handler.cc @@ -23,8 +23,8 @@ static constexpr char kHasStringsClipboardMethod[] = "Clipboard.hasStrings"; static constexpr char kSetClipboardDataMethod[] = "Clipboard.setData"; static constexpr char kExitApplicationMethod[] = "System.exitApplication"; static constexpr char kRequestAppExitMethod[] = "System.requestAppExit"; +static constexpr char kRegisterBindingMethod[] = "System.registerBinding"; static constexpr char kPlaySoundMethod[] = "SystemSound.play"; -static constexpr char kRegisterBinding[] = "System.registerBinding"; static constexpr char kExitCodeKey[] = "exitCode"; @@ -496,7 +496,7 @@ void PlatformHandler::HandleMethodCall( const rapidjson::Value& sound_type = method_call.arguments()[0]; SystemSoundPlay(sound_type.GetString(), std::move(result)); - } else if (method.compare(kRegisterBinding) == 0) { + } else if (method.compare(kRegisterBindingMethod) == 0) { engine_->OnServiceBindingsRegistered(); result->Success(); } else { From 4f72ae45fd19d1a0c7425066bfda8b66b1a6dd37 Mon Sep 17 00:00:00 2001 From: schectman Date: Thu, 4 May 2023 12:30:05 -0400 Subject: [PATCH 03/21] Fix typo --- shell/platform/linux/fl_platform_plugin.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/linux/fl_platform_plugin.cc b/shell/platform/linux/fl_platform_plugin.cc index 402c9980f5ffe..7b768e266b09e 100644 --- a/shell/platform/linux/fl_platform_plugin.cc +++ b/shell/platform/linux/fl_platform_plugin.cc @@ -337,7 +337,7 @@ static void method_call_cb(FlMethodChannel* channel, } else if (strcmp(method, kSystemNavigatorPopMethod) == 0) { response = system_navigator_pop(self); } else if () { - response = FL_METHOD_RESPONSE(fl_method_success_respons_new(fl_value_new_null())); + response = FL_METHOD_RESPONSE(fl_method_success_response_new(fl_value_new_null())); } else { response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new()); } From d27058ced07f4fd2adb4c5d46d279eb8af780665 Mon Sep 17 00:00:00 2001 From: schectman Date: Thu, 4 May 2023 12:39:39 -0400 Subject: [PATCH 04/21] Fix typo --- shell/platform/linux/fl_platform_plugin.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/linux/fl_platform_plugin.cc b/shell/platform/linux/fl_platform_plugin.cc index 7b768e266b09e..0dc66421edf3a 100644 --- a/shell/platform/linux/fl_platform_plugin.cc +++ b/shell/platform/linux/fl_platform_plugin.cc @@ -336,7 +336,7 @@ static void method_call_cb(FlMethodChannel* channel, response = system_sound_play(self, args); } else if (strcmp(method, kSystemNavigatorPopMethod) == 0) { response = system_navigator_pop(self); - } else if () { + } else if (strcmp(method, kRegisterBindingMethod) == 0) { response = FL_METHOD_RESPONSE(fl_method_success_response_new(fl_value_new_null())); } else { response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new()); From 38073625fc94b1729f0875cddeacdc0842cc2a9c Mon Sep 17 00:00:00 2001 From: schectman Date: Thu, 4 May 2023 12:51:10 -0400 Subject: [PATCH 05/21] Test service binding registration --- .../flutter_windows_engine_unittests.cc | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/shell/platform/windows/flutter_windows_engine_unittests.cc b/shell/platform/windows/flutter_windows_engine_unittests.cc index e33fff7f9b9dc..bdceb7a9e2308 100644 --- a/shell/platform/windows/flutter_windows_engine_unittests.cc +++ b/shell/platform/windows/flutter_windows_engine_unittests.cc @@ -818,5 +818,52 @@ TEST_F(FlutterWindowsEngineTest, TestExitCloseMultiWindow) { } } +TEST_F(FlutterWindowsEngineTest, DoNotRegisterTopLevelHandler) { + FlutterWindowsEngineBuilder builder{GetContext()}; + + auto window_binding_handler = + std::make_unique<::testing::NiceMock>(); + MockFlutterWindowsView view(std::move(window_binding_handler)); + view.SetEngine(builder.Build()); + FlutterWindowsEngine* engine = view.GetEngine(); + + EngineModifier modifier(engine); + modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; }; + auto handler = std::make_unique(engine); + ON_CALL(*handler, IsLastWindowOfProcess).WillByDefault([]() { + return false; + }); + // Quit should not be called when there is more than one window. + EXPECT_CALL(*handler, IsLastWindowOfProcess).Times(0); + modifier.SetLifecycleManager(std::move(handler)); + + engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0, + 0); +} + +TEST_F(FlutterWindowsEngineTest, RegisterTopLevelHandler) { + FlutterWindowsEngineBuilder builder{GetContext()}; + + auto window_binding_handler = + std::make_unique<::testing::NiceMock>(); + MockFlutterWindowsView view(std::move(window_binding_handler)); + view.SetEngine(builder.Build()); + FlutterWindowsEngine* engine = view.GetEngine(); + engine->OnServiceBindingsRegistered(); + + EngineModifier modifier(engine); + modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; }; + auto handler = std::make_unique(engine); + ON_CALL(*handler, IsLastWindowOfProcess).WillByDefault([]() { + return false; + }); + // Quit should not be called when there is more than one window. + EXPECT_CALL(*handler, IsLastWindowOfProcess).Times(1); + modifier.SetLifecycleManager(std::move(handler)); + + engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0, + 0); +} + } // namespace testing } // namespace flutter From 952520b5823b7f0235418e7c67ff1b32d06cd673 Mon Sep 17 00:00:00 2001 From: schectman Date: Thu, 4 May 2023 12:59:23 -0400 Subject: [PATCH 06/21] Formatting --- shell/platform/linux/fl_platform_plugin.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell/platform/linux/fl_platform_plugin.cc b/shell/platform/linux/fl_platform_plugin.cc index 0dc66421edf3a..04c289a48c819 100644 --- a/shell/platform/linux/fl_platform_plugin.cc +++ b/shell/platform/linux/fl_platform_plugin.cc @@ -337,7 +337,8 @@ static void method_call_cb(FlMethodChannel* channel, } else if (strcmp(method, kSystemNavigatorPopMethod) == 0) { response = system_navigator_pop(self); } else if (strcmp(method, kRegisterBindingMethod) == 0) { - response = FL_METHOD_RESPONSE(fl_method_success_response_new(fl_value_new_null())); + response = + FL_METHOD_RESPONSE(fl_method_success_response_new(fl_value_new_null())); } else { response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new()); } From 7dc998ded03a0145a831bca53e8c969c6f984ce0 Mon Sep 17 00:00:00 2001 From: schectman Date: Thu, 4 May 2023 13:25:10 -0400 Subject: [PATCH 07/21] Comments --- shell/platform/windows/flutter_windows_engine_unittests.cc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/shell/platform/windows/flutter_windows_engine_unittests.cc b/shell/platform/windows/flutter_windows_engine_unittests.cc index bdceb7a9e2308..2471a04ce98c8 100644 --- a/shell/platform/windows/flutter_windows_engine_unittests.cc +++ b/shell/platform/windows/flutter_windows_engine_unittests.cc @@ -830,10 +830,6 @@ TEST_F(FlutterWindowsEngineTest, DoNotRegisterTopLevelHandler) { EngineModifier modifier(engine); modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; }; auto handler = std::make_unique(engine); - ON_CALL(*handler, IsLastWindowOfProcess).WillByDefault([]() { - return false; - }); - // Quit should not be called when there is more than one window. EXPECT_CALL(*handler, IsLastWindowOfProcess).Times(0); modifier.SetLifecycleManager(std::move(handler)); @@ -857,7 +853,6 @@ TEST_F(FlutterWindowsEngineTest, RegisterTopLevelHandler) { ON_CALL(*handler, IsLastWindowOfProcess).WillByDefault([]() { return false; }); - // Quit should not be called when there is more than one window. EXPECT_CALL(*handler, IsLastWindowOfProcess).Times(1); modifier.SetLifecycleManager(std::move(handler)); From 559ab7bb5311ba5c6a7202948dadbfbc7d666a21 Mon Sep 17 00:00:00 2001 From: schectman Date: Thu, 4 May 2023 13:32:44 -0400 Subject: [PATCH 08/21] Gate WM_CLOSE consumption --- .../windows/flutter_windows_engine.cc | 23 ++++++++++--------- .../flutter_windows_engine_unittests.cc | 10 ++++---- .../windows/windows_lifecycle_manager.cc | 9 +++++++- .../windows/windows_lifecycle_manager.h | 5 ++++ 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/shell/platform/windows/flutter_windows_engine.cc b/shell/platform/windows/flutter_windows_engine.cc index 8f8b7ae6960e7..aaeef9386711c 100644 --- a/shell/platform/windows/flutter_windows_engine.cc +++ b/shell/platform/windows/flutter_windows_engine.cc @@ -204,6 +204,17 @@ FlutterWindowsEngine::FlutterWindowsEngine( std::make_unique(this, gl_procs_); surface_manager_ = AngleSurfaceManager::Create(); window_proc_delegate_manager_ = std::make_unique(); + window_proc_delegate_manager_->RegisterTopLevelWindowProcDelegate( + [](HWND hwnd, UINT msg, WPARAM wpar, LPARAM lpar, void* user_data, + LRESULT* result) { + BASE_DCHECK(user_data); + FlutterWindowsEngine* that = + static_cast(user_data); + BASE_DCHECK(that->lifecycle_manager_); + return that->lifecycle_manager_->WindowProc(hwnd, msg, wpar, lpar, + result); + }, + static_cast(this)); // Set up internal channels. // TODO: Replace this with an embedder.h API. See @@ -768,17 +779,7 @@ void FlutterWindowsEngine::OnDwmCompositionChanged() { } void FlutterWindowsEngine::OnServiceBindingsRegistered() { - window_proc_delegate_manager_->RegisterTopLevelWindowProcDelegate( - [](HWND hwnd, UINT msg, WPARAM wpar, LPARAM lpar, void* user_data, - LRESULT* result) { - BASE_DCHECK(user_data); - FlutterWindowsEngine* that = - static_cast(user_data); - BASE_DCHECK(that->lifecycle_manager_); - return that->lifecycle_manager_->WindowProc(hwnd, msg, wpar, lpar, - result); - }, - static_cast(this)); + lifecycle_manager_->BeginProcessingClose(); } } // namespace flutter diff --git a/shell/platform/windows/flutter_windows_engine_unittests.cc b/shell/platform/windows/flutter_windows_engine_unittests.cc index 2471a04ce98c8..91ba099993d98 100644 --- a/shell/platform/windows/flutter_windows_engine_unittests.cc +++ b/shell/platform/windows/flutter_windows_engine_unittests.cc @@ -645,7 +645,6 @@ TEST_F(FlutterWindowsEngineTest, TestExit) { MockFlutterWindowsView view(std::move(window_binding_handler)); view.SetEngine(builder.Build()); FlutterWindowsEngine* engine = view.GetEngine(); - engine->OnServiceBindingsRegistered(); EngineModifier modifier(engine); modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; }; @@ -658,6 +657,7 @@ TEST_F(FlutterWindowsEngineTest, TestExit) { ON_CALL(*handler, IsLastWindowOfProcess).WillByDefault([]() { return true; }); EXPECT_CALL(*handler, Quit).Times(1); modifier.SetLifecycleManager(std::move(handler)); + engine->OnServiceBindingsRegistered(); engine->Run(); @@ -682,7 +682,6 @@ TEST_F(FlutterWindowsEngineTest, TestExitCancel) { MockFlutterWindowsView view(std::move(window_binding_handler)); view.SetEngine(builder.Build()); FlutterWindowsEngine* engine = view.GetEngine(); - engine->OnServiceBindingsRegistered(); EngineModifier modifier(engine); modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; }; @@ -695,6 +694,7 @@ TEST_F(FlutterWindowsEngineTest, TestExitCancel) { ON_CALL(*handler, IsLastWindowOfProcess).WillByDefault([]() { return true; }); EXPECT_CALL(*handler, Quit).Times(0); modifier.SetLifecycleManager(std::move(handler)); + engine->OnServiceBindingsRegistered(); auto binary_messenger = std::make_unique(engine->messenger()); @@ -733,7 +733,6 @@ TEST_F(FlutterWindowsEngineTest, TestExitSecondCloseMessage) { MockFlutterWindowsView view(std::move(window_binding_handler)); view.SetEngine(builder.Build()); FlutterWindowsEngine* engine = view.GetEngine(); - engine->OnServiceBindingsRegistered(); EngineModifier modifier(engine); modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; }; @@ -756,6 +755,7 @@ TEST_F(FlutterWindowsEngineTest, TestExitSecondCloseMessage) { hwnd, msg, wparam, lparam); }); modifier.SetLifecycleManager(std::move(handler)); + engine->OnServiceBindingsRegistered(); engine->Run(); @@ -795,7 +795,6 @@ TEST_F(FlutterWindowsEngineTest, TestExitCloseMultiWindow) { MockFlutterWindowsView view(std::move(window_binding_handler)); view.SetEngine(builder.Build()); FlutterWindowsEngine* engine = view.GetEngine(); - engine->OnServiceBindingsRegistered(); EngineModifier modifier(engine); modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; }; @@ -807,6 +806,7 @@ TEST_F(FlutterWindowsEngineTest, TestExitCloseMultiWindow) { // Quit should not be called when there is more than one window. EXPECT_CALL(*handler, Quit).Times(0); modifier.SetLifecycleManager(std::move(handler)); + engine->OnServiceBindingsRegistered(); engine->Run(); @@ -845,7 +845,6 @@ TEST_F(FlutterWindowsEngineTest, RegisterTopLevelHandler) { MockFlutterWindowsView view(std::move(window_binding_handler)); view.SetEngine(builder.Build()); FlutterWindowsEngine* engine = view.GetEngine(); - engine->OnServiceBindingsRegistered(); EngineModifier modifier(engine); modifier.embedder_api().RunsAOTCompiledDartCode = []() { return false; }; @@ -855,6 +854,7 @@ TEST_F(FlutterWindowsEngineTest, RegisterTopLevelHandler) { }); EXPECT_CALL(*handler, IsLastWindowOfProcess).Times(1); modifier.SetLifecycleManager(std::move(handler)); + engine->OnServiceBindingsRegistered(); engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0, 0); diff --git a/shell/platform/windows/windows_lifecycle_manager.cc b/shell/platform/windows/windows_lifecycle_manager.cc index c7c46fa1e9c1c..f8bf5de37f7bf 100644 --- a/shell/platform/windows/windows_lifecycle_manager.cc +++ b/shell/platform/windows/windows_lifecycle_manager.cc @@ -14,7 +14,7 @@ namespace flutter { WindowsLifecycleManager::WindowsLifecycleManager(FlutterWindowsEngine* engine) - : engine_(engine) {} + : engine_(engine), process_close_(false) {} WindowsLifecycleManager::~WindowsLifecycleManager() {} @@ -49,6 +49,9 @@ bool WindowsLifecycleManager::WindowProc(HWND hwnd, // is, we re-dispatch a new WM_CLOSE message. In order to allow the new // message to reach other delegates, we ignore it here. case WM_CLOSE: { + if (!process_close_) { + return false; + } auto key = std::make_tuple(hwnd, wpar, lpar); auto itr = sent_close_messages_.find(key); if (itr != sent_close_messages_.end()) { @@ -156,4 +159,8 @@ bool WindowsLifecycleManager::IsLastWindowOfProcess() { return num_windows <= 1; } +void WindowsLifecycleManager::BeginProcessingClose() { + process_close_ = true; +} + } // namespace flutter diff --git a/shell/platform/windows/windows_lifecycle_manager.h b/shell/platform/windows/windows_lifecycle_manager.h index e1d1f604c4a3d..b08ec57a4dbd8 100644 --- a/shell/platform/windows/windows_lifecycle_manager.h +++ b/shell/platform/windows/windows_lifecycle_manager.h @@ -37,6 +37,9 @@ class WindowsLifecycleManager { // Intercept top level window messages, only paying attention to WM_CLOSE. bool WindowProc(HWND hwnd, UINT msg, WPARAM w, LPARAM l, LRESULT* result); + // Signal to start consuming WM_CLOSE messages. + void BeginProcessingClose(); + protected: // Check the number of top-level windows associated with this process, and // return true only if there are 1 or fewer. @@ -51,6 +54,8 @@ class WindowsLifecycleManager { FlutterWindowsEngine* engine_; std::map, int> sent_close_messages_; + + bool process_close_; }; } // namespace flutter From 748c3e52dcc8217177ca4c0c441f28859b680e15 Mon Sep 17 00:00:00 2001 From: schectman Date: Thu, 4 May 2023 15:21:33 -0400 Subject: [PATCH 09/21] Rename message --- shell/platform/darwin/macos/framework/Source/FlutterEngine.mm | 2 +- shell/platform/linux/fl_platform_plugin.cc | 2 +- shell/platform/windows/platform_handler.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index e5e42d73a877f..fd3c379d2da5e 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -1031,7 +1031,7 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { result(@{@"value" : @([self clipboardHasStrings])}); } else if ([call.method isEqualToString:@"System.exitApplication"]) { [[self terminationHandler] handleRequestAppExitMethodCall:call.arguments result:result]; - } else if ([call.method isEqualToString:@"System.registerBinding"]) { + } else if ([call.method isEqualToString:@"System.enableApplicationLifecycle"]) { result(nil); } else { result(FlutterMethodNotImplemented); diff --git a/shell/platform/linux/fl_platform_plugin.cc b/shell/platform/linux/fl_platform_plugin.cc index 04c289a48c819..ee76a439c75a4 100644 --- a/shell/platform/linux/fl_platform_plugin.cc +++ b/shell/platform/linux/fl_platform_plugin.cc @@ -20,7 +20,7 @@ static constexpr char kSetClipboardDataMethod[] = "Clipboard.setData"; static constexpr char kClipboardHasStringsMethod[] = "Clipboard.hasStrings"; static constexpr char kExitApplicationMethod[] = "System.exitApplication"; static constexpr char kRequestAppExitMethod[] = "System.requestAppExit"; -static constexpr char kRegisterBindingMethod[] = "System.registerBinding"; +static constexpr char kRegisterBindingMethod[] = "System.enableApplicationLifecycle"; static constexpr char kPlaySoundMethod[] = "SystemSound.play"; static constexpr char kSystemNavigatorPopMethod[] = "SystemNavigator.pop"; static constexpr char kTextKey[] = "text"; diff --git a/shell/platform/windows/platform_handler.cc b/shell/platform/windows/platform_handler.cc index 41a627c9223c8..949ebcc0eec62 100644 --- a/shell/platform/windows/platform_handler.cc +++ b/shell/platform/windows/platform_handler.cc @@ -23,7 +23,7 @@ static constexpr char kHasStringsClipboardMethod[] = "Clipboard.hasStrings"; static constexpr char kSetClipboardDataMethod[] = "Clipboard.setData"; static constexpr char kExitApplicationMethod[] = "System.exitApplication"; static constexpr char kRequestAppExitMethod[] = "System.requestAppExit"; -static constexpr char kRegisterBindingMethod[] = "System.registerBinding"; +static constexpr char kRegisterBindingMethod[] = "System.enableApplicationLifecycle"; static constexpr char kPlaySoundMethod[] = "SystemSound.play"; static constexpr char kExitCodeKey[] = "exitCode"; From 2a7e68f8ece5aee045ed8dd122b72fd2bda61126 Mon Sep 17 00:00:00 2001 From: yaakovschectman <109111084+yaakovschectman@users.noreply.github.com> Date: Thu, 4 May 2023 15:21:52 -0400 Subject: [PATCH 10/21] Update shell/platform/windows/flutter_windows_engine_unittests.cc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Loïc Sharma <737941+loic-sharma@users.noreply.github.com> --- shell/platform/windows/flutter_windows_engine_unittests.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/windows/flutter_windows_engine_unittests.cc b/shell/platform/windows/flutter_windows_engine_unittests.cc index 91ba099993d98..d6e28d44d6259 100644 --- a/shell/platform/windows/flutter_windows_engine_unittests.cc +++ b/shell/platform/windows/flutter_windows_engine_unittests.cc @@ -818,7 +818,7 @@ TEST_F(FlutterWindowsEngineTest, TestExitCloseMultiWindow) { } } -TEST_F(FlutterWindowsEngineTest, DoNotRegisterTopLevelHandler) { +TEST_F(FlutterWindowsEngineTest, LifecycleManagerDisabledByDefault) { FlutterWindowsEngineBuilder builder{GetContext()}; auto window_binding_handler = From ecadae4e81eaa73b320f69b7ce5a5b79a7416e25 Mon Sep 17 00:00:00 2001 From: yaakovschectman <109111084+yaakovschectman@users.noreply.github.com> Date: Thu, 4 May 2023 15:21:58 -0400 Subject: [PATCH 11/21] Update shell/platform/windows/flutter_windows_engine_unittests.cc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Loïc Sharma <737941+loic-sharma@users.noreply.github.com> --- shell/platform/windows/flutter_windows_engine_unittests.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/windows/flutter_windows_engine_unittests.cc b/shell/platform/windows/flutter_windows_engine_unittests.cc index d6e28d44d6259..82632c5433786 100644 --- a/shell/platform/windows/flutter_windows_engine_unittests.cc +++ b/shell/platform/windows/flutter_windows_engine_unittests.cc @@ -837,7 +837,7 @@ TEST_F(FlutterWindowsEngineTest, LifecycleManagerDisabledByDefault) { 0); } -TEST_F(FlutterWindowsEngineTest, RegisterTopLevelHandler) { +TEST_F(FlutterWindowsEngineTest, EnableApplicationLifecycle) { FlutterWindowsEngineBuilder builder{GetContext()}; auto window_binding_handler = From 24a37cc3ffcc878ab3ee33de7031d38c2d647a27 Mon Sep 17 00:00:00 2001 From: schectman Date: Thu, 4 May 2023 17:01:43 -0400 Subject: [PATCH 12/21] Feedback --- shell/platform/linux/fl_platform_plugin.cc | 3 ++- shell/platform/windows/flutter_windows_engine.cc | 2 +- shell/platform/windows/flutter_windows_engine.h | 2 +- .../windows/flutter_windows_engine_unittests.cc | 10 +++++----- shell/platform/windows/platform_handler.cc | 5 +++-- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/shell/platform/linux/fl_platform_plugin.cc b/shell/platform/linux/fl_platform_plugin.cc index ee76a439c75a4..0390989537d5d 100644 --- a/shell/platform/linux/fl_platform_plugin.cc +++ b/shell/platform/linux/fl_platform_plugin.cc @@ -20,7 +20,8 @@ static constexpr char kSetClipboardDataMethod[] = "Clipboard.setData"; static constexpr char kClipboardHasStringsMethod[] = "Clipboard.hasStrings"; static constexpr char kExitApplicationMethod[] = "System.exitApplication"; static constexpr char kRequestAppExitMethod[] = "System.requestAppExit"; -static constexpr char kRegisterBindingMethod[] = "System.enableApplicationLifecycle"; +static constexpr char kRegisterBindingMethod[] = + "System.enableApplicationLifecycle"; static constexpr char kPlaySoundMethod[] = "SystemSound.play"; static constexpr char kSystemNavigatorPopMethod[] = "SystemNavigator.pop"; static constexpr char kTextKey[] = "text"; diff --git a/shell/platform/windows/flutter_windows_engine.cc b/shell/platform/windows/flutter_windows_engine.cc index aaeef9386711c..8d8f3f15d358d 100644 --- a/shell/platform/windows/flutter_windows_engine.cc +++ b/shell/platform/windows/flutter_windows_engine.cc @@ -778,7 +778,7 @@ void FlutterWindowsEngine::OnDwmCompositionChanged() { view_->OnDwmCompositionChanged(); } -void FlutterWindowsEngine::OnServiceBindingsRegistered() { +void FlutterWindowsEngine::OnApplicationLifecycleEnabled() { lifecycle_manager_->BeginProcessingClose(); } diff --git a/shell/platform/windows/flutter_windows_engine.h b/shell/platform/windows/flutter_windows_engine.h index 2e903e0ad0f08..36d21f822df54 100644 --- a/shell/platform/windows/flutter_windows_engine.h +++ b/shell/platform/windows/flutter_windows_engine.h @@ -271,7 +271,7 @@ class FlutterWindowsEngine { // Called in response to the framework registering a ServiceBindings. // Registers the top level handler for the WM_CLOSE window message. - void OnServiceBindingsRegistered(); + void OnApplicationLifecycleEnabled(); protected: // Creates the keyboard key handler. diff --git a/shell/platform/windows/flutter_windows_engine_unittests.cc b/shell/platform/windows/flutter_windows_engine_unittests.cc index 82632c5433786..d518e7f9c1f66 100644 --- a/shell/platform/windows/flutter_windows_engine_unittests.cc +++ b/shell/platform/windows/flutter_windows_engine_unittests.cc @@ -657,7 +657,7 @@ TEST_F(FlutterWindowsEngineTest, TestExit) { ON_CALL(*handler, IsLastWindowOfProcess).WillByDefault([]() { return true; }); EXPECT_CALL(*handler, Quit).Times(1); modifier.SetLifecycleManager(std::move(handler)); - engine->OnServiceBindingsRegistered(); + engine->OnApplicationLifecycleEnabled(); engine->Run(); @@ -694,7 +694,7 @@ TEST_F(FlutterWindowsEngineTest, TestExitCancel) { ON_CALL(*handler, IsLastWindowOfProcess).WillByDefault([]() { return true; }); EXPECT_CALL(*handler, Quit).Times(0); modifier.SetLifecycleManager(std::move(handler)); - engine->OnServiceBindingsRegistered(); + engine->OnApplicationLifecycleEnabled(); auto binary_messenger = std::make_unique(engine->messenger()); @@ -755,7 +755,7 @@ TEST_F(FlutterWindowsEngineTest, TestExitSecondCloseMessage) { hwnd, msg, wparam, lparam); }); modifier.SetLifecycleManager(std::move(handler)); - engine->OnServiceBindingsRegistered(); + engine->OnApplicationLifecycleEnabled(); engine->Run(); @@ -806,7 +806,7 @@ TEST_F(FlutterWindowsEngineTest, TestExitCloseMultiWindow) { // Quit should not be called when there is more than one window. EXPECT_CALL(*handler, Quit).Times(0); modifier.SetLifecycleManager(std::move(handler)); - engine->OnServiceBindingsRegistered(); + engine->OnApplicationLifecycleEnabled(); engine->Run(); @@ -854,7 +854,7 @@ TEST_F(FlutterWindowsEngineTest, EnableApplicationLifecycle) { }); EXPECT_CALL(*handler, IsLastWindowOfProcess).Times(1); modifier.SetLifecycleManager(std::move(handler)); - engine->OnServiceBindingsRegistered(); + engine->OnApplicationLifecycleEnabled(); engine->window_proc_delegate_manager()->OnTopLevelWindowProc(0, WM_CLOSE, 0, 0); diff --git a/shell/platform/windows/platform_handler.cc b/shell/platform/windows/platform_handler.cc index 949ebcc0eec62..baaa05f0f06d9 100644 --- a/shell/platform/windows/platform_handler.cc +++ b/shell/platform/windows/platform_handler.cc @@ -23,7 +23,8 @@ static constexpr char kHasStringsClipboardMethod[] = "Clipboard.hasStrings"; static constexpr char kSetClipboardDataMethod[] = "Clipboard.setData"; static constexpr char kExitApplicationMethod[] = "System.exitApplication"; static constexpr char kRequestAppExitMethod[] = "System.requestAppExit"; -static constexpr char kRegisterBindingMethod[] = "System.enableApplicationLifecycle"; +static constexpr char kRegisterBindingMethod[] = + "System.enableApplicationLifecycle"; static constexpr char kPlaySoundMethod[] = "SystemSound.play"; static constexpr char kExitCodeKey[] = "exitCode"; @@ -497,7 +498,7 @@ void PlatformHandler::HandleMethodCall( SystemSoundPlay(sound_type.GetString(), std::move(result)); } else if (method.compare(kRegisterBindingMethod) == 0) { - engine_->OnServiceBindingsRegistered(); + engine_->OnApplicationLifecycleEnabled(); result->Success(); } else { result->NotImplemented(); From 01409d4ae5a7729b5f7215fbc8b0ff29abf6760e Mon Sep 17 00:00:00 2001 From: schectman Date: Fri, 5 May 2023 10:46:51 -0400 Subject: [PATCH 13/21] TODO comments --- shell/platform/darwin/macos/framework/Source/FlutterEngine.mm | 2 ++ shell/platform/linux/fl_platform_plugin.cc | 4 +++- shell/platform/windows/platform_handler.cc | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index fd3c379d2da5e..c46671f5f2236 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -1032,6 +1032,8 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { } else if ([call.method isEqualToString:@"System.exitApplication"]) { [[self terminationHandler] handleRequestAppExitMethodCall:call.arguments result:result]; } else if ([call.method isEqualToString:@"System.enableApplicationLifecycle"]) { + // TODO: Handle this message to enable exit message listening. + // https://github.com/flutter/flutter/issues/126033 result(nil); } else { result(FlutterMethodNotImplemented); diff --git a/shell/platform/linux/fl_platform_plugin.cc b/shell/platform/linux/fl_platform_plugin.cc index 0390989537d5d..475d943968dd5 100644 --- a/shell/platform/linux/fl_platform_plugin.cc +++ b/shell/platform/linux/fl_platform_plugin.cc @@ -20,7 +20,7 @@ static constexpr char kSetClipboardDataMethod[] = "Clipboard.setData"; static constexpr char kClipboardHasStringsMethod[] = "Clipboard.hasStrings"; static constexpr char kExitApplicationMethod[] = "System.exitApplication"; static constexpr char kRequestAppExitMethod[] = "System.requestAppExit"; -static constexpr char kRegisterBindingMethod[] = +static constexpr char kEnableApplicationLifecycleMethod[] = "System.enableApplicationLifecycle"; static constexpr char kPlaySoundMethod[] = "SystemSound.play"; static constexpr char kSystemNavigatorPopMethod[] = "SystemNavigator.pop"; @@ -338,6 +338,8 @@ static void method_call_cb(FlMethodChannel* channel, } else if (strcmp(method, kSystemNavigatorPopMethod) == 0) { response = system_navigator_pop(self); } else if (strcmp(method, kRegisterBindingMethod) == 0) { + // TODO: Handle this message to enable exit message listening. + // https://github.com/flutter/flutter/issues/126033 response = FL_METHOD_RESPONSE(fl_method_success_response_new(fl_value_new_null())); } else { diff --git a/shell/platform/windows/platform_handler.cc b/shell/platform/windows/platform_handler.cc index baaa05f0f06d9..3af58aed122a9 100644 --- a/shell/platform/windows/platform_handler.cc +++ b/shell/platform/windows/platform_handler.cc @@ -23,7 +23,7 @@ static constexpr char kHasStringsClipboardMethod[] = "Clipboard.hasStrings"; static constexpr char kSetClipboardDataMethod[] = "Clipboard.setData"; static constexpr char kExitApplicationMethod[] = "System.exitApplication"; static constexpr char kRequestAppExitMethod[] = "System.requestAppExit"; -static constexpr char kRegisterBindingMethod[] = +static constexpr char kEnableApplicationLifecycleMethod[] = "System.enableApplicationLifecycle"; static constexpr char kPlaySoundMethod[] = "SystemSound.play"; @@ -497,7 +497,7 @@ void PlatformHandler::HandleMethodCall( const rapidjson::Value& sound_type = method_call.arguments()[0]; SystemSoundPlay(sound_type.GetString(), std::move(result)); - } else if (method.compare(kRegisterBindingMethod) == 0) { + } else if (method.compare(kEnableApplicationLifecycleMethod) == 0) { engine_->OnApplicationLifecycleEnabled(); result->Success(); } else { From d35bf0081a6f0192c575d80132f97f8da4dfa957 Mon Sep 17 00:00:00 2001 From: schectman Date: Fri, 5 May 2023 12:57:21 -0400 Subject: [PATCH 14/21] VS mistake --- shell/platform/linux/fl_platform_plugin.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/linux/fl_platform_plugin.cc b/shell/platform/linux/fl_platform_plugin.cc index 475d943968dd5..28390c2f23451 100644 --- a/shell/platform/linux/fl_platform_plugin.cc +++ b/shell/platform/linux/fl_platform_plugin.cc @@ -337,7 +337,7 @@ static void method_call_cb(FlMethodChannel* channel, response = system_sound_play(self, args); } else if (strcmp(method, kSystemNavigatorPopMethod) == 0) { response = system_navigator_pop(self); - } else if (strcmp(method, kRegisterBindingMethod) == 0) { + } else if (strcmp(method, kEnableApplicationLifecycleMethod) == 0) { // TODO: Handle this message to enable exit message listening. // https://github.com/flutter/flutter/issues/126033 response = From 47866e4e6d0ce5b6f737818e4276a88dc2caedec Mon Sep 17 00:00:00 2001 From: schectman Date: Fri, 5 May 2023 13:25:44 -0400 Subject: [PATCH 15/21] Tag gspencergoog in TODO for Linux --- shell/platform/linux/fl_platform_plugin.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/linux/fl_platform_plugin.cc b/shell/platform/linux/fl_platform_plugin.cc index 28390c2f23451..780802cd6ca84 100644 --- a/shell/platform/linux/fl_platform_plugin.cc +++ b/shell/platform/linux/fl_platform_plugin.cc @@ -338,7 +338,7 @@ static void method_call_cb(FlMethodChannel* channel, } else if (strcmp(method, kSystemNavigatorPopMethod) == 0) { response = system_navigator_pop(self); } else if (strcmp(method, kEnableApplicationLifecycleMethod) == 0) { - // TODO: Handle this message to enable exit message listening. + // TODO(gspencergoog): Handle this message to enable exit message listening. // https://github.com/flutter/flutter/issues/126033 response = FL_METHOD_RESPONSE(fl_method_success_response_new(fl_value_new_null())); From a759f41c81ba46c74618bb41772dcd37ee3d7acf Mon Sep 17 00:00:00 2001 From: schectman Date: Fri, 5 May 2023 14:27:53 -0400 Subject: [PATCH 16/21] Tag chrome-bot --- shell/platform/darwin/macos/framework/Source/FlutterEngine.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index c46671f5f2236..a3f63e119f74e 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -1032,7 +1032,7 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { } else if ([call.method isEqualToString:@"System.exitApplication"]) { [[self terminationHandler] handleRequestAppExitMethodCall:call.arguments result:result]; } else if ([call.method isEqualToString:@"System.enableApplicationLifecycle"]) { - // TODO: Handle this message to enable exit message listening. + // TODO(chrome-bot): Handle this message to enable exit message listening. // https://github.com/flutter/flutter/issues/126033 result(nil); } else { From 621bca64a3910ab2158eee1bd8ffa85ca87091f8 Mon Sep 17 00:00:00 2001 From: schectman Date: Fri, 5 May 2023 15:10:21 -0400 Subject: [PATCH 17/21] Rename method --- shell/platform/darwin/macos/framework/Source/FlutterEngine.mm | 2 +- shell/platform/linux/fl_platform_plugin.cc | 2 +- shell/platform/windows/platform_handler.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index a3f63e119f74e..23036125a957f 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -1031,7 +1031,7 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { result(@{@"value" : @([self clipboardHasStrings])}); } else if ([call.method isEqualToString:@"System.exitApplication"]) { [[self terminationHandler] handleRequestAppExitMethodCall:call.arguments result:result]; - } else if ([call.method isEqualToString:@"System.enableApplicationLifecycle"]) { + } else if ([call.method isEqualToString:@"System.initializationComplete"]) { // TODO(chrome-bot): Handle this message to enable exit message listening. // https://github.com/flutter/flutter/issues/126033 result(nil); diff --git a/shell/platform/linux/fl_platform_plugin.cc b/shell/platform/linux/fl_platform_plugin.cc index 780802cd6ca84..395316ac365c2 100644 --- a/shell/platform/linux/fl_platform_plugin.cc +++ b/shell/platform/linux/fl_platform_plugin.cc @@ -21,7 +21,7 @@ static constexpr char kClipboardHasStringsMethod[] = "Clipboard.hasStrings"; static constexpr char kExitApplicationMethod[] = "System.exitApplication"; static constexpr char kRequestAppExitMethod[] = "System.requestAppExit"; static constexpr char kEnableApplicationLifecycleMethod[] = - "System.enableApplicationLifecycle"; + "System.initializationComplete"; static constexpr char kPlaySoundMethod[] = "SystemSound.play"; static constexpr char kSystemNavigatorPopMethod[] = "SystemNavigator.pop"; static constexpr char kTextKey[] = "text"; diff --git a/shell/platform/windows/platform_handler.cc b/shell/platform/windows/platform_handler.cc index 3af58aed122a9..41b7f7b53c0cd 100644 --- a/shell/platform/windows/platform_handler.cc +++ b/shell/platform/windows/platform_handler.cc @@ -24,7 +24,7 @@ static constexpr char kSetClipboardDataMethod[] = "Clipboard.setData"; static constexpr char kExitApplicationMethod[] = "System.exitApplication"; static constexpr char kRequestAppExitMethod[] = "System.requestAppExit"; static constexpr char kEnableApplicationLifecycleMethod[] = - "System.enableApplicationLifecycle"; + "System.initializationComplete"; static constexpr char kPlaySoundMethod[] = "SystemSound.play"; static constexpr char kExitCodeKey[] = "exitCode"; From ff6af43b3e8334466c819c24bd5b38c716ec2515 Mon Sep 17 00:00:00 2001 From: schectman Date: Fri, 5 May 2023 17:39:07 -0400 Subject: [PATCH 18/21] Rename var --- shell/platform/linux/fl_platform_plugin.cc | 4 ++-- shell/platform/windows/platform_handler.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/shell/platform/linux/fl_platform_plugin.cc b/shell/platform/linux/fl_platform_plugin.cc index 395316ac365c2..67d28efe125d6 100644 --- a/shell/platform/linux/fl_platform_plugin.cc +++ b/shell/platform/linux/fl_platform_plugin.cc @@ -20,7 +20,7 @@ static constexpr char kSetClipboardDataMethod[] = "Clipboard.setData"; static constexpr char kClipboardHasStringsMethod[] = "Clipboard.hasStrings"; static constexpr char kExitApplicationMethod[] = "System.exitApplication"; static constexpr char kRequestAppExitMethod[] = "System.requestAppExit"; -static constexpr char kEnableApplicationLifecycleMethod[] = +static constexpr char kInitializationCompleteMethod[] = "System.initializationComplete"; static constexpr char kPlaySoundMethod[] = "SystemSound.play"; static constexpr char kSystemNavigatorPopMethod[] = "SystemNavigator.pop"; @@ -337,7 +337,7 @@ static void method_call_cb(FlMethodChannel* channel, response = system_sound_play(self, args); } else if (strcmp(method, kSystemNavigatorPopMethod) == 0) { response = system_navigator_pop(self); - } else if (strcmp(method, kEnableApplicationLifecycleMethod) == 0) { + } else if (strcmp(method, kInitializationCompleteMethod) == 0) { // TODO(gspencergoog): Handle this message to enable exit message listening. // https://github.com/flutter/flutter/issues/126033 response = diff --git a/shell/platform/windows/platform_handler.cc b/shell/platform/windows/platform_handler.cc index 41b7f7b53c0cd..771d3d56b9b24 100644 --- a/shell/platform/windows/platform_handler.cc +++ b/shell/platform/windows/platform_handler.cc @@ -23,7 +23,7 @@ static constexpr char kHasStringsClipboardMethod[] = "Clipboard.hasStrings"; static constexpr char kSetClipboardDataMethod[] = "Clipboard.setData"; static constexpr char kExitApplicationMethod[] = "System.exitApplication"; static constexpr char kRequestAppExitMethod[] = "System.requestAppExit"; -static constexpr char kEnableApplicationLifecycleMethod[] = +static constexpr char kInitializationCompleteMethod[] = "System.initializationComplete"; static constexpr char kPlaySoundMethod[] = "SystemSound.play"; @@ -497,7 +497,7 @@ void PlatformHandler::HandleMethodCall( const rapidjson::Value& sound_type = method_call.arguments()[0]; SystemSoundPlay(sound_type.GetString(), std::move(result)); - } else if (method.compare(kEnableApplicationLifecycleMethod) == 0) { + } else if (method.compare(kInitializationCompleteMethod) == 0) { engine_->OnApplicationLifecycleEnabled(); result->Success(); } else { From 5368213dcf6ce20b3ac4f8d9ca86e4c18a73a68d Mon Sep 17 00:00:00 2001 From: schectman Date: Tue, 9 May 2023 07:58:56 -0400 Subject: [PATCH 19/21] Cleanup null --- shell/platform/linux/fl_platform_plugin.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/linux/fl_platform_plugin.cc b/shell/platform/linux/fl_platform_plugin.cc index 67d28efe125d6..9709d57b681c3 100644 --- a/shell/platform/linux/fl_platform_plugin.cc +++ b/shell/platform/linux/fl_platform_plugin.cc @@ -341,7 +341,7 @@ static void method_call_cb(FlMethodChannel* channel, // TODO(gspencergoog): Handle this message to enable exit message listening. // https://github.com/flutter/flutter/issues/126033 response = - FL_METHOD_RESPONSE(fl_method_success_response_new(fl_value_new_null())); + FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr)); } else { response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new()); } From 83d9d67ba1b37241361234ef4af1317f3f7c367e Mon Sep 17 00:00:00 2001 From: schectman Date: Tue, 9 May 2023 13:41:21 -0400 Subject: [PATCH 20/21] Formatting --- shell/platform/linux/fl_platform_plugin.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/shell/platform/linux/fl_platform_plugin.cc b/shell/platform/linux/fl_platform_plugin.cc index 9709d57b681c3..35b954f6b1ac3 100644 --- a/shell/platform/linux/fl_platform_plugin.cc +++ b/shell/platform/linux/fl_platform_plugin.cc @@ -340,8 +340,7 @@ static void method_call_cb(FlMethodChannel* channel, } else if (strcmp(method, kInitializationCompleteMethod) == 0) { // TODO(gspencergoog): Handle this message to enable exit message listening. // https://github.com/flutter/flutter/issues/126033 - response = - FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr)); + response = FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr)); } else { response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new()); } From 5e13448b3162252caa231d468cab79d0b97218cd Mon Sep 17 00:00:00 2001 From: schectman Date: Tue, 9 May 2023 15:45:46 -0400 Subject: [PATCH 21/21] Update TODO --- shell/platform/darwin/macos/framework/Source/FlutterEngine.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index d992ea56b0978..91aa17e903a33 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -1032,7 +1032,7 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { } else if ([call.method isEqualToString:@"System.exitApplication"]) { [[self terminationHandler] handleRequestAppExitMethodCall:call.arguments result:result]; } else if ([call.method isEqualToString:@"System.initializationComplete"]) { - // TODO(chrome-bot): Handle this message to enable exit message listening. + // TODO(gspencergoog): Handle this message to enable exit message listening. // https://github.com/flutter/flutter/issues/126033 result(nil); } else {