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/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 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1036 | 1036 |
1037 // RenderFrameImpl ---------------------------------------------------------- | 1037 // RenderFrameImpl ---------------------------------------------------------- |
1038 RenderFrameImpl::RenderFrameImpl(const CreateParams& params) | 1038 RenderFrameImpl::RenderFrameImpl(const CreateParams& params) |
1039 : frame_(NULL), | 1039 : frame_(NULL), |
1040 is_main_frame_(true), | 1040 is_main_frame_(true), |
1041 in_browser_initiated_detach_(false), | 1041 in_browser_initiated_detach_(false), |
1042 in_frame_tree_(false), | 1042 in_frame_tree_(false), |
1043 render_view_(params.render_view->AsWeakPtr()), | 1043 render_view_(params.render_view->AsWeakPtr()), |
1044 routing_id_(params.routing_id), | 1044 routing_id_(params.routing_id), |
1045 proxy_routing_id_(MSG_ROUTING_NONE), | 1045 proxy_routing_id_(MSG_ROUTING_NONE), |
1046 browser_has_subtree_history_items_(false), | |
alexmos
2016/09/22 01:44:06
I was thinking whether "true" might be a safer def
Charlie Reis
2016/09/22 21:00:37
Right. I think this is a smaller delta from where
| |
1046 #if defined(ENABLE_PLUGINS) | 1047 #if defined(ENABLE_PLUGINS) |
1047 plugin_power_saver_helper_(nullptr), | 1048 plugin_power_saver_helper_(nullptr), |
1048 plugin_find_handler_(nullptr), | 1049 plugin_find_handler_(nullptr), |
1049 #endif | 1050 #endif |
1050 cookie_jar_(this), | 1051 cookie_jar_(this), |
1051 selection_text_offset_(0), | 1052 selection_text_offset_(0), |
1052 selection_range_(gfx::Range::InvalidRange()), | 1053 selection_range_(gfx::Range::InvalidRange()), |
1053 handling_select_range_(false), | 1054 handling_select_range_(false), |
1054 web_user_media_client_(NULL), | 1055 web_user_media_client_(NULL), |
1055 #if defined(OS_ANDROID) | 1056 #if defined(OS_ANDROID) |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1166 | 1167 |
1167 frame_ = web_frame; | 1168 frame_ = web_frame; |
1168 } | 1169 } |
1169 | 1170 |
1170 void RenderFrameImpl::Initialize() { | 1171 void RenderFrameImpl::Initialize() { |
1171 is_main_frame_ = !frame_->parent(); | 1172 is_main_frame_ = !frame_->parent(); |
1172 | 1173 |
1173 RenderFrameImpl* parent_frame = RenderFrameImpl::FromWebFrame( | 1174 RenderFrameImpl* parent_frame = RenderFrameImpl::FromWebFrame( |
1174 frame_->parent()); | 1175 frame_->parent()); |
1175 if (parent_frame) { | 1176 if (parent_frame) { |
1177 // Inherit knowledge of whether we need to consult the browser process for | |
1178 // a history item on the first navigation. This is inherited by further | |
1179 // subframes and cleared at didStopLoading. | |
1180 browser_has_subtree_history_items_ = | |
1181 parent_frame->browser_has_subtree_history_items_; | |
1176 is_using_lofi_ = parent_frame->IsUsingLoFi(); | 1182 is_using_lofi_ = parent_frame->IsUsingLoFi(); |
1177 effective_connection_type_ = parent_frame->getEffectiveConnectionType(); | 1183 effective_connection_type_ = parent_frame->getEffectiveConnectionType(); |
1178 } | 1184 } |
1179 | 1185 |
1180 bool is_tracing_rail = false; | 1186 bool is_tracing_rail = false; |
1181 bool is_tracing_navigation = false; | 1187 bool is_tracing_navigation = false; |
1182 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing_navigation); | 1188 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing_navigation); |
1183 TRACE_EVENT_CATEGORY_GROUP_ENABLED("rail", &is_tracing_rail); | 1189 TRACE_EVENT_CATEGORY_GROUP_ENABLED("rail", &is_tracing_rail); |
1184 if (is_tracing_rail || is_tracing_navigation) { | 1190 if (is_tracing_rail || is_tracing_navigation) { |
1185 int parent_id = GetRoutingIdForFrameOrProxy(frame_->parent()); | 1191 int parent_id = GetRoutingIdForFrameOrProxy(frame_->parent()); |
(...skipping 3641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4827 | 4833 |
4828 // PlzNavigate: the browser is responsible for knowing the start of all | 4834 // PlzNavigate: the browser is responsible for knowing the start of all |
4829 // non-synchronous navigations. | 4835 // non-synchronous navigations. |
4830 if (!IsBrowserSideNavigationEnabled() || !to_different_document) | 4836 if (!IsBrowserSideNavigationEnabled() || !to_different_document) |
4831 Send(new FrameHostMsg_DidStartLoading(routing_id_, to_different_document)); | 4837 Send(new FrameHostMsg_DidStartLoading(routing_id_, to_different_document)); |
4832 } | 4838 } |
4833 | 4839 |
4834 void RenderFrameImpl::didStopLoading() { | 4840 void RenderFrameImpl::didStopLoading() { |
4835 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::didStopLoading", | 4841 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::didStopLoading", |
4836 "id", routing_id_); | 4842 "id", routing_id_); |
4843 | |
4844 // Any subframes created after this point won't be considered part of the | |
4845 // current history navigation (if this was one), so we don't need to track | |
4846 // this state anymore. | |
4847 browser_has_subtree_history_items_ = false; | |
alexmos
2016/09/22 01:44:06
This will be reset in all frames, since main frame
Charlie Reis
2016/09/22 21:00:37
Exactly. The newly created child frame checks to
| |
4848 | |
4837 render_view_->FrameDidStopLoading(frame_); | 4849 render_view_->FrameDidStopLoading(frame_); |
4838 Send(new FrameHostMsg_DidStopLoading(routing_id_)); | 4850 Send(new FrameHostMsg_DidStopLoading(routing_id_)); |
4839 } | 4851 } |
4840 | 4852 |
4841 void RenderFrameImpl::didChangeLoadProgress(double load_progress) { | 4853 void RenderFrameImpl::didChangeLoadProgress(double load_progress) { |
4842 Send(new FrameHostMsg_DidChangeLoadProgress(routing_id_, load_progress)); | 4854 Send(new FrameHostMsg_DidChangeLoadProgress(routing_id_, load_progress)); |
4843 } | 4855 } |
4844 | 4856 |
4845 void RenderFrameImpl::HandleWebAccessibilityEvent( | 4857 void RenderFrameImpl::HandleWebAccessibilityEvent( |
4846 const blink::WebAXObject& obj, blink::WebAXEvent event) { | 4858 const blink::WebAXObject& obj, blink::WebAXEvent event) { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4971 if (is_content_initiated && IsTopLevelNavigation(frame_) && | 4983 if (is_content_initiated && IsTopLevelNavigation(frame_) && |
4972 render_view_->renderer_preferences_ | 4984 render_view_->renderer_preferences_ |
4973 .browser_handles_all_top_level_requests) { | 4985 .browser_handles_all_top_level_requests) { |
4974 OpenURL(url, IsHttpPost(info.urlRequest), | 4986 OpenURL(url, IsHttpPost(info.urlRequest), |
4975 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, | 4987 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, |
4976 info.defaultPolicy, info.replacesCurrentHistoryItem, false); | 4988 info.defaultPolicy, info.replacesCurrentHistoryItem, false); |
4977 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 4989 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
4978 } | 4990 } |
4979 | 4991 |
4980 // In OOPIF-enabled modes, back/forward navigations in newly created subframes | 4992 // In OOPIF-enabled modes, back/forward navigations in newly created subframes |
4981 // should be sent to the browser in case there is a matching | 4993 // should be sent to the browser if there is a chance there is a matching |
4982 // FrameNavigationEntry. If none is found, fall back to the default url. | 4994 // FrameNavigationEntry. If none is found (or if the browser has indicated it |
4995 // has no subtree history items), fall back to loading the default url. | |
4983 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && | 4996 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && |
4984 info.isHistoryNavigationInNewChildFrame && is_content_initiated) { | 4997 info.isHistoryNavigationInNewChildFrame && is_content_initiated && |
4998 browser_has_subtree_history_items_) { | |
4985 // Don't do this if |info| also says it is a client redirect, in which case | 4999 // Don't do this if |info| also says it is a client redirect, in which case |
4986 // JavaScript on the page is trying to interrupt the history navigation. | 5000 // JavaScript on the page is trying to interrupt the history navigation. |
4987 if (!info.isClientRedirect) { | 5001 if (!info.isClientRedirect) { |
4988 OpenURL(url, IsHttpPost(info.urlRequest), | 5002 OpenURL(url, IsHttpPost(info.urlRequest), |
4989 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, | 5003 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, |
4990 info.defaultPolicy, info.replacesCurrentHistoryItem, true); | 5004 info.defaultPolicy, info.replacesCurrentHistoryItem, true); |
4991 // Suppress the load in Blink but mark the frame as loading. | 5005 // Suppress the load in Blink but mark the frame as loading. |
4992 return blink::WebNavigationPolicyHandledByClient; | 5006 return blink::WebNavigationPolicyHandledByClient; |
4993 } else { | 5007 } else { |
4994 // Client redirects during an initial history load should attempt to | 5008 // Client redirects during an initial history load should attempt to |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5570 // PageState. | 5584 // PageState. |
5571 item_for_history_navigation = entry->root(); | 5585 item_for_history_navigation = entry->root(); |
5572 history_load_type = request_params.is_same_document_history_load | 5586 history_load_type = request_params.is_same_document_history_load |
5573 ? blink::WebHistorySameDocumentLoad | 5587 ? blink::WebHistorySameDocumentLoad |
5574 : blink::WebHistoryDifferentDocumentLoad; | 5588 : blink::WebHistoryDifferentDocumentLoad; |
5575 load_type = request_params.is_history_navigation_in_new_child | 5589 load_type = request_params.is_history_navigation_in_new_child |
5576 ? blink::WebFrameLoadType::InitialHistoryLoad | 5590 ? blink::WebFrameLoadType::InitialHistoryLoad |
5577 : blink::WebFrameLoadType::BackForward; | 5591 : blink::WebFrameLoadType::BackForward; |
5578 should_load_request = true; | 5592 should_load_request = true; |
5579 | 5593 |
5594 // Remember whether we should consult the browser process for any | |
5595 // subframes created during this history navigation. | |
5596 browser_has_subtree_history_items_ = | |
5597 request_params.has_subtree_history_items; | |
5598 | |
5580 if (history_load_type == blink::WebHistorySameDocumentLoad) { | 5599 if (history_load_type == blink::WebHistorySameDocumentLoad) { |
5581 // If this is marked as a same document load but we haven't committed | 5600 // If this is marked as a same document load but we haven't committed |
5582 // anything, treat it as a new load. The browser shouldn't let this | 5601 // anything, treat it as a new load. The browser shouldn't let this |
5583 // happen. | 5602 // happen. |
5584 if (current_history_item_.isNull()) { | 5603 if (current_history_item_.isNull()) { |
5585 history_load_type = blink::WebHistoryDifferentDocumentLoad; | 5604 history_load_type = blink::WebHistoryDifferentDocumentLoad; |
5586 NOTREACHED(); | 5605 NOTREACHED(); |
5587 } else { | 5606 } else { |
5588 // Additionally, if the |current_history_item_|'s document | 5607 // Additionally, if the |current_history_item_|'s document |
5589 // sequence number doesn't match the one sent from the browser, it | 5608 // sequence number doesn't match the one sent from the browser, it |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6398 // event target. Potentially a Pepper plugin will receive the event. | 6417 // event target. Potentially a Pepper plugin will receive the event. |
6399 // In order to tell whether a plugin gets the last mouse event and which it | 6418 // In order to tell whether a plugin gets the last mouse event and which it |
6400 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6419 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6401 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6420 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6402 // |pepper_last_mouse_event_target_|. | 6421 // |pepper_last_mouse_event_target_|. |
6403 pepper_last_mouse_event_target_ = nullptr; | 6422 pepper_last_mouse_event_target_ = nullptr; |
6404 #endif | 6423 #endif |
6405 } | 6424 } |
6406 | 6425 |
6407 } // namespace content | 6426 } // namespace content |
OLD | NEW |