webcontents: replace deprecated navigation observers

This commit is contained in:
deepak1556 2016-07-14 05:49:28 +05:30
parent 5d95b544dd
commit c8bf6edcc6
6 changed files with 34 additions and 55 deletions

View file

@ -47,6 +47,7 @@
#include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/navigation_details.h" #include "content/public/browser/navigation_details.h"
#include "content/public/browser/navigation_entry.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/plugin_service.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_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"); 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, void WebContents::DidFailLoad(content::RenderFrameHost* render_frame_host,
const GURL& url, const GURL& url,
int error_code, int error_code,
@ -665,13 +652,27 @@ void WebContents::DidGetRedirectForResourceRequest(
details.headers.get()); details.headers.get());
} }
void WebContents::DidNavigateMainFrame( void WebContents::DidFinishNavigation(
const content::LoadCommittedDetails& details, content::NavigationHandle* navigation_handle) {
const content::FrameNavigateParams& params) { bool is_main_frame = navigation_handle->IsInMainFrame();
if (details.is_navigation_to_different_page()) if (navigation_handle->HasCommitted() && !navigation_handle->IsErrorPage()) {
Emit("did-navigate", params.url); auto url = navigation_handle->GetURL();
else if (details.is_in_page) bool is_in_page = navigation_handle->IsSamePage();
Emit("did-navigate-in-page", params.url); 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, void WebContents::TitleWasSet(content::NavigationEntry* entry,

View file

@ -244,11 +244,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
int error_code, int error_code,
const base::string16& error_description, const base::string16& error_description,
bool was_ignored_by_handler) override; 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 DidStartLoading() override;
void DidStopLoading() override; void DidStopLoading() override;
void DidGetResourceResponseStart( void DidGetResourceResponseStart(
@ -256,9 +251,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
void DidGetRedirectForResourceRequest( void DidGetRedirectForResourceRequest(
content::RenderFrameHost* render_frame_host, content::RenderFrameHost* render_frame_host,
const content::ResourceRedirectDetails& details) override; const content::ResourceRedirectDetails& details) override;
void DidNavigateMainFrame( void DidFinishNavigation(
const content::LoadCommittedDetails& details, content::NavigationHandle* navigation_handle) override;
const content::FrameNavigateParams& params) override;
bool OnMessageReceived(const IPC::Message& message) override; bool OnMessageReceived(const IPC::Message& message) override;
void WebContentsDestroyed() override; void WebContentsDestroyed() override;
void NavigationEntryCommitted( void NavigationEntryCommitted(

View file

@ -7,6 +7,7 @@
#include "atom/browser/api/atom_api_web_contents.h" #include "atom/browser/api/atom_api_web_contents.h"
#include "atom/common/native_mate_converters/gurl_converter.h" #include "atom/common/native_mate_converters/gurl_converter.h"
#include "content/public/browser/guest_host.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_frame_host.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_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; auto_size_enabled_ = enable_auto_size;
} }
void WebViewGuestDelegate::DidCommitProvisionalLoadForFrame( void WebViewGuestDelegate::DidFinishNavigation(
content::RenderFrameHost* render_frame_host, content::NavigationHandle* navigation_handle) {
const GURL& url, ui::PageTransition transition_type) { if (navigation_handle->HasCommitted() && !navigation_handle->IsErrorPage()) {
api_web_contents_->Emit("load-commit", url, !render_frame_host->GetParent()); 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) { void WebViewGuestDelegate::DidAttach(int guest_proxy_routing_id) {

View file

@ -47,9 +47,8 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate,
protected: protected:
// content::WebContentsObserver: // content::WebContentsObserver:
void DidCommitProvisionalLoadForFrame( void DidFinishNavigation(
content::RenderFrameHost* render_frame_host, content::NavigationHandle* navigation_handle) override;
const GURL& url, ui::PageTransition transition_type) override;
// content::BrowserPluginGuestDelegate: // content::BrowserPluginGuestDelegate:
void DidAttach(int guest_proxy_routing_id) final; void DidAttach(int guest_proxy_routing_id) final;

View file

@ -20,7 +20,6 @@
#include "atom/renderer/node_array_buffer_bridge.h" #include "atom/renderer/node_array_buffer_bridge.h"
#include "atom/renderer/preferences_manager.h" #include "atom/renderer/preferences_manager.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/renderer/media/chrome_key_systems.h" #include "chrome/renderer/media/chrome_key_systems.h"
#include "chrome/renderer/pepper/pepper_helper.h" #include "chrome/renderer/pepper/pepper_helper.h"
#include "chrome/renderer/printing/print_web_view_helper.h" #include "chrome/renderer/printing/print_web_view_helper.h"
@ -32,7 +31,6 @@
#include "content/public/renderer/render_view.h" #include "content/public/renderer/render_view.h"
#include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_macros.h"
#include "native_mate/dictionary.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/WebCustomElement.h"
#include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebFrameWidget.h" #include "third_party/WebKit/public/web/WebFrameWidget.h"
@ -322,16 +320,4 @@ void AtomRendererClient::AddKeySystems(
AddChromeKeySystems(key_systems); 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 } // namespace atom

View file

@ -58,11 +58,6 @@ class AtomRendererClient : public content::ContentRendererClient {
const std::string& mime_type, const std::string& mime_type,
const GURL& original_url) override; const GURL& original_url) override;
void AddKeySystems(std::vector<media::KeySystemInfo>* key_systems) override; void AddKeySystems(std::vector<media::KeySystemInfo>* 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<NodeBindings> node_bindings_; std::unique_ptr<NodeBindings> node_bindings_;
std::unique_ptr<AtomBindings> atom_bindings_; std::unique_ptr<AtomBindings> atom_bindings_;