2020-08-29 00:39:23 +02:00
|
|
|
diff --git base/message_loop/message_pump_win.cc base/message_loop/message_pump_win.cc
|
2023-12-06 21:16:15 +01:00
|
|
|
index c30066f515f63..450c67882ea91 100644
|
2020-08-29 00:39:23 +02:00
|
|
|
--- base/message_loop/message_pump_win.cc
|
|
|
|
+++ base/message_loop/message_pump_win.cc
|
|
|
|
@@ -2,6 +2,7 @@
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
+#include "base/task/current_thread.h"
|
|
|
|
#include "base/message_loop/message_pump_win.h"
|
|
|
|
|
|
|
|
#include <algorithm>
|
2023-10-19 20:08:48 +02:00
|
|
|
@@ -496,7 +497,17 @@ bool MessagePumpForUI::ProcessNextWindowsMessage() {
|
2020-12-02 23:31:49 +01:00
|
|
|
ctx.event()->set_chrome_message_pump();
|
|
|
|
msg_pump_data->set_sent_messages_in_queue(more_work_is_plausible);
|
|
|
|
});
|
|
|
|
- has_msg = ::PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE) != FALSE;
|
|
|
|
+
|
|
|
|
+ // We should not process all window messages if we are in the context of an
|
|
|
|
+ // OS modal loop, i.e. in the context of a windows API call like MessageBox.
|
|
|
|
+ // This is to ensure that these messages are peeked out by the OS modal loop.
|
|
|
|
+ if (CurrentThread::Get()->os_modal_loop()) {
|
|
|
|
+ // We only peek out WM_PAINT and WM_TIMER here for reasons mentioned above.
|
|
|
|
+ has_msg = PeekMessage(&msg, NULL, WM_PAINT, WM_PAINT, PM_REMOVE) ||
|
|
|
|
+ PeekMessage(&msg, NULL, WM_TIMER, WM_TIMER, PM_REMOVE);
|
|
|
|
+ } else {
|
|
|
|
+ has_msg = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) != FALSE;
|
|
|
|
+ }
|
|
|
|
}
|
2020-08-29 00:39:23 +02:00
|
|
|
}
|
|
|
|
if (has_msg)
|
|
|
|
diff --git base/task/current_thread.cc base/task/current_thread.cc
|
2023-12-06 21:16:15 +01:00
|
|
|
index 96b2fd7cad015..2fa7f4016fe5a 100644
|
2020-08-29 00:39:23 +02:00
|
|
|
--- base/task/current_thread.cc
|
|
|
|
+++ base/task/current_thread.cc
|
2023-01-30 18:43:54 +01:00
|
|
|
@@ -48,6 +48,8 @@ void CurrentThread::AddDestructionObserver(
|
2018-09-06 17:32:01 +02:00
|
|
|
|
2020-08-29 00:39:23 +02:00
|
|
|
void CurrentThread::RemoveDestructionObserver(
|
2018-09-06 17:32:01 +02:00
|
|
|
DestructionObserver* destruction_observer) {
|
|
|
|
+ if (!current_)
|
|
|
|
+ return;
|
2018-11-30 23:21:07 +01:00
|
|
|
DCHECK(current_->IsBoundToCurrentThread());
|
|
|
|
current_->RemoveDestructionObserver(destruction_observer);
|
2018-09-06 17:32:01 +02:00
|
|
|
}
|
2020-08-29 00:39:23 +02:00
|
|
|
diff --git base/task/current_thread.h base/task/current_thread.h
|
2023-12-06 21:16:15 +01:00
|
|
|
index 33e320fd647cb..5f67ef65d4392 100644
|
2020-08-29 00:39:23 +02:00
|
|
|
--- base/task/current_thread.h
|
|
|
|
+++ base/task/current_thread.h
|
2023-04-04 20:00:13 +02:00
|
|
|
@@ -133,6 +133,12 @@ class BASE_EXPORT CurrentThread {
|
2022-07-21 19:26:10 +02:00
|
|
|
// with a null callback to clear any potentially pending callbacks.
|
2021-12-16 23:35:54 +01:00
|
|
|
void RegisterOnNextIdleCallback(OnceClosure on_next_idle_callback);
|
2016-06-21 00:59:23 +02:00
|
|
|
|
2022-01-25 21:26:51 +01:00
|
|
|
+#if BUILDFLAG(IS_WIN)
|
2019-03-13 22:27:37 +01:00
|
|
|
+ void set_os_modal_loop(bool os_modal_loop) { os_modal_loop_ = os_modal_loop; }
|
2016-06-21 00:59:23 +02:00
|
|
|
+
|
2019-03-13 22:27:37 +01:00
|
|
|
+ bool os_modal_loop() const { return os_modal_loop_; }
|
2016-06-21 00:59:23 +02:00
|
|
|
+#endif // OS_WIN
|
|
|
|
+
|
2020-07-08 19:23:29 +02:00
|
|
|
// Enables nested task processing in scope of an upcoming native message loop.
|
|
|
|
// Some unwanted message loops may occur when using common controls or printer
|
|
|
|
// functions. Hence, nested task processing is disabled by default to avoid
|
2023-04-04 20:00:13 +02:00
|
|
|
@@ -197,6 +203,13 @@ class BASE_EXPORT CurrentThread {
|
2019-10-01 15:55:16 +02:00
|
|
|
friend class web::WebTaskEnvironment;
|
2018-11-30 23:21:07 +01:00
|
|
|
|
2022-06-17 15:28:55 +02:00
|
|
|
raw_ptr<sequence_manager::internal::SequenceManagerImpl> current_;
|
2018-05-14 13:24:05 +02:00
|
|
|
+
|
2022-01-25 21:26:51 +01:00
|
|
|
+#if BUILDFLAG(IS_WIN)
|
2018-05-14 13:24:05 +02:00
|
|
|
+ private:
|
2016-06-21 00:59:23 +02:00
|
|
|
+ // Should be set to true before calling Windows APIs like TrackPopupMenu, etc.
|
|
|
|
+ // which enter a modal message loop.
|
2017-05-31 17:33:30 +02:00
|
|
|
+ bool os_modal_loop_ = false;
|
2016-06-21 00:59:23 +02:00
|
|
|
+#endif
|
2018-05-14 13:24:05 +02:00
|
|
|
};
|
|
|
|
|
2022-01-25 21:26:51 +01:00
|
|
|
#if !BUILDFLAG(IS_NACL)
|