| 239 | } |
| 240 | |
| 241 | int DocumentHost::SetFocusedFrameByIdentifier(VARIANT frame_identifier) { |
| 242 | LOG(TRACE) << "Entering DocumentHost::SetFocusedFrameByIdentifier"; |
| 243 | |
| 244 | CComPtr<IHTMLDocument2> doc; |
| 245 | this->GetDocument(&doc); |
| 246 | |
| 247 | CComPtr<IHTMLFramesCollection2> frames; |
| 248 | HRESULT hr = doc->get_frames(&frames); |
| 249 | |
| 250 | if (!frames) { |
| 251 | LOG(WARN) << "No frames in document are set, IHTMLDocument2::get_frames returned NULL"; |
| 252 | return ENOSUCHFRAME; |
| 253 | } |
| 254 | |
| 255 | long length = 0; |
| 256 | frames->get_length(&length); |
| 257 | if (!length) { |
| 258 | LOG(WARN) << "No frames in document are found IHTMLFramesCollection2::get_length returned 0"; |
| 259 | return ENOSUCHFRAME; |
| 260 | } |
| 261 | |
| 262 | // Find the frame |
| 263 | CComVariant frame_holder; |
| 264 | hr = frames->item(&frame_identifier, &frame_holder); |
| 265 | |
| 266 | if (FAILED(hr)) { |
| 267 | LOGHR(WARN, hr) << "Error retrieving frame holder, call to IHTMLFramesCollection2::item failed"; |
| 268 | return ENOSUCHFRAME; |
| 269 | } |
| 270 | |
| 271 | CComPtr<IHTMLWindow2> interim_result; |
| 272 | frame_holder.pdispVal->QueryInterface<IHTMLWindow2>(&interim_result); |
| 273 | if (!interim_result) { |
| 274 | LOG(WARN) << "Error retrieving frame, IDispatch cannot be cast to IHTMLWindow2"; |
| 275 | return ENOSUCHFRAME; |
| 276 | } |
| 277 | |
| 278 | this->focused_frame_window_ = interim_result; |
| 279 | return WD_SUCCESS; |
| 280 | } |
| 281 | |
| 282 | void DocumentHost::PostQuitMessage() { |
| 283 | LOG(TRACE) << "Entering DocumentHost::PostQuitMessage"; |
no test coverage detected