add did-frame-navigate event to WebContents (#12723)

* add did-frame-navigate event to WebContents, pass http response code to it and did-navigate

* docs for frame routing id related api changes on WebFrame and WebContents
This commit is contained in:
bughit 2018-05-01 00:34:41 -04:00 committed by Cheng Zhao
parent c67d1b62e3
commit 55a7f6f0ce
5 changed files with 87 additions and 8 deletions

View file

@ -955,14 +955,31 @@ void WebContents::DidFinishNavigation(
if (!navigation_handle->IsErrorPage()) {
auto url = navigation_handle->GetURL();
bool is_same_document = navigation_handle->IsSameDocument();
if (is_main_frame && !is_same_document) {
Emit("did-navigate", url);
} else if (is_same_document) {
if (is_same_document) {
Emit("did-navigate-in-page",
url,
is_main_frame,
frame_process_id,
frame_routing_id);
} else {
const net::HttpResponseHeaders* http_response
= navigation_handle->GetResponseHeaders();
std::string http_status_text;
int http_response_code = -1;
if (http_response) {
http_status_text = http_response->GetStatusText();
http_response_code = http_response->response_code();
}
Emit("did-frame-navigate",
url,
http_response_code,
http_status_text,
is_main_frame,
frame_process_id,
frame_routing_id);
if (is_main_frame) {
Emit("did-navigate", url, http_response_code, http_status_text);
}
}
} else {
auto url = navigation_handle->GetURL();