| 280 | } |
| 281 | |
| 282 | LRESULT IECommandExecutor::OnAfterNewWindow(UINT uMsg, |
| 283 | WPARAM wParam, |
| 284 | LPARAM lParam, |
| 285 | BOOL& bHandled) { |
| 286 | LOG(TRACE) << "Entering IECommandExecutor::OnAfterNewWindow"; |
| 287 | if (wParam > 0) { |
| 288 | LOG(DEBUG) << "Creating thread and reposting message."; |
| 289 | this->CreateDelayPostMessageThread(static_cast<DWORD>(wParam), |
| 290 | this->m_hWnd, |
| 291 | WD_AFTER_NEW_WINDOW); |
| 292 | if (lParam > 0) { |
| 293 | // a new window is created from Edge in IEMode |
| 294 | BrowserHandle browser_wrapper; |
| 295 | this->GetCurrentBrowser(&browser_wrapper); |
| 296 | HWND top_level_handle = browser_wrapper->GetTopLevelWindowHandle(); |
| 297 | |
| 298 | std::vector<HWND>* current_window_handles = |
| 299 | reinterpret_cast<std::vector<HWND>*>(lParam); |
| 300 | std::unordered_set<HWND> current_window_set( |
| 301 | current_window_handles->begin(), |
| 302 | current_window_handles->end()); |
| 303 | delete current_window_handles; |
| 304 | |
| 305 | // sleep 0.5s then get current window handles |
| 306 | clock_t end = clock() + (DEFAULT_BROWSER_REATTACH_TIMEOUT_IN_MILLISECONDS / 1000 * CLOCKS_PER_SEC); |
| 307 | std::vector<HWND> diff; |
| 308 | int loop_count = 0; |
| 309 | bool is_processing_wm = false; |
| 310 | ::Sleep(1000); |
| 311 | while (diff.size() == 0 && clock() < end) { |
| 312 | std::vector<HWND> edge_window_handles; |
| 313 | ::EnumWindows(&BrowserFactory::FindEdgeBrowserHandles, |
| 314 | reinterpret_cast<LPARAM>(&edge_window_handles)); |
| 315 | |
| 316 | std::vector<HWND> new_ie_window_handles; |
| 317 | for (auto& edge_window_handle : edge_window_handles) { |
| 318 | std::vector<HWND> child_window_handles; |
| 319 | ::EnumChildWindows(edge_window_handle, |
| 320 | &BrowserFactory::FindIEBrowserHandles, |
| 321 | reinterpret_cast<LPARAM>(&child_window_handles)); |
| 322 | |
| 323 | for (auto& child_window_handle : child_window_handles) { |
| 324 | new_ie_window_handles.push_back(child_window_handle); |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | for (auto& window_handle : new_ie_window_handles) { |
| 329 | if (current_window_set.find(window_handle) != current_window_set.end()) { |
| 330 | continue; |
| 331 | } |
| 332 | diff.push_back(window_handle); |
| 333 | } |
| 334 | |
| 335 | if (diff.size() == 0) { |
| 336 | MSG msg; |
| 337 | if (loop_count >= 1 && !is_processing_wm &&::PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_REMOVE)) { |
| 338 | ::TranslateMessage(&msg); |
| 339 | ::DispatchMessage(&msg); |
nothing calls this directly
no test coverage detected