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

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

Issue 2550113002: Send a subtree of same-process PageStates for back/forward child frames.
Patch Set: Rebase Created 4 years 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
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3226 matching lines...) Expand 10 before | Expand all | Expand 10 after
3237 suggested_name)); 3237 suggested_name));
3238 } else { 3238 } else {
3239 OpenURL(request.url(), IsHttpPost(request), 3239 OpenURL(request.url(), IsHttpPost(request),
3240 GetRequestBodyForWebURLRequest(request), 3240 GetRequestBodyForWebURLRequest(request),
3241 GetWebURLRequestHeaders(request), referrer, policy, 3241 GetWebURLRequestHeaders(request), referrer, policy,
3242 should_replace_current_entry, false); 3242 should_replace_current_entry, false);
3243 } 3243 }
3244 } 3244 }
3245 3245
3246 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() { 3246 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame() {
3247 // OOPIF enabled modes will punt this navigation to the browser in 3247 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
3248 // decidePolicyForNavigation. 3248 // Check whether the browser process provided a history item to use for this
3249 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) 3249 // new frame. If not, return an empty WebHistoryItem and check with the
3250 // browser process in decidePolicyForNavigation.
3251 const std::string& unique_name = frame_->uniqueName().utf8();
3252 const auto& iter = render_view_->history_page_states_.find(unique_name);
3253 if (iter != render_view_->history_page_states_.end()) {
3254 const PageState& page_state = iter->second;
3255 // If the PageState is non-empty, use it as the history item to load. If
3256 // it is empty, it represents a cross-process history item. We'll ask the
3257 // browser process to handle it in decidePolicyForNavigation.
3258 if (page_state.IsValid()) {
3259 std::unique_ptr<HistoryEntry> entry =
3260 PageStateToHistoryEntry(page_state);
3261
3262 // Erase the entry now that we've used it (unlike the empty PageState
3263 // case).
3264 render_view_->history_page_states_.erase(unique_name);
3265
3266 return entry->root();
3267 }
3268 }
3269
3250 return WebHistoryItem(); 3270 return WebHistoryItem();
3271 }
3251 3272
3252 return render_view_->history_controller()->GetItemForNewChildFrame(this); 3273 return render_view_->history_controller()->GetItemForNewChildFrame(this);
3253 } 3274 }
3254 3275
3255 void RenderFrameImpl::willSendSubmitEvent(const blink::WebFormElement& form) { 3276 void RenderFrameImpl::willSendSubmitEvent(const blink::WebFormElement& form) {
3256 for (auto& observer : observers_) 3277 for (auto& observer : observers_)
3257 observer.WillSendSubmitEvent(form); 3278 observer.WillSendSubmitEvent(form);
3258 } 3279 }
3259 3280
3260 void RenderFrameImpl::willSubmitForm(const blink::WebFormElement& form) { 3281 void RenderFrameImpl::willSubmitForm(const blink::WebFormElement& form) {
(...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after
4976 // PlzNavigate: the browser is responsible for knowing the start of all 4997 // PlzNavigate: the browser is responsible for knowing the start of all
4977 // non-synchronous navigations. 4998 // non-synchronous navigations.
4978 if (!IsBrowserSideNavigationEnabled() || !to_different_document) 4999 if (!IsBrowserSideNavigationEnabled() || !to_different_document)
4979 Send(new FrameHostMsg_DidStartLoading(routing_id_, to_different_document)); 5000 Send(new FrameHostMsg_DidStartLoading(routing_id_, to_different_document));
4980 } 5001 }
4981 5002
4982 void RenderFrameImpl::didStopLoading() { 5003 void RenderFrameImpl::didStopLoading() {
4983 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::didStopLoading", 5004 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::didStopLoading",
4984 "id", routing_id_); 5005 "id", routing_id_);
4985 5006
4986 // Any subframes created after this point won't be considered part of the
4987 // current history navigation (if this was one), so we don't need to track
4988 // this state anymore.
4989 history_subframe_unique_names_.clear();
4990
4991 render_view_->FrameDidStopLoading(frame_); 5007 render_view_->FrameDidStopLoading(frame_);
4992 Send(new FrameHostMsg_DidStopLoading(routing_id_)); 5008 Send(new FrameHostMsg_DidStopLoading(routing_id_));
4993 } 5009 }
4994 5010
4995 void RenderFrameImpl::didChangeLoadProgress(double load_progress) { 5011 void RenderFrameImpl::didChangeLoadProgress(double load_progress) {
4996 Send(new FrameHostMsg_DidChangeLoadProgress(routing_id_, load_progress)); 5012 Send(new FrameHostMsg_DidChangeLoadProgress(routing_id_, load_progress));
4997 } 5013 }
4998 5014
4999 void RenderFrameImpl::HandleWebAccessibilityEvent( 5015 void RenderFrameImpl::HandleWebAccessibilityEvent(
5000 const blink::WebAXObject& obj, blink::WebAXEvent event) { 5016 const blink::WebAXObject& obj, blink::WebAXEvent event) {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
5147 if (is_content_initiated && IsTopLevelNavigation(frame_) && 5163 if (is_content_initiated && IsTopLevelNavigation(frame_) &&
5148 render_view_->renderer_preferences_ 5164 render_view_->renderer_preferences_
5149 .browser_handles_all_top_level_requests) { 5165 .browser_handles_all_top_level_requests) {
5150 OpenURL(url, IsHttpPost(info.urlRequest), 5166 OpenURL(url, IsHttpPost(info.urlRequest),
5151 GetRequestBodyForWebURLRequest(info.urlRequest), 5167 GetRequestBodyForWebURLRequest(info.urlRequest),
5152 GetWebURLRequestHeaders(info.urlRequest), referrer, 5168 GetWebURLRequestHeaders(info.urlRequest), referrer,
5153 info.defaultPolicy, info.replacesCurrentHistoryItem, false); 5169 info.defaultPolicy, info.replacesCurrentHistoryItem, false);
5154 return blink::WebNavigationPolicyIgnore; // Suppress the load here. 5170 return blink::WebNavigationPolicyIgnore; // Suppress the load here.
5155 } 5171 }
5156 5172
5157 // In OOPIF-enabled modes, back/forward navigations in newly created subframes 5173 // Back/forward navigations in newly created subframes should be sent to the
5158 // should be sent to the browser if there is a matching FrameNavigationEntry, 5174 // browser process if there is a matching unique name in the PageState map but
5159 // and if it isn't just staying at about:blank. If this frame isn't in the 5175 // the PageState is empty. This is a signal that the browser process has a
5160 // map of unique names that have history items, or if it's staying at the 5176 // FrameNavigationEntry for it but that it will load in a different process.
5161 // initial about:blank URL, fall back to loading the default url. (We remove 5177 // We remove each name as we encounter it, because it will only be used once
5162 // each name as we encounter it, because it will only be used once as the 5178 // as the frame is created.
5163 // frame is created.) 5179 //
5180 // If this frame isn't in the map (or has already been removed during
5181 // historyItemForNewChildFrame), allow the navigation to continue. For frames
5182 // that were never in the map, this effectively falls back to loading the
5183 // default URL for the frame.
5164 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && 5184 if (SiteIsolationPolicy::UseSubframeNavigationEntries() &&
5165 info.isHistoryNavigationInNewChildFrame && is_content_initiated && 5185 info.isHistoryNavigationInNewChildFrame && is_content_initiated &&
5166 frame_->parent()) { 5186 frame_->parent()) {
5167 // Check whether the browser has a history item for this frame that isn't 5187 // Check whether the browser process sent an empty PageState for this frame,
5168 // just staying at the initial about:blank document. 5188 // indicating that it should load in a different process.
5169 bool should_ask_browser = false; 5189 bool should_ask_browser = false;
5170 RenderFrameImpl* parent = RenderFrameImpl::FromWebFrame(frame_->parent()); 5190 const std::string& unique_name = frame_->uniqueName().utf8();
5171 const auto& iter = parent->history_subframe_unique_names_.find( 5191 const auto& iter = render_view_->history_page_states_.find(unique_name);
5172 frame_->uniqueName().utf8()); 5192 if (iter != render_view_->history_page_states_.end()) {
5173 if (iter != parent->history_subframe_unique_names_.end()) { 5193 const PageState& page_state = iter->second;
5174 bool history_item_is_about_blank = iter->second; 5194
5175 should_ask_browser = 5195 // If the PageState were valid, we should have used and removed it in
5176 !history_item_is_about_blank || url != url::kAboutBlankURL; 5196 // historyItemForNewChildFrame.
5177 parent->history_subframe_unique_names_.erase(frame_->uniqueName().utf8()); 5197 DCHECK(!page_state.IsValid());
5198
5199 should_ask_browser = !page_state.IsValid();
5200 render_view_->history_page_states_.erase(unique_name);
5178 } 5201 }
5179 5202
5180 if (should_ask_browser) { 5203 if (should_ask_browser) {
5181 // Don't do this if |info| also says it is a client redirect, in which 5204 // Don't do this if |info| also says it is a client redirect, in which
5182 // case JavaScript on the page is trying to interrupt the history 5205 // case JavaScript on the page is trying to interrupt the history
5183 // navigation. 5206 // navigation.
5184 if (!info.isClientRedirect) { 5207 if (!info.isClientRedirect) {
5185 OpenURL(url, IsHttpPost(info.urlRequest), 5208 OpenURL(url, IsHttpPost(info.urlRequest),
5186 GetRequestBodyForWebURLRequest(info.urlRequest), 5209 GetRequestBodyForWebURLRequest(info.urlRequest),
5187 GetWebURLRequestHeaders(info.urlRequest), referrer, 5210 GetWebURLRequestHeaders(info.urlRequest), referrer,
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
5820 item_for_history_navigation = entry->root(); 5843 item_for_history_navigation = entry->root();
5821 history_load_type = request_params.is_same_document_history_load 5844 history_load_type = request_params.is_same_document_history_load
5822 ? blink::WebHistorySameDocumentLoad 5845 ? blink::WebHistorySameDocumentLoad
5823 : blink::WebHistoryDifferentDocumentLoad; 5846 : blink::WebHistoryDifferentDocumentLoad;
5824 load_type = request_params.is_history_navigation_in_new_child 5847 load_type = request_params.is_history_navigation_in_new_child
5825 ? blink::WebFrameLoadType::InitialHistoryLoad 5848 ? blink::WebFrameLoadType::InitialHistoryLoad
5826 : blink::WebFrameLoadType::BackForward; 5849 : blink::WebFrameLoadType::BackForward;
5827 should_load_request = true; 5850 should_load_request = true;
5828 5851
5829 // Keep track of which subframes the browser process has history items 5852 // Keep track of which subframes the browser process has history items
5830 // for during a history navigation. 5853 // for during a history navigation (in addition to any existing ones,
5831 history_subframe_unique_names_ = request_params.subframe_unique_names; 5854 // overwriting any stale entries).
5855 for (const auto& iter : request_params.subtree_page_states)
5856 render_view_->history_page_states_[iter.first] = iter.second;
5832 5857
5833 if (history_load_type == blink::WebHistorySameDocumentLoad) { 5858 if (history_load_type == blink::WebHistorySameDocumentLoad) {
5834 // If this is marked as a same document load but we haven't committed 5859 // If this is marked as a same document load but we haven't committed
5835 // anything, treat it as a new load. The browser shouldn't let this 5860 // anything, treat it as a new load. The browser shouldn't let this
5836 // happen. 5861 // happen.
5837 if (current_history_item_.isNull()) { 5862 if (current_history_item_.isNull()) {
5838 history_load_type = blink::WebHistoryDifferentDocumentLoad; 5863 history_load_type = blink::WebHistoryDifferentDocumentLoad;
5839 NOTREACHED(); 5864 NOTREACHED();
5840 } else { 5865 } else {
5841 // Additionally, if the |current_history_item_|'s document 5866 // Additionally, if the |current_history_item_|'s document
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
6681 // event target. Potentially a Pepper plugin will receive the event. 6706 // event target. Potentially a Pepper plugin will receive the event.
6682 // In order to tell whether a plugin gets the last mouse event and which it 6707 // In order to tell whether a plugin gets the last mouse event and which it
6683 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6708 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6684 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6709 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6685 // |pepper_last_mouse_event_target_|. 6710 // |pepper_last_mouse_event_target_|.
6686 pepper_last_mouse_event_target_ = nullptr; 6711 pepper_last_mouse_event_target_ = nullptr;
6687 #endif 6712 #endif
6688 } 6713 }
6689 6714
6690 } // namespace content 6715 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698