| 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 void RenderFrameHostImpl::InsertCSS(const std::string& css) { | 150 void RenderFrameHostImpl::InsertCSS(const std::string& css) { |
| 135 Send(new FrameMsg_CSSInsertRequest(routing_id_, css)); | 151 Send(new FrameMsg_CSSInsertRequest(routing_id_, css)); |
| 136 } | 152 } |
| 137 | 153 |
| 138 RenderViewHost* RenderFrameHostImpl::GetRenderViewHost() { | 154 RenderViewHost* RenderFrameHostImpl::GetRenderViewHost() { |
| 139 return render_view_host_; | 155 return render_view_host_; |
| 140 } | 156 } |
| 141 | 157 |
| 142 bool RenderFrameHostImpl::Send(IPC::Message* message) { | 158 bool RenderFrameHostImpl::Send(IPC::Message* message) { |
| 143 return GetProcess()->Send(message); | 159 return GetProcess()->Send(message); |
| 144 } | 160 } |
| 145 | 161 |
| 146 bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) { | 162 bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) { |
| 147 if (delegate_->OnMessageReceived(this, msg)) | 163 if (delegate_->OnMessageReceived(this, msg)) |
| 148 return true; | 164 return true; |
| 149 | 165 |
| 150 if (cross_process_frame_connector_ && | 166 if (cross_process_frame_connector_ && |
| 151 cross_process_frame_connector_->OnMessageReceived(msg)) | 167 cross_process_frame_connector_->OnMessageReceived(msg)) |
| 152 return true; | 168 return true; |
| 153 | 169 |
| 154 bool handled = true; | 170 bool handled = true; |
| 155 bool msg_is_ok = true; | 171 bool msg_is_ok = true; |
| 156 IPC_BEGIN_MESSAGE_MAP_EX(RenderFrameHostImpl, msg, msg_is_ok) | 172 IPC_BEGIN_MESSAGE_MAP_EX(RenderFrameHostImpl, msg, msg_is_ok) |
| 157 IPC_MESSAGE_HANDLER(FrameHostMsg_Detach, OnDetach) | 173 IPC_MESSAGE_HANDLER(FrameHostMsg_Detach, OnDetach) |
| 174 IPC_MESSAGE_HANDLER(FrameHostMsg_FrameFocused, OnFrameFocused) |
| 158 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStartProvisionalLoadForFrame, | 175 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStartProvisionalLoadForFrame, |
| 159 OnDidStartProvisionalLoadForFrame) | 176 OnDidStartProvisionalLoadForFrame) |
| 160 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailProvisionalLoadWithError, | 177 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailProvisionalLoadWithError, |
| 161 OnDidFailProvisionalLoadWithError) | 178 OnDidFailProvisionalLoadWithError) |
| 162 IPC_MESSAGE_HANDLER(FrameHostMsg_DidRedirectProvisionalLoad, | 179 IPC_MESSAGE_HANDLER(FrameHostMsg_DidRedirectProvisionalLoad, |
| 163 OnDidRedirectProvisionalLoad) | 180 OnDidRedirectProvisionalLoad) |
| 164 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailLoadWithError, | 181 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailLoadWithError, |
| 165 OnDidFailLoadWithError) | 182 OnDidFailLoadWithError) |
| 166 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad, | 183 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad, |
| 167 OnNavigate(msg)) | 184 OnNavigate(msg)) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 191 RenderFrameHostImpl* new_frame = frame_tree_->AddFrame( | 208 RenderFrameHostImpl* new_frame = frame_tree_->AddFrame( |
| 192 frame_tree_node_, new_routing_id, frame_name); | 209 frame_tree_node_, new_routing_id, frame_name); |
| 193 if (delegate_) | 210 if (delegate_) |
| 194 delegate_->RenderFrameCreated(new_frame); | 211 delegate_->RenderFrameCreated(new_frame); |
| 195 } | 212 } |
| 196 | 213 |
| 197 void RenderFrameHostImpl::OnDetach() { | 214 void RenderFrameHostImpl::OnDetach() { |
| 198 frame_tree_->RemoveFrame(frame_tree_node_); | 215 frame_tree_->RemoveFrame(frame_tree_node_); |
| 199 } | 216 } |
| 200 | 217 |
| 218 void RenderFrameHostImpl::OnFrameFocused() { |
| 219 frame_tree_->SetFocusedFrame(frame_tree_node_); |
| 220 } |
| 221 |
| 201 void RenderFrameHostImpl::OnOpenURL( | 222 void RenderFrameHostImpl::OnOpenURL( |
| 202 const FrameHostMsg_OpenURL_Params& params) { | 223 const FrameHostMsg_OpenURL_Params& params) { |
| 203 GURL validated_url(params.url); | 224 GURL validated_url(params.url); |
| 204 GetProcess()->FilterURL(false, &validated_url); | 225 GetProcess()->FilterURL(false, &validated_url); |
| 205 | 226 |
| 206 frame_tree_node_->navigator()->RequestOpenURL( | 227 frame_tree_node_->navigator()->RequestOpenURL( |
| 207 this, validated_url, params.referrer, params.disposition, | 228 this, validated_url, params.referrer, params.disposition, |
| 208 params.should_replace_current_entry, params.user_gesture); | 229 params.should_replace_current_entry, params.user_gesture); |
| 209 } | 230 } |
| 210 | 231 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 // second navigation occurs, RenderFrameHostManager will cancel this pending | 442 // second navigation occurs, RenderFrameHostManager will cancel this pending |
| 422 // RFH and create a new pending RFH. | 443 // RFH and create a new pending RFH. |
| 423 DCHECK(!render_view_host_->suspended_nav_params_.get()); | 444 DCHECK(!render_view_host_->suspended_nav_params_.get()); |
| 424 render_view_host_->suspended_nav_params_.reset( | 445 render_view_host_->suspended_nav_params_.reset( |
| 425 new FrameMsg_Navigate_Params(params)); | 446 new FrameMsg_Navigate_Params(params)); |
| 426 } else { | 447 } else { |
| 427 // Get back to a clean state, in case we start a new navigation without | 448 // Get back to a clean state, in case we start a new navigation without |
| 428 // completing a RVH swap or unload handler. | 449 // completing a RVH swap or unload handler. |
| 429 render_view_host_->SetState(RenderViewHostImpl::STATE_DEFAULT); | 450 render_view_host_->SetState(RenderViewHostImpl::STATE_DEFAULT); |
| 430 | 451 |
| 431 Send(new FrameMsg_Navigate(GetRoutingID(), params)); | 452 Send(new FrameMsg_Navigate(routing_id_, params)); |
| 432 } | 453 } |
| 433 | 454 |
| 434 // Force the throbber to start. We do this because Blink's "started | 455 // Force the throbber to start. We do this because Blink's "started |
| 435 // loading" message will be received asynchronously from the UI of the | 456 // loading" message will be received asynchronously from the UI of the |
| 436 // browser. But we want to keep the throbber in sync with what's happening | 457 // browser. But we want to keep the throbber in sync with what's happening |
| 437 // in the UI. For example, we want to start throbbing immediately when the | 458 // in the UI. For example, we want to start throbbing immediately when the |
| 438 // user naivgates even if the renderer is delayed. There is also an issue | 459 // user naivgates even if the renderer is delayed. There is also an issue |
| 439 // with the throbber starting because the WebUI (which controls whether the | 460 // with the throbber starting because the WebUI (which controls whether the |
| 440 // favicon is displayed) happens synchronously. If the start loading | 461 // favicon is displayed) happens synchronously. If the start loading |
| 441 // messages was asynchronous, then the default favicon would flash in. | 462 // messages was asynchronous, then the default favicon would flash in. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 452 params.pending_history_list_offset = -1; | 473 params.pending_history_list_offset = -1; |
| 453 params.current_history_list_offset = -1; | 474 params.current_history_list_offset = -1; |
| 454 params.current_history_list_length = 0; | 475 params.current_history_list_length = 0; |
| 455 params.url = url; | 476 params.url = url; |
| 456 params.transition = PAGE_TRANSITION_LINK; | 477 params.transition = PAGE_TRANSITION_LINK; |
| 457 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 478 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 458 Navigate(params); | 479 Navigate(params); |
| 459 } | 480 } |
| 460 | 481 |
| 461 } // namespace content | 482 } // namespace content |
| OLD | NEW |