| 77 | } |
| 78 | |
| 79 | std::string DocumentHost::GetCurrentUrl() { |
| 80 | LOG(TRACE) << "Entering DocumentHost::GetCurrentUrl"; |
| 81 | |
| 82 | CComPtr<IHTMLDocument2> doc; |
| 83 | this->GetDocument(&doc); |
| 84 | if (!doc) { |
| 85 | LOG(WARN) << "Unable to get document object, DocumentHost::GetDocument returned NULL. " |
| 86 | << "Attempting to get URL from IWebBrowser2 object"; |
| 87 | return this->GetBrowserUrl(); |
| 88 | } |
| 89 | |
| 90 | CComBSTR url; |
| 91 | HRESULT hr = doc->get_URL(&url); |
| 92 | if (FAILED(hr)) { |
| 93 | LOGHR(WARN, hr) << "Unable to get current URL, call to IHTMLDocument2::get_URL failed"; |
| 94 | return ""; |
| 95 | } |
| 96 | |
| 97 | std::wstring converted_url(url, ::SysStringLen(url)); |
| 98 | std::string current_url = StringUtilities::ToString(converted_url); |
| 99 | return current_url; |
| 100 | } |
| 101 | |
| 102 | std::string DocumentHost::GetPageSource() { |
| 103 | LOG(TRACE) << "Entering DocumentHost::GetPageSource"; |
no test coverage detected