| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/frame_host/navigator_impl.h" | 5 #include "content/browser/frame_host/navigator_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "content/browser/frame_host/debug_urls.h" |
| 12 #include "content/browser/frame_host/frame_tree.h" | 13 #include "content/browser/frame_host/frame_tree.h" |
| 13 #include "content/browser/frame_host/frame_tree_node.h" | 14 #include "content/browser/frame_host/frame_tree_node.h" |
| 14 #include "content/browser/frame_host/navigation_controller_impl.h" | 15 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 15 #include "content/browser/frame_host/navigation_entry_impl.h" | 16 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 16 #include "content/browser/frame_host/navigation_handle_impl.h" | 17 #include "content/browser/frame_host/navigation_handle_impl.h" |
| 17 #include "content/browser/frame_host/navigation_request.h" | 18 #include "content/browser/frame_host/navigation_request.h" |
| 18 #include "content/browser/frame_host/navigation_request_info.h" | 19 #include "content/browser/frame_host/navigation_request_info.h" |
| 19 #include "content/browser/frame_host/navigator_delegate.h" | 20 #include "content/browser/frame_host/navigator_delegate.h" |
| 20 #include "content/browser/frame_host/render_frame_host_impl.h" | 21 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 21 #include "content/browser/renderer_host/render_view_host_impl.h" | 22 #include "content/browser/renderer_host/render_view_host_impl.h" |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 controller_->GetLastCommittedEntryIndex(), | 404 controller_->GetLastCommittedEntryIndex(), |
| 404 controller_->GetEntryCount())); | 405 controller_->GetEntryCount())); |
| 405 } | 406 } |
| 406 } | 407 } |
| 407 | 408 |
| 408 // Make sure no code called via RFH::Navigate clears the pending entry. | 409 // Make sure no code called via RFH::Navigate clears the pending entry. |
| 409 if (is_pending_entry) | 410 if (is_pending_entry) |
| 410 CHECK_EQ(controller_->GetPendingEntry(), &entry); | 411 CHECK_EQ(controller_->GetPendingEntry(), &entry); |
| 411 | 412 |
| 412 if (controller_->GetPendingEntryIndex() == -1 && | 413 if (controller_->GetPendingEntryIndex() == -1 && |
| 413 dest_url.SchemeIs(url::kJavaScriptScheme)) { | 414 IsRendererDebugURL(dest_url)) { |
| 414 // If the pending entry index is -1 (which means a new navigation rather | 415 // If the pending entry index is -1 (which means a new navigation rather |
| 415 // than a history one), and the user typed in a javascript: URL, don't add | 416 // than a history one), and the user typed in a debug URL, don't add it to |
| 416 // it to the session history. | 417 // the session history. |
| 417 // | 418 // |
| 418 // This is a hack. What we really want is to avoid adding to the history any | 419 // This is a hack. What we really want is to avoid adding to the history any |
| 419 // URL that doesn't generate content, and what would be great would be if we | 420 // URL that doesn't generate content, and what would be great would be if we |
| 420 // had a message from the renderer telling us that a new page was not | 421 // had a message from the renderer telling us that a new page was not |
| 421 // created. The same message could be used for mailto: URLs and the like. | 422 // created. The same message could be used for mailto: URLs and the like. |
| 422 return false; | 423 return false; |
| 423 } | 424 } |
| 424 | 425 |
| 425 // Notify observers about navigation. | 426 // Notify observers about navigation. |
| 426 if (delegate_ && is_pending_entry) | 427 if (delegate_ && is_pending_entry) |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 navigation_request->common_params(), | 1048 navigation_request->common_params(), |
| 1048 navigation_request->request_params(), | 1049 navigation_request->request_params(), |
| 1049 navigation_request->is_view_source()); | 1050 navigation_request->is_view_source()); |
| 1050 return; | 1051 return; |
| 1051 } | 1052 } |
| 1052 | 1053 |
| 1053 frame_tree_node->CreatedNavigationRequest(std::move(scoped_request)); | 1054 frame_tree_node->CreatedNavigationRequest(std::move(scoped_request)); |
| 1054 navigation_request->CreateNavigationHandle(entry.GetUniqueID()); | 1055 navigation_request->CreateNavigationHandle(entry.GetUniqueID()); |
| 1055 | 1056 |
| 1056 // Have the current renderer execute its beforeunload event if needed. If it | 1057 // Have the current renderer execute its beforeunload event if needed. If it |
| 1057 // is not needed (when beforeunload dispatch is not needed or this navigation | 1058 // is not needed then NavigationRequest::BeginNavigation should be directly |
| 1058 // is synchronous and same-site) then NavigationRequest::BeginNavigation | 1059 // called instead. |
| 1059 // should be directly called instead. | 1060 if (should_dispatch_beforeunload && !IsRendererDebugURL(dest_url)) { |
| 1060 if (should_dispatch_beforeunload && | |
| 1061 ShouldMakeNetworkRequestForURL( | |
| 1062 navigation_request->common_params().url)) { | |
| 1063 navigation_request->SetWaitingForRendererResponse(); | 1061 navigation_request->SetWaitingForRendererResponse(); |
| 1064 frame_tree_node->current_frame_host()->DispatchBeforeUnload( | 1062 frame_tree_node->current_frame_host()->DispatchBeforeUnload( |
| 1065 true, reload_type != ReloadType::NONE); | 1063 true, reload_type != ReloadType::NONE); |
| 1066 } else { | 1064 } else { |
| 1067 navigation_request->BeginNavigation(); | 1065 navigation_request->BeginNavigation(); |
| 1068 } | 1066 } |
| 1069 } | 1067 } |
| 1070 | 1068 |
| 1071 void NavigatorImpl::RecordNavigationMetrics( | 1069 void NavigatorImpl::RecordNavigationMetrics( |
| 1072 const LoadCommittedDetails& details, | 1070 const LoadCommittedDetails& details, |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 if (pending_entry != controller_->GetVisibleEntry() || | 1199 if (pending_entry != controller_->GetVisibleEntry() || |
| 1202 !should_preserve_entry) { | 1200 !should_preserve_entry) { |
| 1203 controller_->DiscardPendingEntry(true); | 1201 controller_->DiscardPendingEntry(true); |
| 1204 | 1202 |
| 1205 // Also force the UI to refresh. | 1203 // Also force the UI to refresh. |
| 1206 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); | 1204 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); |
| 1207 } | 1205 } |
| 1208 } | 1206 } |
| 1209 | 1207 |
| 1210 } // namespace content | 1208 } // namespace content |
| OLD | NEW |