From 0663b9dae22de5e56ef13aa055019df8e5e88a80 Mon Sep 17 00:00:00 2001 From: Robo Date: Thu, 5 Mar 2015 20:09:27 +0530 Subject: [PATCH] using WebContentsObserver::NavigationEntryCommitted to set virtualurl --- atom/browser/api/atom_api_web_contents.cc | 15 ++++++++++++++- atom/browser/api/atom_api_web_contents.h | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index d3c453ff1c4c..b1426c98edde 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -16,6 +16,7 @@ #include "base/strings/utf_string_conversions.h" #include "brightray/browser/inspectable_web_contents.h" #include "content/public/browser/navigation_details.h" +#include "content/public/browser/navigation_entry.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" @@ -264,6 +265,15 @@ void WebContents::WebContentsDestroyed() { Emit("destroyed"); } +void WebContents::NavigationEntryCommitted( + const content::LoadCommittedDetails& load_details) { + content::NavigationEntry* entry = load_details.entry; + web_contents() + ->GetController() + .GetLastCommittedEntry() + ->SetVirtualURL(entry->GetOriginalRequestURL()); +} + void WebContents::DidAttach(int guest_proxy_routing_id) { Emit("did-attach"); } @@ -323,7 +333,10 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) { } GURL WebContents::GetURL() const { - return web_contents()->GetURL(); + return web_contents() + ->GetController() + .GetLastCommittedEntry() + ->GetVirtualURL(); } base::string16 WebContents::GetTitle() const { diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 7e65b462d934..75714306684c 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -165,6 +165,8 @@ class WebContents : public mate::EventEmitter, bool OnMessageReceived(const IPC::Message& message) override; void RenderViewReady() override; void WebContentsDestroyed() override; + void NavigationEntryCommitted( + const content::LoadCommittedDetails& load_details) override; // content::BrowserPluginGuestDelegate: void DidAttach(int guest_proxy_routing_id) final;