Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(639)

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 2385923002: Tell renderer which subframes have history items on back/forward. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 1039
1040 // RenderFrameImpl ---------------------------------------------------------- 1040 // RenderFrameImpl ----------------------------------------------------------
1041 RenderFrameImpl::RenderFrameImpl(const CreateParams& params) 1041 RenderFrameImpl::RenderFrameImpl(const CreateParams& params)
1042 : frame_(NULL), 1042 : frame_(NULL),
1043 is_main_frame_(true), 1043 is_main_frame_(true),
1044 in_browser_initiated_detach_(false), 1044 in_browser_initiated_detach_(false),
1045 in_frame_tree_(false), 1045 in_frame_tree_(false),
1046 render_view_(params.render_view->AsWeakPtr()), 1046 render_view_(params.render_view->AsWeakPtr()),
1047 routing_id_(params.routing_id), 1047 routing_id_(params.routing_id),
1048 proxy_routing_id_(MSG_ROUTING_NONE), 1048 proxy_routing_id_(MSG_ROUTING_NONE),
1049 browser_has_subtree_history_items_(false),
1050 #if defined(ENABLE_PLUGINS) 1049 #if defined(ENABLE_PLUGINS)
1051 plugin_power_saver_helper_(nullptr), 1050 plugin_power_saver_helper_(nullptr),
1052 plugin_find_handler_(nullptr), 1051 plugin_find_handler_(nullptr),
1053 #endif 1052 #endif
1054 cookie_jar_(this), 1053 cookie_jar_(this),
1055 selection_text_offset_(0), 1054 selection_text_offset_(0),
1056 selection_range_(gfx::Range::InvalidRange()), 1055 selection_range_(gfx::Range::InvalidRange()),
1057 handling_select_range_(false), 1056 handling_select_range_(false),
1058 notification_permission_dispatcher_(NULL), 1057 notification_permission_dispatcher_(NULL),
1059 web_user_media_client_(NULL), 1058 web_user_media_client_(NULL),
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 1169
1171 frame_ = web_frame; 1170 frame_ = web_frame;
1172 } 1171 }
1173 1172
1174 void RenderFrameImpl::Initialize() { 1173 void RenderFrameImpl::Initialize() {
1175 is_main_frame_ = !frame_->parent(); 1174 is_main_frame_ = !frame_->parent();
1176 1175
1177 RenderFrameImpl* parent_frame = RenderFrameImpl::FromWebFrame( 1176 RenderFrameImpl* parent_frame = RenderFrameImpl::FromWebFrame(
1178 frame_->parent()); 1177 frame_->parent());
1179 if (parent_frame) { 1178 if (parent_frame) {
1180 // Inherit knowledge of whether we need to consult the browser process for
1181 // a history item on the first navigation. This is inherited by further
1182 // subframes and cleared at didStopLoading.
1183 browser_has_subtree_history_items_ =
1184 parent_frame->browser_has_subtree_history_items_;
1185 is_using_lofi_ = parent_frame->IsUsingLoFi(); 1179 is_using_lofi_ = parent_frame->IsUsingLoFi();
1186 effective_connection_type_ = parent_frame->getEffectiveConnectionType(); 1180 effective_connection_type_ = parent_frame->getEffectiveConnectionType();
1187 } 1181 }
1188 1182
1189 bool is_tracing_rail = false; 1183 bool is_tracing_rail = false;
1190 bool is_tracing_navigation = false; 1184 bool is_tracing_navigation = false;
1191 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing_navigation); 1185 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing_navigation);
1192 TRACE_EVENT_CATEGORY_GROUP_ENABLED("rail", &is_tracing_rail); 1186 TRACE_EVENT_CATEGORY_GROUP_ENABLED("rail", &is_tracing_rail);
1193 if (is_tracing_rail || is_tracing_navigation) { 1187 if (is_tracing_rail || is_tracing_navigation) {
1194 int parent_id = GetRoutingIdForFrameOrProxy(frame_->parent()); 1188 int parent_id = GetRoutingIdForFrameOrProxy(frame_->parent());
(...skipping 3638 matching lines...) Expand 10 before | Expand all | Expand 10 after
4833 Send(new FrameHostMsg_DidStartLoading(routing_id_, to_different_document)); 4827 Send(new FrameHostMsg_DidStartLoading(routing_id_, to_different_document));
4834 } 4828 }
4835 4829
4836 void RenderFrameImpl::didStopLoading() { 4830 void RenderFrameImpl::didStopLoading() {
4837 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::didStopLoading", 4831 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::didStopLoading",
4838 "id", routing_id_); 4832 "id", routing_id_);
4839 4833
4840 // Any subframes created after this point won't be considered part of the 4834 // Any subframes created after this point won't be considered part of the
4841 // current history navigation (if this was one), so we don't need to track 4835 // current history navigation (if this was one), so we don't need to track
4842 // this state anymore. 4836 // this state anymore.
4843 browser_has_subtree_history_items_ = false; 4837 history_subframe_unique_names_.clear();
4844 4838
4845 render_view_->FrameDidStopLoading(frame_); 4839 render_view_->FrameDidStopLoading(frame_);
4846 Send(new FrameHostMsg_DidStopLoading(routing_id_)); 4840 Send(new FrameHostMsg_DidStopLoading(routing_id_));
4847 } 4841 }
4848 4842
4849 void RenderFrameImpl::didChangeLoadProgress(double load_progress) { 4843 void RenderFrameImpl::didChangeLoadProgress(double load_progress) {
4850 Send(new FrameHostMsg_DidChangeLoadProgress(routing_id_, load_progress)); 4844 Send(new FrameHostMsg_DidChangeLoadProgress(routing_id_, load_progress));
4851 } 4845 }
4852 4846
4853 void RenderFrameImpl::HandleWebAccessibilityEvent( 4847 void RenderFrameImpl::HandleWebAccessibilityEvent(
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
4976 if (is_content_initiated && IsTopLevelNavigation(frame_) && 4970 if (is_content_initiated && IsTopLevelNavigation(frame_) &&
4977 render_view_->renderer_preferences_ 4971 render_view_->renderer_preferences_
4978 .browser_handles_all_top_level_requests) { 4972 .browser_handles_all_top_level_requests) {
4979 OpenURL(url, IsHttpPost(info.urlRequest), 4973 OpenURL(url, IsHttpPost(info.urlRequest),
4980 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, 4974 GetRequestBodyForWebURLRequest(info.urlRequest), referrer,
4981 info.defaultPolicy, info.replacesCurrentHistoryItem, false); 4975 info.defaultPolicy, info.replacesCurrentHistoryItem, false);
4982 return blink::WebNavigationPolicyIgnore; // Suppress the load here. 4976 return blink::WebNavigationPolicyIgnore; // Suppress the load here.
4983 } 4977 }
4984 4978
4985 // In OOPIF-enabled modes, back/forward navigations in newly created subframes 4979 // In OOPIF-enabled modes, back/forward navigations in newly created subframes
4986 // should be sent to the browser if there is a chance there is a matching 4980 // should be sent to the browser if there is a matching FrameNavigationEntry.
4987 // FrameNavigationEntry. If none is found (or if the browser has indicated it 4981 // If this frame isn't on the list of unique names that have history items,
4988 // has no subtree history items), fall back to loading the default url. 4982 // fall back to loading the default url. (We remove each name as we encounter
4983 // it, because it will only be used once as the frame is created.)
4989 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && 4984 if (SiteIsolationPolicy::UseSubframeNavigationEntries() &&
4990 info.isHistoryNavigationInNewChildFrame && is_content_initiated && 4985 info.isHistoryNavigationInNewChildFrame && is_content_initiated &&
4991 browser_has_subtree_history_items_) { 4986 frame_->parent() &&
4987 RenderFrameImpl::FromWebFrame(frame_->parent())
4988 ->history_subframe_unique_names_.erase(
4989 frame_->uniqueName().utf8()) > 0) {
4992 // Don't do this if |info| also says it is a client redirect, in which case 4990 // Don't do this if |info| also says it is a client redirect, in which case
4993 // JavaScript on the page is trying to interrupt the history navigation. 4991 // JavaScript on the page is trying to interrupt the history navigation.
4994 if (!info.isClientRedirect) { 4992 if (!info.isClientRedirect) {
4995 OpenURL(url, IsHttpPost(info.urlRequest), 4993 OpenURL(url, IsHttpPost(info.urlRequest),
4996 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, 4994 GetRequestBodyForWebURLRequest(info.urlRequest), referrer,
4997 info.defaultPolicy, info.replacesCurrentHistoryItem, true); 4995 info.defaultPolicy, info.replacesCurrentHistoryItem, true);
4998 // Suppress the load in Blink but mark the frame as loading. 4996 // Suppress the load in Blink but mark the frame as loading.
4999 return blink::WebNavigationPolicyHandledByClient; 4997 return blink::WebNavigationPolicyHandledByClient;
5000 } else { 4998 } else {
5001 // Client redirects during an initial history load should attempt to 4999 // Client redirects during an initial history load should attempt to
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
5560 // PageState. 5558 // PageState.
5561 item_for_history_navigation = entry->root(); 5559 item_for_history_navigation = entry->root();
5562 history_load_type = request_params.is_same_document_history_load 5560 history_load_type = request_params.is_same_document_history_load
5563 ? blink::WebHistorySameDocumentLoad 5561 ? blink::WebHistorySameDocumentLoad
5564 : blink::WebHistoryDifferentDocumentLoad; 5562 : blink::WebHistoryDifferentDocumentLoad;
5565 load_type = request_params.is_history_navigation_in_new_child 5563 load_type = request_params.is_history_navigation_in_new_child
5566 ? blink::WebFrameLoadType::InitialHistoryLoad 5564 ? blink::WebFrameLoadType::InitialHistoryLoad
5567 : blink::WebFrameLoadType::BackForward; 5565 : blink::WebFrameLoadType::BackForward;
5568 should_load_request = true; 5566 should_load_request = true;
5569 5567
5570 // Remember whether we should consult the browser process for any 5568 // Keep track of which subframes the browser process has history items
5571 // subframes created during this history navigation. 5569 // for during a history navigation.
5572 browser_has_subtree_history_items_ = 5570 history_subframe_unique_names_ = request_params.subframe_unique_names;
5573 request_params.has_subtree_history_items;
5574 5571
5575 // If this is marked as a same document load but we haven't committed 5572 // If this is marked as a same document load but we haven't committed
5576 // anything, treat it as a new load. The browser shouldn't let this 5573 // anything, treat it as a new load. The browser shouldn't let this
5577 // happen. Also treat it as a new load, if the DSN in 5574 // happen. Also treat it as a new load, if the DSN in
5578 // |current_history_item_| and the item navigated to mismatch. 5575 // |current_history_item_| and the item navigated to mismatch.
5579 if (history_load_type == blink::WebHistorySameDocumentLoad) { 5576 if (history_load_type == blink::WebHistorySameDocumentLoad) {
5580 if (current_history_item_.isNull()) { 5577 if (current_history_item_.isNull()) {
5581 history_load_type = blink::WebHistoryDifferentDocumentLoad; 5578 history_load_type = blink::WebHistoryDifferentDocumentLoad;
5582 } else if (current_history_item_.documentSequenceNumber() != 5579 } else if (current_history_item_.documentSequenceNumber() !=
5583 item_for_history_navigation.documentSequenceNumber()) { 5580 item_for_history_navigation.documentSequenceNumber()) {
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
6402 // event target. Potentially a Pepper plugin will receive the event. 6399 // event target. Potentially a Pepper plugin will receive the event.
6403 // In order to tell whether a plugin gets the last mouse event and which it 6400 // In order to tell whether a plugin gets the last mouse event and which it
6404 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6401 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6405 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6402 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6406 // |pepper_last_mouse_event_target_|. 6403 // |pepper_last_mouse_event_target_|.
6407 pepper_last_mouse_event_target_ = nullptr; 6404 pepper_last_mouse_event_target_ = nullptr;
6408 #endif 6405 #endif
6409 } 6406 }
6410 6407
6411 } // namespace content 6408 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/test/data/navigation_controller/dynamic_iframe.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698