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/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
6 | 6 |
7 #include "base/containers/hash_tables.h" | 7 #include "base/containers/hash_tables.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/metrics/user_metrics_action.h" | 9 #include "base/metrics/user_metrics_action.h" |
10 #include "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 GetProcess()->ReceivedBadMessage(); | 154 GetProcess()->ReceivedBadMessage(); |
155 } | 155 } |
156 | 156 |
157 return handled; | 157 return handled; |
158 } | 158 } |
159 | 159 |
160 void RenderFrameHostImpl::Init() { | 160 void RenderFrameHostImpl::Init() { |
161 GetProcess()->ResumeRequestsForView(routing_id_); | 161 GetProcess()->ResumeRequestsForView(routing_id_); |
162 } | 162 } |
163 | 163 |
164 void RenderFrameHostImpl::OnCreateChildFrame(int new_frame_routing_id, | 164 void RenderFrameHostImpl::OnCreateChildFrame(int new_routing_id, |
165 int64 parent_frame_id, | |
166 int64 frame_id, | |
167 const std::string& frame_name) { | 165 const std::string& frame_name) { |
168 RenderFrameHostImpl* new_frame = frame_tree_->AddFrame( | 166 RenderFrameHostImpl* new_frame = frame_tree_->AddFrame( |
169 new_frame_routing_id, parent_frame_id, frame_id, frame_name); | 167 frame_tree_node_, new_routing_id, frame_name); |
170 if (delegate_) | 168 if (delegate_) |
171 delegate_->RenderFrameCreated(new_frame); | 169 delegate_->RenderFrameCreated(new_frame); |
172 } | 170 } |
173 | 171 |
174 void RenderFrameHostImpl::OnDetach(int64 parent_frame_id, int64 frame_id) { | 172 void RenderFrameHostImpl::OnDetach() { |
175 frame_tree_->RemoveFrame(this, parent_frame_id, frame_id); | 173 frame_tree_->RemoveFrame(frame_tree_node_); |
176 } | 174 } |
177 | 175 |
178 void RenderFrameHostImpl::OnDidStartProvisionalLoadForFrame( | 176 void RenderFrameHostImpl::OnDidStartProvisionalLoadForFrame( |
179 int64 frame_id, | 177 int64 frame_id, |
180 int64 parent_frame_id, | 178 int64 parent_frame_id, |
181 bool is_main_frame, | 179 bool is_main_frame, |
182 const GURL& url) { | 180 const GURL& url) { |
183 frame_tree_node_->navigator()->DidStartProvisionalLoad( | 181 frame_tree_node_->navigator()->DidStartProvisionalLoad( |
184 this, frame_id, parent_frame_id, is_main_frame, url); | 182 this, frame_id, parent_frame_id, is_main_frame, url); |
185 } | 183 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 } | 242 } |
245 | 243 |
246 // If we're waiting for an unload ack from this renderer and we receive a | 244 // If we're waiting for an unload ack from this renderer and we receive a |
247 // Navigate message, then the renderer was navigating before it received the | 245 // Navigate message, then the renderer was navigating before it received the |
248 // unload request. It will either respond to the unload request soon or our | 246 // unload request. It will either respond to the unload request soon or our |
249 // timer will expire. Either way, we should ignore this message, because we | 247 // timer will expire. Either way, we should ignore this message, because we |
250 // have already committed to closing this renderer. | 248 // have already committed to closing this renderer. |
251 if (render_view_host_->IsWaitingForUnloadACK()) | 249 if (render_view_host_->IsWaitingForUnloadACK()) |
252 return; | 250 return; |
253 | 251 |
254 // Cache the main frame id, so we can use it for creating the frame tree | |
255 // root node when needed. | |
256 if (PageTransitionIsMainFrame(validated_params.transition)) { | |
257 if (render_view_host_->main_frame_id_ == -1) { | |
258 render_view_host_->main_frame_id_ = validated_params.frame_id; | |
259 } else { | |
260 // TODO(nasko): We plan to remove the usage of frame_id in navigation | |
261 // and move to routing ids. This is in place to ensure that a | |
262 // renderer is not misbehaving and sending us incorrect data. | |
263 DCHECK_EQ(render_view_host_->main_frame_id_, validated_params.frame_id); | |
264 } | |
265 } | |
266 RenderProcessHost* process = GetProcess(); | 252 RenderProcessHost* process = GetProcess(); |
267 | 253 |
268 // Attempts to commit certain off-limits URL should be caught more strictly | 254 // Attempts to commit certain off-limits URL should be caught more strictly |
269 // than our FilterURL checks below. If a renderer violates this policy, it | 255 // than our FilterURL checks below. If a renderer violates this policy, it |
270 // should be killed. | 256 // should be killed. |
271 if (!CanCommitURL(validated_params.url)) { | 257 if (!CanCommitURL(validated_params.url)) { |
272 VLOG(1) << "Blocked URL " << validated_params.url.spec(); | 258 VLOG(1) << "Blocked URL " << validated_params.url.spec(); |
273 validated_params.url = GURL(kAboutBlankURL); | 259 validated_params.url = GURL(kAboutBlankURL); |
274 RecordAction(base::UserMetricsAction("CanCommitURL_BlockedAndKilled")); | 260 RecordAction(base::UserMetricsAction("CanCommitURL_BlockedAndKilled")); |
275 // Kills the process. | 261 // Kills the process. |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 params.pending_history_list_offset = -1; | 402 params.pending_history_list_offset = -1; |
417 params.current_history_list_offset = -1; | 403 params.current_history_list_offset = -1; |
418 params.current_history_list_length = 0; | 404 params.current_history_list_length = 0; |
419 params.url = url; | 405 params.url = url; |
420 params.transition = PAGE_TRANSITION_LINK; | 406 params.transition = PAGE_TRANSITION_LINK; |
421 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 407 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
422 Navigate(params); | 408 Navigate(params); |
423 } | 409 } |
424 | 410 |
425 } // namespace content | 411 } // namespace content |
OLD | NEW |