| 568 | } |
| 569 | |
| 570 | LRESULT IECommandExecutor::OnBrowserReattach(UINT uMsg, |
| 571 | WPARAM wParam, |
| 572 | LPARAM lParam, |
| 573 | BOOL& bHandled) { |
| 574 | LOG(TRACE) << "Entering IECommandExecutor::OnBrowserReattach"; |
| 575 | BrowserReattachInfo* info = reinterpret_cast<BrowserReattachInfo*>(lParam); |
| 576 | DWORD current_process_id = info->current_process_id; |
| 577 | std::string browser_id = info->browser_id; |
| 578 | std::vector<DWORD> known_process_ids = info->known_process_ids; |
| 579 | delete info; |
| 580 | |
| 581 | if (!this->factory_->ignore_protected_mode_settings()) { |
| 582 | return 0; |
| 583 | } |
| 584 | |
| 585 | if (this->reattach_wait_timeout_ < clock()) { |
| 586 | LOG(WARN) << "Reattach attempt has timed out"; |
| 587 | return 0; |
| 588 | } |
| 589 | |
| 590 | LOG(DEBUG) << "Starting browser reattach process"; |
| 591 | |
| 592 | std::vector<DWORD> new_process_ids; |
| 593 | this->GetNewBrowserProcessIds(&known_process_ids, &new_process_ids); |
| 594 | if (new_process_ids.size() == 0) { |
| 595 | LOG(DEBUG) << "No new process found, rescheduling reattach"; |
| 596 | // If no new process IDs were found yet, repost the message |
| 597 | this->PostBrowserReattachMessage(current_process_id, |
| 598 | browser_id, |
| 599 | known_process_ids); |
| 600 | } |
| 601 | if (new_process_ids.size() > 1) { |
| 602 | LOG(WARN) << "Found more than one new iexplore.exe process. It is " |
| 603 | << "impossible to know which is the proper one. Choosing one " |
| 604 | << "at random."; |
| 605 | } |
| 606 | |
| 607 | DWORD new_process_id = new_process_ids[0]; |
| 608 | if (!this->factory_->IsBrowserProcessInitialized(new_process_id)) { |
| 609 | // If the browser for the new process ID is not yet ready, |
| 610 | // repost the message |
| 611 | LOG(DEBUG) << "Browser process " << new_process_id |
| 612 | << " not initialized, rescheduling reattach"; |
| 613 | this->PostBrowserReattachMessage(current_process_id, |
| 614 | browser_id, |
| 615 | known_process_ids); |
| 616 | return 0; |
| 617 | } |
| 618 | |
| 619 | std::string error_message = ""; |
| 620 | ProcessWindowInfo process_window_info; |
| 621 | process_window_info.dwProcessId = new_process_id; |
| 622 | process_window_info.hwndBrowser = NULL; |
| 623 | process_window_info.pBrowser = NULL; |
| 624 | bool attached = this->factory_->AttachToBrowser(&process_window_info, &error_message); |
| 625 | |
| 626 | BrowserMap::iterator found_iterator = this->managed_browsers_.find(browser_id); |
| 627 | if (found_iterator != this->managed_browsers_.end()) { |
nothing calls this directly
no test coverage detected