diff --git a/libcef/renderer/browser_impl.cc b/libcef/renderer/browser_impl.cc index 4cac29295..d25fa6abd 100644 --- a/libcef/renderer/browser_impl.cc +++ b/libcef/renderer/browser_impl.cc @@ -345,7 +345,7 @@ CefRefPtr CefBrowserImpl::GetWebFrameImpl( if (it != frames_.end()) return it->second; - CefRefPtr framePtr(new CefFrameImpl(this, frame)); + CefRefPtr framePtr(new CefFrameImpl(this, frame, frame_id)); frames_.insert(std::make_pair(frame_id, framePtr)); const int64_t parent_id = frame->Parent() == NULL diff --git a/libcef/renderer/frame_impl.cc b/libcef/renderer/frame_impl.cc index 4c4284082..ea0bc5b04 100644 --- a/libcef/renderer/frame_impl.cc +++ b/libcef/renderer/frame_impl.cc @@ -27,6 +27,7 @@ #include "third_party/blink/public/platform/web_url.h" #include "third_party/blink/public/web/blink.h" #include "third_party/blink/public/web/web_document.h" +#include "third_party/blink/public/web/web_document_loader.h" #include "third_party/blink/public/web/web_frame_content_dumper.h" #include "third_party/blink/public/web/web_local_frame.h" #include "third_party/blink/public/web/web_script_source.h" @@ -34,10 +35,10 @@ using blink::WebString; -CefFrameImpl::CefFrameImpl(CefBrowserImpl* browser, blink::WebLocalFrame* frame) - : browser_(browser), - frame_(frame), - frame_id_(render_frame_util::GetIdentifier(frame)) {} +CefFrameImpl::CefFrameImpl(CefBrowserImpl* browser, + blink::WebLocalFrame* frame, + int64_t frame_id) + : browser_(browser), frame_(frame), frame_id_(frame_id) {} CefFrameImpl::~CefFrameImpl() {} @@ -216,6 +217,13 @@ CefString CefFrameImpl::GetURL() { if (frame_) { GURL gurl = frame_->GetDocument().Url(); + if (gurl.is_empty()) { + // For popups the main document URL will be empty during loading. Return + // the provisional document URL instead. + blink::WebDocumentLoader* loader = frame_->GetProvisionalDocumentLoader(); + if (loader) + gurl = loader->GetRequest().Url(); + } url = gurl.spec(); } return url; diff --git a/libcef/renderer/frame_impl.h b/libcef/renderer/frame_impl.h index 674615792..c31d73d5d 100644 --- a/libcef/renderer/frame_impl.h +++ b/libcef/renderer/frame_impl.h @@ -21,7 +21,9 @@ class WebLocalFrame; // associated renderer WebFrame will close. class CefFrameImpl : public CefFrame { public: - CefFrameImpl(CefBrowserImpl* browser, blink::WebLocalFrame* frame); + CefFrameImpl(CefBrowserImpl* browser, + blink::WebLocalFrame* frame, + int64_t frame_id); ~CefFrameImpl() override; // CefFrame implementation.