webcontents: replace deprecated navigation observers
This commit is contained in:
parent
5d95b544dd
commit
c8bf6edcc6
6 changed files with 34 additions and 55 deletions
|
@ -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"
|
||||
|
@ -608,20 +609,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,
|
||||
|
@ -665,13 +652,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,
|
||||
|
|
|
@ -244,11 +244,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
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(
|
||||
|
@ -256,9 +251,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
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(
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue