|
47 | 47 | #include "content/public/browser/native_web_keyboard_event.h" |
48 | 48 | #include "content/public/browser/navigation_details.h" |
49 | 49 | #include "content/public/browser/navigation_entry.h" |
| 50 | +#include "content/public/browser/navigation_handle.h" |
50 | 51 | #include "content/public/browser/plugin_service.h" |
51 | 52 | #include "content/public/browser/render_frame_host.h" |
52 | 53 | #include "content/public/browser/render_process_host.h" |
@@ -603,20 +604,6 @@ void WebContents::DidFinishLoad(content::RenderFrameHost* render_frame_host, |
603 | 604 | Emit("did-finish-load"); |
604 | 605 | } |
605 | 606 |
|
606 | | -void WebContents::DidFailProvisionalLoad( |
607 | | - content::RenderFrameHost* render_frame_host, |
608 | | - const GURL& url, |
609 | | - int code, |
610 | | - const base::string16& description, |
611 | | - bool was_ignored_by_handler) { |
612 | | - bool is_main_frame = !render_frame_host->GetParent(); |
613 | | - Emit("did-fail-provisional-load", code, description, url, is_main_frame); |
614 | | - |
615 | | - // Do not emit "did-fail-load" for canceled requests. |
616 | | - if (code != net::ERR_ABORTED) |
617 | | - Emit("did-fail-load", code, description, url, is_main_frame); |
618 | | -} |
619 | | - |
620 | 607 | void WebContents::DidFailLoad(content::RenderFrameHost* render_frame_host, |
621 | 608 | const GURL& url, |
622 | 609 | int error_code, |
@@ -660,13 +647,27 @@ void WebContents::DidGetRedirectForResourceRequest( |
660 | 647 | details.headers.get()); |
661 | 648 | } |
662 | 649 |
|
663 | | -void WebContents::DidNavigateMainFrame( |
664 | | - const content::LoadCommittedDetails& details, |
665 | | - const content::FrameNavigateParams& params) { |
666 | | - if (details.is_navigation_to_different_page()) |
667 | | - Emit("did-navigate", params.url); |
668 | | - else if (details.is_in_page) |
669 | | - Emit("did-navigate-in-page", params.url); |
| 650 | +void WebContents::DidFinishNavigation( |
| 651 | + content::NavigationHandle* navigation_handle) { |
| 652 | + bool is_main_frame = navigation_handle->IsInMainFrame(); |
| 653 | + if (navigation_handle->HasCommitted() && !navigation_handle->IsErrorPage()) { |
| 654 | + auto url = navigation_handle->GetURL(); |
| 655 | + bool is_in_page = navigation_handle->IsSamePage(); |
| 656 | + if (is_main_frame && !is_in_page) { |
| 657 | + Emit("did-navigate", url); |
| 658 | + } else if (is_in_page) { |
| 659 | + Emit("did-navigate-in-page", url); |
| 660 | + } |
| 661 | + } else { |
| 662 | + auto url = navigation_handle->GetURL(); |
| 663 | + int code = navigation_handle->GetNetErrorCode(); |
| 664 | + auto description = net::ErrorToShortString(code); |
| 665 | + Emit("did-fail-provisional-load", code, description, url, is_main_frame); |
| 666 | + |
| 667 | + // Do not emit "did-fail-load" for canceled requests. |
| 668 | + if (code != net::ERR_ABORTED) |
| 669 | + Emit("did-fail-load", code, description, url, is_main_frame); |
| 670 | + } |
670 | 671 | } |
671 | 672 |
|
672 | 673 | void WebContents::TitleWasSet(content::NavigationEntry* entry, |
|
0 commit comments