| 350 | } |
| 351 | |
| 352 | std::string Browser::GetWindowName() { |
| 353 | LOG(TRACE) << "Entering Browser::GetWindowName"; |
| 354 | |
| 355 | CComPtr<IDispatch> dispatch; |
| 356 | HRESULT hr = this->browser_->get_Document(&dispatch); |
| 357 | if (FAILED(hr)) { |
| 358 | LOGHR(WARN, hr) << "Unable to get document, IWebBrowser2::get_Document call failed"; |
| 359 | return ""; |
| 360 | } |
| 361 | |
| 362 | CComPtr<IHTMLDocument2> doc; |
| 363 | dispatch->QueryInterface<IHTMLDocument2>(&doc); |
| 364 | if (!doc) { |
| 365 | LOGHR(WARN, hr) << "Have document but cannot cast, IDispatch::QueryInterface call failed"; |
| 366 | return ""; |
| 367 | } |
| 368 | |
| 369 | CComPtr<IHTMLWindow2> window; |
| 370 | hr = doc->get_parentWindow(&window); |
| 371 | if (FAILED(hr)) { |
| 372 | LOGHR(WARN, hr) << "Unable to get parent window, call to IHTMLDocument2::get_parentWindow failed"; |
| 373 | return ""; |
| 374 | } |
| 375 | |
| 376 | std::string name = ""; |
| 377 | CComBSTR window_name; |
| 378 | hr = window->get_name(&window_name); |
| 379 | if (window_name) { |
| 380 | std::wstring converted_window_name = window_name; |
| 381 | name = StringUtilities::ToString(converted_window_name); |
| 382 | } else { |
| 383 | LOG(WARN) << "Unable to get window name, IHTMLWindow2::get_name failed or returned a NULL value"; |
| 384 | } |
| 385 | |
| 386 | return name; |
| 387 | } |
| 388 | |
| 389 | long Browser::GetWidth() { |
| 390 | LOG(TRACE) << "Entering Browser::GetWidth"; |