| 644 | } |
| 645 | |
| 646 | LRESULT IECommandExecutor::OnNewHtmlDialog(UINT uMsg, |
| 647 | WPARAM wParam, |
| 648 | LPARAM lParam, |
| 649 | BOOL& bHandles) { |
| 650 | LOG(TRACE) << "Entering IECommandExecutor::OnNewHtmlDialog"; |
| 651 | |
| 652 | HWND dialog_handle = reinterpret_cast<HWND>(lParam); |
| 653 | BrowserMap::const_iterator it = this->managed_browsers_.begin(); |
| 654 | for (; it != this->managed_browsers_.end(); ++it) { |
| 655 | if (dialog_handle == it->second->window_handle()) { |
| 656 | LOG(DEBUG) << "Dialog is equal to one managed browser"; |
| 657 | return 0; |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | int retry_count = 0; |
| 662 | CComPtr<IHTMLDocument2> document; |
| 663 | bool found_document = this->factory_->GetDocumentFromWindowHandle(dialog_handle, &document); |
| 664 | while (found_document && retry_count < MAX_HTML_DIALOG_RETRIES) { |
| 665 | CComPtr<IHTMLWindow2> window; |
| 666 | HRESULT hr = document->get_parentWindow(&window); |
| 667 | if (FAILED(hr)) { |
| 668 | // Getting the parent window of the dialog's document failed. This |
| 669 | // usually means that the document changed out from under us before we |
| 670 | // could get the window reference. The canonical case for this is a |
| 671 | // redirect using JavaScript. Sleep for a short time, then retry to |
| 672 | // obtain the reference. |
| 673 | LOGHR(DEBUG, hr) << "IHTMLDocument2::get_parentWindow failed. Retrying."; |
| 674 | ::Sleep(100); |
| 675 | document.Release(); |
| 676 | found_document = this->factory_->GetDocumentFromWindowHandle(dialog_handle, &document); |
| 677 | ++retry_count; |
| 678 | } else { |
| 679 | this->AddManagedBrowser(BrowserHandle(new HtmlDialog(window, |
| 680 | dialog_handle, |
| 681 | this->m_hWnd))); |
| 682 | return 0; |
| 683 | } |
| 684 | } |
| 685 | if (found_document) { |
| 686 | LOG(WARN) << "Got document from dialog, but could not get window"; |
| 687 | } else { |
| 688 | LOG(WARN) << "Unable to get document from dialog"; |
| 689 | } |
| 690 | return 0; |
| 691 | } |
| 692 | |
| 693 | LRESULT IECommandExecutor::OnQuit(UINT uMsg, |
| 694 | WPARAM wParam, |
nothing calls this directly
no test coverage detected