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), | |
1047 #if defined(ENABLE_PLUGINS) | 1046 #if defined(ENABLE_PLUGINS) |
1048 plugin_power_saver_helper_(nullptr), | 1047 plugin_power_saver_helper_(nullptr), |
1049 plugin_find_handler_(nullptr), | 1048 plugin_find_handler_(nullptr), |
1050 #endif | 1049 #endif |
1051 cookie_jar_(this), | 1050 cookie_jar_(this), |
1052 selection_text_offset_(0), | 1051 selection_text_offset_(0), |
1053 selection_range_(gfx::Range::InvalidRange()), | 1052 selection_range_(gfx::Range::InvalidRange()), |
1054 handling_select_range_(false), | 1053 handling_select_range_(false), |
1055 web_user_media_client_(NULL), | 1054 web_user_media_client_(NULL), |
1056 #if defined(OS_ANDROID) | 1055 #if defined(OS_ANDROID) |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 | 1158 |
1160 frame_ = web_frame; | 1159 frame_ = web_frame; |
1161 } | 1160 } |
1162 | 1161 |
1163 void RenderFrameImpl::Initialize() { | 1162 void RenderFrameImpl::Initialize() { |
1164 is_main_frame_ = !frame_->parent(); | 1163 is_main_frame_ = !frame_->parent(); |
1165 | 1164 |
1166 RenderFrameImpl* parent_frame = RenderFrameImpl::FromWebFrame( | 1165 RenderFrameImpl* parent_frame = RenderFrameImpl::FromWebFrame( |
1167 frame_->parent()); | 1166 frame_->parent()); |
1168 if (parent_frame) { | 1167 if (parent_frame) { |
1169 // Inherit knowledge of whether we need to consult the browser process for | |
1170 // a history item on the first navigation. This is inherited by further | |
1171 // subframes and cleared at didStopLoading. | |
1172 browser_has_subtree_history_items_ = | |
1173 parent_frame->browser_has_subtree_history_items_; | |
1174 is_using_lofi_ = parent_frame->IsUsingLoFi(); | 1168 is_using_lofi_ = parent_frame->IsUsingLoFi(); |
1175 effective_connection_type_ = parent_frame->getEffectiveConnectionType(); | 1169 effective_connection_type_ = parent_frame->getEffectiveConnectionType(); |
1176 } | 1170 } |
1177 | 1171 |
1178 bool is_tracing_rail = false; | 1172 bool is_tracing_rail = false; |
1179 bool is_tracing_navigation = false; | 1173 bool is_tracing_navigation = false; |
1180 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing_navigation); | 1174 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing_navigation); |
1181 TRACE_EVENT_CATEGORY_GROUP_ENABLED("rail", &is_tracing_rail); | 1175 TRACE_EVENT_CATEGORY_GROUP_ENABLED("rail", &is_tracing_rail); |
1182 if (is_tracing_rail || is_tracing_navigation) { | 1176 if (is_tracing_rail || is_tracing_navigation) { |
1183 int parent_id = GetRoutingIdForFrameOrProxy(frame_->parent()); | 1177 int parent_id = GetRoutingIdForFrameOrProxy(frame_->parent()); |
(...skipping 3653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4837 Send(new FrameHostMsg_DidStartLoading(routing_id_, to_different_document)); | 4831 Send(new FrameHostMsg_DidStartLoading(routing_id_, to_different_document)); |
4838 } | 4832 } |
4839 | 4833 |
4840 void RenderFrameImpl::didStopLoading() { | 4834 void RenderFrameImpl::didStopLoading() { |
4841 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::didStopLoading", | 4835 TRACE_EVENT1("navigation,rail", "RenderFrameImpl::didStopLoading", |
4842 "id", routing_id_); | 4836 "id", routing_id_); |
4843 | 4837 |
4844 // Any subframes created after this point won't be considered part of the | 4838 // 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 | 4839 // current history navigation (if this was one), so we don't need to track |
4846 // this state anymore. | 4840 // this state anymore. |
4847 browser_has_subtree_history_items_ = false; | 4841 history_subframe_unique_names_.clear(); |
4848 | 4842 |
4849 render_view_->FrameDidStopLoading(frame_); | 4843 render_view_->FrameDidStopLoading(frame_); |
4850 Send(new FrameHostMsg_DidStopLoading(routing_id_)); | 4844 Send(new FrameHostMsg_DidStopLoading(routing_id_)); |
4851 } | 4845 } |
4852 | 4846 |
4853 void RenderFrameImpl::didChangeLoadProgress(double load_progress) { | 4847 void RenderFrameImpl::didChangeLoadProgress(double load_progress) { |
4854 Send(new FrameHostMsg_DidChangeLoadProgress(routing_id_, load_progress)); | 4848 Send(new FrameHostMsg_DidChangeLoadProgress(routing_id_, load_progress)); |
4855 } | 4849 } |
4856 | 4850 |
4857 void RenderFrameImpl::HandleWebAccessibilityEvent( | 4851 void RenderFrameImpl::HandleWebAccessibilityEvent( |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4983 if (is_content_initiated && IsTopLevelNavigation(frame_) && | 4977 if (is_content_initiated && IsTopLevelNavigation(frame_) && |
4984 render_view_->renderer_preferences_ | 4978 render_view_->renderer_preferences_ |
4985 .browser_handles_all_top_level_requests) { | 4979 .browser_handles_all_top_level_requests) { |
4986 OpenURL(url, IsHttpPost(info.urlRequest), | 4980 OpenURL(url, IsHttpPost(info.urlRequest), |
4987 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, | 4981 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, |
4988 info.defaultPolicy, info.replacesCurrentHistoryItem, false); | 4982 info.defaultPolicy, info.replacesCurrentHistoryItem, false); |
4989 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 4983 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
4990 } | 4984 } |
4991 | 4985 |
4992 // In OOPIF-enabled modes, back/forward navigations in newly created subframes | 4986 // In OOPIF-enabled modes, back/forward navigations in newly created subframes |
4993 // should be sent to the browser if there is a chance there is a matching | 4987 // should be sent to the browser if there is a matching FrameNavigationEntry. |
4994 // FrameNavigationEntry. If none is found (or if the browser has indicated it | 4988 // If this frame isn't on the list of unique names that have history items, |
4995 // has no subtree history items), fall back to loading the default url. | 4989 // fall back to loading the default url. (We remove each name as we encounter |
| 4990 // it, because it will only be used once as the frame is created.) |
4996 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && | 4991 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && |
4997 info.isHistoryNavigationInNewChildFrame && is_content_initiated && | 4992 info.isHistoryNavigationInNewChildFrame && is_content_initiated && |
4998 browser_has_subtree_history_items_) { | 4993 frame_->parent() && |
| 4994 RenderFrameImpl::FromWebFrame(frame_->parent()) |
| 4995 ->history_subframe_unique_names_.erase( |
| 4996 frame_->uniqueName().utf8()) > 0) { |
4999 // Don't do this if |info| also says it is a client redirect, in which case | 4997 // Don't do this if |info| also says it is a client redirect, in which case |
5000 // JavaScript on the page is trying to interrupt the history navigation. | 4998 // JavaScript on the page is trying to interrupt the history navigation. |
5001 if (!info.isClientRedirect) { | 4999 if (!info.isClientRedirect) { |
5002 OpenURL(url, IsHttpPost(info.urlRequest), | 5000 OpenURL(url, IsHttpPost(info.urlRequest), |
5003 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, | 5001 GetRequestBodyForWebURLRequest(info.urlRequest), referrer, |
5004 info.defaultPolicy, info.replacesCurrentHistoryItem, true); | 5002 info.defaultPolicy, info.replacesCurrentHistoryItem, true); |
5005 // Suppress the load in Blink but mark the frame as loading. | 5003 // Suppress the load in Blink but mark the frame as loading. |
5006 return blink::WebNavigationPolicyHandledByClient; | 5004 return blink::WebNavigationPolicyHandledByClient; |
5007 } else { | 5005 } else { |
5008 // Client redirects during an initial history load should attempt to | 5006 // Client redirects during an initial history load should attempt to |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5592 // PageState. | 5590 // PageState. |
5593 item_for_history_navigation = entry->root(); | 5591 item_for_history_navigation = entry->root(); |
5594 history_load_type = request_params.is_same_document_history_load | 5592 history_load_type = request_params.is_same_document_history_load |
5595 ? blink::WebHistorySameDocumentLoad | 5593 ? blink::WebHistorySameDocumentLoad |
5596 : blink::WebHistoryDifferentDocumentLoad; | 5594 : blink::WebHistoryDifferentDocumentLoad; |
5597 load_type = request_params.is_history_navigation_in_new_child | 5595 load_type = request_params.is_history_navigation_in_new_child |
5598 ? blink::WebFrameLoadType::InitialHistoryLoad | 5596 ? blink::WebFrameLoadType::InitialHistoryLoad |
5599 : blink::WebFrameLoadType::BackForward; | 5597 : blink::WebFrameLoadType::BackForward; |
5600 should_load_request = true; | 5598 should_load_request = true; |
5601 | 5599 |
5602 // Remember whether we should consult the browser process for any | 5600 // Keep track of which subframes the browser process has history items |
5603 // subframes created during this history navigation. | 5601 // for during a history navigation. |
5604 browser_has_subtree_history_items_ = | 5602 history_subframe_unique_names_ = request_params.subframe_unique_names; |
5605 request_params.has_subtree_history_items; | |
5606 | 5603 |
5607 if (history_load_type == blink::WebHistorySameDocumentLoad) { | 5604 if (history_load_type == blink::WebHistorySameDocumentLoad) { |
5608 // If this is marked as a same document load but we haven't committed | 5605 // If this is marked as a same document load but we haven't committed |
5609 // anything, treat it as a new load. The browser shouldn't let this | 5606 // anything, treat it as a new load. The browser shouldn't let this |
5610 // happen. | 5607 // happen. |
5611 if (current_history_item_.isNull()) { | 5608 if (current_history_item_.isNull()) { |
5612 history_load_type = blink::WebHistoryDifferentDocumentLoad; | 5609 history_load_type = blink::WebHistoryDifferentDocumentLoad; |
5613 NOTREACHED(); | 5610 NOTREACHED(); |
5614 } else { | 5611 } else { |
5615 // Additionally, if the |current_history_item_|'s document | 5612 // Additionally, if the |current_history_item_|'s document |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6431 // event target. Potentially a Pepper plugin will receive the event. | 6428 // event target. Potentially a Pepper plugin will receive the event. |
6432 // In order to tell whether a plugin gets the last mouse event and which it | 6429 // In order to tell whether a plugin gets the last mouse event and which it |
6433 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6430 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6434 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6431 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6435 // |pepper_last_mouse_event_target_|. | 6432 // |pepper_last_mouse_event_target_|. |
6436 pepper_last_mouse_event_target_ = nullptr; | 6433 pepper_last_mouse_event_target_ = nullptr; |
6437 #endif | 6434 #endif |
6438 } | 6435 } |
6439 | 6436 |
6440 } // namespace content | 6437 } // namespace content |
OLD | NEW |