HRESULT MiniBrowserWebHost::updateAddressBar(IWebView& webView) { IWebFramePtr mainFrame; HRESULT hr = webView.mainFrame(&mainFrame.GetInterfacePtr()); if (FAILED(hr)) return hr; IWebDataSourcePtr dataSource; hr = mainFrame->dataSource(&dataSource.GetInterfacePtr()); if (FAILED(hr) || !dataSource) hr = mainFrame->provisionalDataSource(&dataSource.GetInterfacePtr()); if (FAILED(hr) || !dataSource) return hr; IWebMutableURLRequestPtr request; hr = dataSource->request(&request.GetInterfacePtr()); if (FAILED(hr) || !request) return hr; _bstr_t frameURL; hr = request->mainDocumentURL(frameURL.GetAddress()); if (FAILED(hr)) return hr; if (frameURL.length()) { m_client->pageLoadTestClient().setPageURL(frameURL); m_client->pageLoadTestClient().didCommitLoad(); } loadURL(frameURL); return S_OK; }
HRESULT WinLauncherWebHost::updateAddressBar(IWebView& webView) { IWebFramePtr mainFrame; HRESULT hr = webView.mainFrame(&mainFrame.GetInterfacePtr()); if (FAILED(hr)) return 0; IWebDataSourcePtr dataSource; hr = mainFrame->dataSource(&dataSource.GetInterfacePtr()); if (FAILED(hr) || !dataSource) hr = mainFrame->provisionalDataSource(&dataSource.GetInterfacePtr()); if (FAILED(hr) || !dataSource) return 0; IWebMutableURLRequestPtr request; hr = dataSource->request(&request.GetInterfacePtr()); if (FAILED(hr) || !request) return 0; _bstr_t frameURL; hr = request->mainDocumentURL(frameURL.GetAddress()); if (FAILED(hr)) return 0; ::SendMessage(m_hURLBarWnd, static_cast<UINT>(WM_SETTEXT), 0, reinterpret_cast<LPARAM>(frameURL.GetBSTR())); return 0; }