| 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" |
| 11 #include "content/browser/frame_host/cross_process_frame_connector.h" | 11 #include "content/browser/frame_host/cross_process_frame_connector.h" |
| 12 #include "content/browser/frame_host/cross_site_transferring_request.h" | 12 #include "content/browser/frame_host/cross_site_transferring_request.h" |
| 13 #include "content/browser/frame_host/frame_tree.h" | 13 #include "content/browser/frame_host/frame_tree.h" |
| 14 #include "content/browser/frame_host/frame_tree_node.h" | 14 #include "content/browser/frame_host/frame_tree_node.h" |
| 15 #include "content/browser/frame_host/navigator.h" | 15 #include "content/browser/frame_host/navigator.h" |
| 16 #include "content/browser/frame_host/render_frame_host_delegate.h" | 16 #include "content/browser/frame_host/render_frame_host_delegate.h" |
| 17 #include "content/browser/renderer_host/render_view_host_impl.h" | 17 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 18 #include "content/common/frame_messages.h" | 18 #include "content/common/frame_messages.h" |
| 19 #include "content/common/input_messages.h" |
| 19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/content_browser_client.h" | 21 #include "content/public/browser/content_browser_client.h" |
| 21 #include "content/public/browser/render_process_host.h" | 22 #include "content/public/browser/render_process_host.h" |
| 22 #include "content/public/browser/render_widget_host_view.h" | 23 #include "content/public/browser/render_widget_host_view.h" |
| 23 #include "content/public/browser/user_metrics.h" | 24 #include "content/public/browser/user_metrics.h" |
| 24 #include "content/public/common/url_constants.h" | 25 #include "content/public/common/url_constants.h" |
| 25 #include "url/gurl.h" | 26 #include "url/gurl.h" |
| 26 | 27 |
| 27 namespace content { | 28 namespace content { |
| 28 | 29 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 void RenderFrameHostImpl::NotifyContextMenuClosed( | 125 void RenderFrameHostImpl::NotifyContextMenuClosed( |
| 125 const CustomContextMenuContext& context) { | 126 const CustomContextMenuContext& context) { |
| 126 Send(new FrameMsg_ContextMenuClosed(routing_id_, context)); | 127 Send(new FrameMsg_ContextMenuClosed(routing_id_, context)); |
| 127 } | 128 } |
| 128 | 129 |
| 129 void RenderFrameHostImpl::ExecuteCustomContextMenuCommand( | 130 void RenderFrameHostImpl::ExecuteCustomContextMenuCommand( |
| 130 int action, const CustomContextMenuContext& context) { | 131 int action, const CustomContextMenuContext& context) { |
| 131 Send(new FrameMsg_CustomContextMenuAction(routing_id_, context, action)); | 132 Send(new FrameMsg_CustomContextMenuAction(routing_id_, context, action)); |
| 132 } | 133 } |
| 133 | 134 |
| 135 void RenderFrameHostImpl::Cut() { |
| 136 Send(new InputMsg_Cut(routing_id_)); |
| 137 RecordAction(base::UserMetricsAction("Cut")); |
| 138 } |
| 139 |
| 140 void RenderFrameHostImpl::Copy() { |
| 141 Send(new InputMsg_Copy(routing_id_)); |
| 142 RecordAction(base::UserMetricsAction("Copy")); |
| 143 } |
| 144 |
| 145 void RenderFrameHostImpl::Paste() { |
| 146 Send(new InputMsg_Paste(routing_id_)); |
| 147 RecordAction(base::UserMetricsAction("Paste")); |
| 148 } |
| 149 |
| 134 RenderViewHost* RenderFrameHostImpl::GetRenderViewHost() { | 150 RenderViewHost* RenderFrameHostImpl::GetRenderViewHost() { |
| 135 return render_view_host_; | 151 return render_view_host_; |
| 136 } | 152 } |
| 137 | 153 |
| 138 bool RenderFrameHostImpl::Send(IPC::Message* message) { | 154 bool RenderFrameHostImpl::Send(IPC::Message* message) { |
| 139 return GetProcess()->Send(message); | 155 return GetProcess()->Send(message); |
| 140 } | 156 } |
| 141 | 157 |
| 142 bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) { | 158 bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) { |
| 143 if (delegate_->OnMessageReceived(this, msg)) | 159 if (delegate_->OnMessageReceived(this, msg)) |
| 144 return true; | 160 return true; |
| 145 | 161 |
| 146 if (cross_process_frame_connector_ && | 162 if (cross_process_frame_connector_ && |
| 147 cross_process_frame_connector_->OnMessageReceived(msg)) | 163 cross_process_frame_connector_->OnMessageReceived(msg)) |
| 148 return true; | 164 return true; |
| 149 | 165 |
| 150 bool handled = true; | 166 bool handled = true; |
| 151 bool msg_is_ok = true; | 167 bool msg_is_ok = true; |
| 152 IPC_BEGIN_MESSAGE_MAP_EX(RenderFrameHostImpl, msg, msg_is_ok) | 168 IPC_BEGIN_MESSAGE_MAP_EX(RenderFrameHostImpl, msg, msg_is_ok) |
| 153 IPC_MESSAGE_HANDLER(FrameHostMsg_Detach, OnDetach) | 169 IPC_MESSAGE_HANDLER(FrameHostMsg_Detach, OnDetach) |
| 170 IPC_MESSAGE_HANDLER(FrameHostMsg_FrameFocused, OnFrameFocused) |
| 154 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStartProvisionalLoadForFrame, | 171 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStartProvisionalLoadForFrame, |
| 155 OnDidStartProvisionalLoadForFrame) | 172 OnDidStartProvisionalLoadForFrame) |
| 156 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailProvisionalLoadWithError, | 173 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailProvisionalLoadWithError, |
| 157 OnDidFailProvisionalLoadWithError) | 174 OnDidFailProvisionalLoadWithError) |
| 158 IPC_MESSAGE_HANDLER(FrameHostMsg_DidRedirectProvisionalLoad, | 175 IPC_MESSAGE_HANDLER(FrameHostMsg_DidRedirectProvisionalLoad, |
| 159 OnDidRedirectProvisionalLoad) | 176 OnDidRedirectProvisionalLoad) |
| 160 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailLoadWithError, | 177 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailLoadWithError, |
| 161 OnDidFailLoadWithError) | 178 OnDidFailLoadWithError) |
| 162 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad, | 179 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad, |
| 163 OnNavigate(msg)) | 180 OnNavigate(msg)) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 187 RenderFrameHostImpl* new_frame = frame_tree_->AddFrame( | 204 RenderFrameHostImpl* new_frame = frame_tree_->AddFrame( |
| 188 frame_tree_node_, new_routing_id, frame_name); | 205 frame_tree_node_, new_routing_id, frame_name); |
| 189 if (delegate_) | 206 if (delegate_) |
| 190 delegate_->RenderFrameCreated(new_frame); | 207 delegate_->RenderFrameCreated(new_frame); |
| 191 } | 208 } |
| 192 | 209 |
| 193 void RenderFrameHostImpl::OnDetach() { | 210 void RenderFrameHostImpl::OnDetach() { |
| 194 frame_tree_->RemoveFrame(frame_tree_node_); | 211 frame_tree_->RemoveFrame(frame_tree_node_); |
| 195 } | 212 } |
| 196 | 213 |
| 214 void RenderFrameHostImpl::OnFrameFocused() { |
| 215 frame_tree_->SetFocusedFrame(frame_tree_node_); |
| 216 } |
| 217 |
| 197 void RenderFrameHostImpl::OnOpenURL( | 218 void RenderFrameHostImpl::OnOpenURL( |
| 198 const FrameHostMsg_OpenURL_Params& params) { | 219 const FrameHostMsg_OpenURL_Params& params) { |
| 199 GURL validated_url(params.url); | 220 GURL validated_url(params.url); |
| 200 GetProcess()->FilterURL(false, &validated_url); | 221 GetProcess()->FilterURL(false, &validated_url); |
| 201 | 222 |
| 202 frame_tree_node_->navigator()->RequestOpenURL( | 223 frame_tree_node_->navigator()->RequestOpenURL( |
| 203 this, validated_url, params.referrer, params.disposition, | 224 this, validated_url, params.referrer, params.disposition, |
| 204 params.should_replace_current_entry, params.user_gesture); | 225 params.should_replace_current_entry, params.user_gesture); |
| 205 } | 226 } |
| 206 | 227 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 // second navigation occurs, RenderFrameHostManager will cancel this pending | 438 // second navigation occurs, RenderFrameHostManager will cancel this pending |
| 418 // RFH and create a new pending RFH. | 439 // RFH and create a new pending RFH. |
| 419 DCHECK(!render_view_host_->suspended_nav_params_.get()); | 440 DCHECK(!render_view_host_->suspended_nav_params_.get()); |
| 420 render_view_host_->suspended_nav_params_.reset( | 441 render_view_host_->suspended_nav_params_.reset( |
| 421 new FrameMsg_Navigate_Params(params)); | 442 new FrameMsg_Navigate_Params(params)); |
| 422 } else { | 443 } else { |
| 423 // Get back to a clean state, in case we start a new navigation without | 444 // Get back to a clean state, in case we start a new navigation without |
| 424 // completing a RVH swap or unload handler. | 445 // completing a RVH swap or unload handler. |
| 425 render_view_host_->SetState(RenderViewHostImpl::STATE_DEFAULT); | 446 render_view_host_->SetState(RenderViewHostImpl::STATE_DEFAULT); |
| 426 | 447 |
| 427 Send(new FrameMsg_Navigate(GetRoutingID(), params)); | 448 Send(new FrameMsg_Navigate(routing_id_, params)); |
| 428 } | 449 } |
| 429 | 450 |
| 430 // Force the throbber to start. We do this because Blink's "started | 451 // Force the throbber to start. We do this because Blink's "started |
| 431 // loading" message will be received asynchronously from the UI of the | 452 // loading" message will be received asynchronously from the UI of the |
| 432 // browser. But we want to keep the throbber in sync with what's happening | 453 // browser. But we want to keep the throbber in sync with what's happening |
| 433 // in the UI. For example, we want to start throbbing immediately when the | 454 // in the UI. For example, we want to start throbbing immediately when the |
| 434 // user naivgates even if the renderer is delayed. There is also an issue | 455 // user naivgates even if the renderer is delayed. There is also an issue |
| 435 // with the throbber starting because the WebUI (which controls whether the | 456 // with the throbber starting because the WebUI (which controls whether the |
| 436 // favicon is displayed) happens synchronously. If the start loading | 457 // favicon is displayed) happens synchronously. If the start loading |
| 437 // messages was asynchronous, then the default favicon would flash in. | 458 // messages was asynchronous, then the default favicon would flash in. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 448 params.pending_history_list_offset = -1; | 469 params.pending_history_list_offset = -1; |
| 449 params.current_history_list_offset = -1; | 470 params.current_history_list_offset = -1; |
| 450 params.current_history_list_length = 0; | 471 params.current_history_list_length = 0; |
| 451 params.url = url; | 472 params.url = url; |
| 452 params.transition = PAGE_TRANSITION_LINK; | 473 params.transition = PAGE_TRANSITION_LINK; |
| 453 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 474 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 454 Navigate(params); | 475 Navigate(params); |
| 455 } | 476 } |
| 456 | 477 |
| 457 } // namespace content | 478 } // namespace content |
| OLD | NEW |