diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 380b2624b094..a4b3816b5d5e 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -47,6 +47,7 @@ #include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/navigation_details.h" #include "content/public/browser/navigation_entry.h" +#include "content/public/browser/navigation_handle.h" #include "content/public/browser/plugin_service.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" @@ -603,20 +604,6 @@ void WebContents::DidFinishLoad(content::RenderFrameHost* render_frame_host, Emit("did-finish-load"); } -void WebContents::DidFailProvisionalLoad( - content::RenderFrameHost* render_frame_host, - const GURL& url, - int code, - const base::string16& description, - bool was_ignored_by_handler) { - bool is_main_frame = !render_frame_host->GetParent(); - Emit("did-fail-provisional-load", code, description, url, is_main_frame); - - // Do not emit "did-fail-load" for canceled requests. - if (code != net::ERR_ABORTED) - Emit("did-fail-load", code, description, url, is_main_frame); -} - void WebContents::DidFailLoad(content::RenderFrameHost* render_frame_host, const GURL& url, int error_code, @@ -660,13 +647,27 @@ void WebContents::DidGetRedirectForResourceRequest( details.headers.get()); } -void WebContents::DidNavigateMainFrame( - const content::LoadCommittedDetails& details, - const content::FrameNavigateParams& params) { - if (details.is_navigation_to_different_page()) - Emit("did-navigate", params.url); - else if (details.is_in_page) - Emit("did-navigate-in-page", params.url); +void WebContents::DidFinishNavigation( + content::NavigationHandle* navigation_handle) { + bool is_main_frame = navigation_handle->IsInMainFrame(); + if (navigation_handle->HasCommitted() && !navigation_handle->IsErrorPage()) { + auto url = navigation_handle->GetURL(); + bool is_in_page = navigation_handle->IsSamePage(); + if (is_main_frame && !is_in_page) { + Emit("did-navigate", url); + } else if (is_in_page) { + Emit("did-navigate-in-page", url); + } + } else { + auto url = navigation_handle->GetURL(); + int code = navigation_handle->GetNetErrorCode(); + auto description = net::ErrorToShortString(code); + Emit("did-fail-provisional-load", code, description, url, is_main_frame); + + // Do not emit "did-fail-load" for canceled requests. + if (code != net::ERR_ABORTED) + Emit("did-fail-load", code, description, url, is_main_frame); + } } void WebContents::TitleWasSet(content::NavigationEntry* entry, diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 5e1a48783d88..47684b929830 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -245,11 +245,6 @@ class WebContents : public mate::TrackableObject, int error_code, const base::string16& error_description, bool was_ignored_by_handler) override; - void DidFailProvisionalLoad(content::RenderFrameHost* render_frame_host, - const GURL& validated_url, - int error_code, - const base::string16& error_description, - bool was_ignored_by_handler) override; void DidStartLoading() override; void DidStopLoading() override; void DidGetResourceResponseStart( @@ -257,9 +252,8 @@ class WebContents : public mate::TrackableObject, void DidGetRedirectForResourceRequest( content::RenderFrameHost* render_frame_host, const content::ResourceRedirectDetails& details) override; - void DidNavigateMainFrame( - const content::LoadCommittedDetails& details, - const content::FrameNavigateParams& params) override; + void DidFinishNavigation( + content::NavigationHandle* navigation_handle) override; bool OnMessageReceived(const IPC::Message& message) override; void WebContentsDestroyed() override; void NavigationEntryCommitted( diff --git a/atom/browser/web_view_guest_delegate.cc b/atom/browser/web_view_guest_delegate.cc index 11f8219bf088..7f5a9261b93d 100644 --- a/atom/browser/web_view_guest_delegate.cc +++ b/atom/browser/web_view_guest_delegate.cc @@ -7,6 +7,7 @@ #include "atom/browser/api/atom_api_web_contents.h" #include "atom/common/native_mate_converters/gurl_converter.h" #include "content/public/browser/guest_host.h" +#include "content/public/browser/navigation_handle.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host.h" @@ -95,10 +96,13 @@ void WebViewGuestDelegate::SetSize(const SetSizeParams& params) { auto_size_enabled_ = enable_auto_size; } -void WebViewGuestDelegate::DidCommitProvisionalLoadForFrame( - content::RenderFrameHost* render_frame_host, - const GURL& url, ui::PageTransition transition_type) { - api_web_contents_->Emit("load-commit", url, !render_frame_host->GetParent()); +void WebViewGuestDelegate::DidFinishNavigation( + content::NavigationHandle* navigation_handle) { + if (navigation_handle->HasCommitted() && !navigation_handle->IsErrorPage()) { + auto is_main_frame = navigation_handle->IsInMainFrame(); + auto url = navigation_handle->GetURL(); + api_web_contents_->Emit("load-commit", url, is_main_frame); + } } void WebViewGuestDelegate::DidAttach(int guest_proxy_routing_id) { diff --git a/atom/browser/web_view_guest_delegate.h b/atom/browser/web_view_guest_delegate.h index d65eb1463586..f63a46cf76ce 100644 --- a/atom/browser/web_view_guest_delegate.h +++ b/atom/browser/web_view_guest_delegate.h @@ -47,9 +47,8 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate, protected: // content::WebContentsObserver: - void DidCommitProvisionalLoadForFrame( - content::RenderFrameHost* render_frame_host, - const GURL& url, ui::PageTransition transition_type) override; + void DidFinishNavigation( + content::NavigationHandle* navigation_handle) override; // content::BrowserPluginGuestDelegate: void DidAttach(int guest_proxy_routing_id) final; diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index 63a9a3eb263d..07f0a0c48bfe 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -20,7 +20,6 @@ #include "atom/renderer/node_array_buffer_bridge.h" #include "atom/renderer/preferences_manager.h" #include "base/command_line.h" -#include "base/strings/utf_string_conversions.h" #include "chrome/renderer/media/chrome_key_systems.h" #include "chrome/renderer/pepper/pepper_helper.h" #include "chrome/renderer/printing/print_web_view_helper.h" @@ -32,7 +31,6 @@ #include "content/public/renderer/render_view.h" #include "ipc/ipc_message_macros.h" #include "native_mate/dictionary.h" -#include "net/base/net_errors.h" #include "third_party/WebKit/public/web/WebCustomElement.h" #include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebFrameWidget.h" @@ -322,16 +320,4 @@ void AtomRendererClient::AddKeySystems( AddChromeKeySystems(key_systems); } -void AtomRendererClient::GetNavigationErrorStrings( - content::RenderFrame* render_frame, - const blink::WebURLRequest& failed_request, - const blink::WebURLError& error, - std::string* error_html, - base::string16* error_description) { - if (!error_description) - return; - - *error_description = base::UTF8ToUTF16(net::ErrorToShortString(error.reason)); -} - } // namespace atom diff --git a/atom/renderer/atom_renderer_client.h b/atom/renderer/atom_renderer_client.h index f4a548908e06..9cf6eaa2a7ce 100644 --- a/atom/renderer/atom_renderer_client.h +++ b/atom/renderer/atom_renderer_client.h @@ -58,11 +58,6 @@ class AtomRendererClient : public content::ContentRendererClient { const std::string& mime_type, const GURL& original_url) override; void AddKeySystems(std::vector* key_systems) override; - void GetNavigationErrorStrings(content::RenderFrame* render_frame, - const blink::WebURLRequest& failed_request, - const blink::WebURLError& error, - std::string* error_html, - base::string16* error_description) override; std::unique_ptr node_bindings_; std::unique_ptr atom_bindings_;