OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer_host/render_view_host_impl.h" | 5 #include "content/browser/renderer_host/render_view_host_impl.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 routing_id, | 198 routing_id, |
199 hidden), | 199 hidden), |
200 frames_ref_count_(0), | 200 frames_ref_count_(0), |
201 delegate_(delegate), | 201 delegate_(delegate), |
202 instance_(static_cast<SiteInstanceImpl*>(instance)), | 202 instance_(static_cast<SiteInstanceImpl*>(instance)), |
203 waiting_for_drag_context_response_(false), | 203 waiting_for_drag_context_response_(false), |
204 enabled_bindings_(0), | 204 enabled_bindings_(0), |
205 navigations_suspended_(false), | 205 navigations_suspended_(false), |
206 has_accessed_initial_document_(false), | 206 has_accessed_initial_document_(false), |
207 main_frame_routing_id_(main_frame_routing_id), | 207 main_frame_routing_id_(main_frame_routing_id), |
| 208 focused_frame_routing_id_(MSG_ROUTING_NONE), |
208 is_waiting_for_beforeunload_ack_(false), | 209 is_waiting_for_beforeunload_ack_(false), |
209 unload_ack_is_for_cross_site_transition_(false), | 210 unload_ack_is_for_cross_site_transition_(false), |
210 are_javascript_messages_suppressed_(false), | 211 are_javascript_messages_suppressed_(false), |
211 sudden_termination_allowed_(false), | 212 sudden_termination_allowed_(false), |
212 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 213 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
213 virtual_keyboard_requested_(false), | 214 virtual_keyboard_requested_(false), |
214 weak_factory_(this) { | 215 weak_factory_(this) { |
215 DCHECK(instance_.get()); | 216 DCHECK(instance_.get()); |
216 CHECK(delegate_); // http://crbug.com/82827 | 217 CHECK(delegate_); // http://crbug.com/82827 |
217 | 218 |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 } | 961 } |
961 | 962 |
962 void RenderViewHostImpl::DragSourceSystemDragEnded() { | 963 void RenderViewHostImpl::DragSourceSystemDragEnded() { |
963 Send(new DragMsg_SourceSystemDragEnded(GetRoutingID())); | 964 Send(new DragMsg_SourceSystemDragEnded(GetRoutingID())); |
964 } | 965 } |
965 | 966 |
966 RenderFrameHost* RenderViewHostImpl::GetMainFrame() { | 967 RenderFrameHost* RenderViewHostImpl::GetMainFrame() { |
967 return RenderFrameHost::FromID(GetProcess()->GetID(), main_frame_routing_id_); | 968 return RenderFrameHost::FromID(GetProcess()->GetID(), main_frame_routing_id_); |
968 } | 969 } |
969 | 970 |
| 971 RenderFrameHost* RenderViewHostImpl::GetFocusedFrame() { |
| 972 return RenderFrameHost::FromID( |
| 973 GetProcess()->GetID(), focused_frame_routing_id_); |
| 974 } |
| 975 |
970 void RenderViewHostImpl::AllowBindings(int bindings_flags) { | 976 void RenderViewHostImpl::AllowBindings(int bindings_flags) { |
971 // Never grant any bindings to browser plugin guests. | 977 // Never grant any bindings to browser plugin guests. |
972 if (GetProcess()->IsGuest()) { | 978 if (GetProcess()->IsGuest()) { |
973 NOTREACHED() << "Never grant bindings to a guest process."; | 979 NOTREACHED() << "Never grant bindings to a guest process."; |
974 return; | 980 return; |
975 } | 981 } |
976 | 982 |
977 // Ensure we aren't granting WebUI bindings to a process that has already | 983 // Ensure we aren't granting WebUI bindings to a process that has already |
978 // been used for non-privileged views. | 984 // been used for non-privileged views. |
979 if (bindings_flags & BINDINGS_POLICY_WEB_UI && | 985 if (bindings_flags & BINDINGS_POLICY_WEB_UI && |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 IPC_MESSAGE_HANDLER(ViewHostMsg_RouteMessageEvent, OnRouteMessageEvent) | 1157 IPC_MESSAGE_HANDLER(ViewHostMsg_RouteMessageEvent, OnRouteMessageEvent) |
1152 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunJavaScriptMessage, | 1158 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunJavaScriptMessage, |
1153 OnRunJavaScriptMessage) | 1159 OnRunJavaScriptMessage) |
1154 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm, | 1160 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm, |
1155 OnRunBeforeUnloadConfirm) | 1161 OnRunBeforeUnloadConfirm) |
1156 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnStartDragging) | 1162 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnStartDragging) |
1157 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) | 1163 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) |
1158 IPC_MESSAGE_HANDLER(DragHostMsg_TargetDrop_ACK, OnTargetDropACK) | 1164 IPC_MESSAGE_HANDLER(DragHostMsg_TargetDrop_ACK, OnTargetDropACK) |
1159 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) | 1165 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) |
1160 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) | 1166 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) |
| 1167 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedFrameChanged, OnFocusedFrameChanged) |
1161 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) | 1168 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) |
1162 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnShouldCloseACK) | 1169 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnShouldCloseACK) |
1163 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) | 1170 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) |
1164 IPC_MESSAGE_HANDLER(ViewHostMsg_SwapOut_ACK, OnSwapOutACK) | 1171 IPC_MESSAGE_HANDLER(ViewHostMsg_SwapOut_ACK, OnSwapOutACK) |
1165 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnSelectionChanged) | 1172 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnSelectionChanged) |
1166 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionBoundsChanged, | 1173 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionBoundsChanged, |
1167 OnSelectionBoundsChanged) | 1174 OnSelectionBoundsChanged) |
1168 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) | 1175 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) |
1169 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) | 1176 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) |
1170 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission, | 1177 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission, |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1524 base::Bind(base::IgnoreResult(&DismissVirtualKeyboardTask)), | 1531 base::Bind(base::IgnoreResult(&DismissVirtualKeyboardTask)), |
1525 TimeDelta::FromMilliseconds(kVirtualKeyboardDisplayWaitTimeoutMs)); | 1532 TimeDelta::FromMilliseconds(kVirtualKeyboardDisplayWaitTimeoutMs)); |
1526 } | 1533 } |
1527 #endif | 1534 #endif |
1528 NotificationService::current()->Notify( | 1535 NotificationService::current()->Notify( |
1529 NOTIFICATION_FOCUS_CHANGED_IN_PAGE, | 1536 NOTIFICATION_FOCUS_CHANGED_IN_PAGE, |
1530 Source<RenderViewHost>(this), | 1537 Source<RenderViewHost>(this), |
1531 Details<const bool>(&is_editable_node)); | 1538 Details<const bool>(&is_editable_node)); |
1532 } | 1539 } |
1533 | 1540 |
| 1541 void RenderViewHostImpl::OnFocusedFrameChanged(int focused_frame_routing_id) { |
| 1542 focused_frame_routing_id_ = focused_frame_routing_id; |
| 1543 } |
| 1544 |
1534 void RenderViewHostImpl::OnAddMessageToConsole( | 1545 void RenderViewHostImpl::OnAddMessageToConsole( |
1535 int32 level, | 1546 int32 level, |
1536 const base::string16& message, | 1547 const base::string16& message, |
1537 int32 line_no, | 1548 int32 line_no, |
1538 const base::string16& source_id) { | 1549 const base::string16& source_id) { |
1539 if (delegate_->AddMessageToConsole(level, message, line_no, source_id)) | 1550 if (delegate_->AddMessageToConsole(level, message, line_no, source_id)) |
1540 return; | 1551 return; |
1541 | 1552 |
1542 // Pass through log level only on WebUI pages to limit console spew. | 1553 // Pass through log level only on WebUI pages to limit console spew. |
1543 int32 resolved_level = HasWebUIScheme(delegate_->GetURL()) ? level : 0; | 1554 int32 resolved_level = HasWebUIScheme(delegate_->GetURL()) ? level : 0; |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1973 return true; | 1984 return true; |
1974 } | 1985 } |
1975 | 1986 |
1976 void RenderViewHostImpl::AttachToFrameTree() { | 1987 void RenderViewHostImpl::AttachToFrameTree() { |
1977 FrameTree* frame_tree = delegate_->GetFrameTree(); | 1988 FrameTree* frame_tree = delegate_->GetFrameTree(); |
1978 | 1989 |
1979 frame_tree->ResetForMainFrameSwap(); | 1990 frame_tree->ResetForMainFrameSwap(); |
1980 } | 1991 } |
1981 | 1992 |
1982 } // namespace content | 1993 } // namespace content |
OLD | NEW |