CefFrame::GetURL in the renderer process should return the provisional URL for popups during loading (issue #2448)

This commit is contained in:
Marshall Greenblatt 2018-07-09 14:36:37 -04:00
parent 9229cdd0eb
commit 448a112352
3 changed files with 15 additions and 6 deletions

View File

@ -346,7 +346,7 @@ CefRefPtr<CefFrameImpl> CefBrowserImpl::GetWebFrameImpl(
if (it != frames_.end()) if (it != frames_.end())
return it->second; return it->second;
CefRefPtr<CefFrameImpl> framePtr(new CefFrameImpl(this, frame)); CefRefPtr<CefFrameImpl> framePtr(new CefFrameImpl(this, frame, frame_id));
frames_.insert(std::make_pair(frame_id, framePtr)); frames_.insert(std::make_pair(frame_id, framePtr));
const int64_t parent_id = frame->Parent() == NULL const int64_t parent_id = frame->Parent() == NULL

View File

@ -34,10 +34,10 @@
using blink::WebString; using blink::WebString;
CefFrameImpl::CefFrameImpl(CefBrowserImpl* browser, blink::WebLocalFrame* frame) CefFrameImpl::CefFrameImpl(CefBrowserImpl* browser,
: browser_(browser), blink::WebLocalFrame* frame,
frame_(frame), int64_t frame_id)
frame_id_(render_frame_util::GetIdentifier(frame)) {} : browser_(browser), frame_(frame), frame_id_(frame_id) {}
CefFrameImpl::~CefFrameImpl() {} CefFrameImpl::~CefFrameImpl() {}
@ -216,6 +216,13 @@ CefString CefFrameImpl::GetURL() {
if (frame_) { if (frame_) {
GURL gurl = frame_->GetDocument().Url(); 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(); url = gurl.spec();
} }
return url; return url;

View File

@ -21,7 +21,9 @@ class WebLocalFrame;
// associated renderer WebFrame will close. // associated renderer WebFrame will close.
class CefFrameImpl : public CefFrame { class CefFrameImpl : public CefFrame {
public: public:
CefFrameImpl(CefBrowserImpl* browser, blink::WebLocalFrame* frame); CefFrameImpl(CefBrowserImpl* browser,
blink::WebLocalFrame* frame,
int64_t frame_id);
~CefFrameImpl() override; ~CefFrameImpl() override;
// CefFrame implementation. // CefFrame implementation.