Chromium Code Reviews| 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)) { |
|
Charlie Reis
2016/09/30 22:54:42
Interesting. This is somewhat independent of the
jam
2016/09/30 23:07:50
yeah I looked for other usages of javascript schem
| |
| 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 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1026 frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload(); | 1027 frame_tree_node->current_frame_host()->ShouldDispatchBeforeUnload(); |
| 1027 FrameMsg_Navigate_Type::Value navigation_type = | 1028 FrameMsg_Navigate_Type::Value navigation_type = |
| 1028 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); | 1029 GetNavigationType(controller_->GetBrowserContext(), entry, reload_type); |
| 1029 std::unique_ptr<NavigationRequest> scoped_request = | 1030 std::unique_ptr<NavigationRequest> scoped_request = |
| 1030 NavigationRequest::CreateBrowserInitiated( | 1031 NavigationRequest::CreateBrowserInitiated( |
| 1031 frame_tree_node, dest_url, dest_referrer, frame_entry, entry, | 1032 frame_tree_node, dest_url, dest_referrer, frame_entry, entry, |
| 1032 navigation_type, lofi_state, is_same_document_history_load, | 1033 navigation_type, lofi_state, is_same_document_history_load, |
| 1033 is_history_navigation_in_new_child, navigation_start, controller_); | 1034 is_history_navigation_in_new_child, navigation_start, controller_); |
| 1034 NavigationRequest* navigation_request = scoped_request.get(); | 1035 NavigationRequest* navigation_request = scoped_request.get(); |
| 1035 | 1036 |
| 1036 // Navigation to a javascript URL is not a "real" navigation so there is no | 1037 // Navigation to a debug URLs is not a "real" navigation so there is no |
|
Charlie Reis
2016/09/30 22:54:42
nit: debug URL
jam
2016/09/30 23:07:50
Done.
| |
| 1037 // need to create a NavigationHandle. The navigation commits immediately and | 1038 // need to create a NavigationHandle. The navigation commits immediately and |
| 1038 // the NavigationRequest is not assigned to the FrameTreeNode as navigating to | 1039 // the NavigationRequest is not assigned to the FrameTreeNode as navigating to |
| 1039 // a Javascript URL should not interrupt a previous navigation. | 1040 // a debug URL should not interrupt a previous navigation. |
| 1040 // Note: The scoped_request will be destroyed at the end of this function. | 1041 // Note: The scoped_request will be destroyed at the end of this function. |
| 1041 if (dest_url.SchemeIs(url::kJavaScriptScheme)) { | 1042 if (IsRendererDebugURL(dest_url)) { |
| 1042 RenderFrameHostImpl* render_frame_host = | 1043 RenderFrameHostImpl* render_frame_host = |
| 1043 frame_tree_node->render_manager()->GetFrameHostForNavigation( | 1044 frame_tree_node->render_manager()->GetFrameHostForNavigation( |
| 1044 *navigation_request); | 1045 *navigation_request); |
| 1045 render_frame_host->CommitNavigation(nullptr, // response | 1046 render_frame_host->CommitNavigation(nullptr, // response |
| 1046 nullptr, // body | 1047 nullptr, // body |
| 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) { |
| 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 |