| 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> |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
| 14 #include "base/json/json_reader.h" | 14 #include "base/json/json_reader.h" |
| 15 #include "base/json/json_writer.h" |
| 15 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
| 16 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
| 17 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| 18 #include "base/time.h" | 19 #include "base/time.h" |
| 19 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| 20 #include "base/values.h" | 21 #include "base/values.h" |
| 21 #include "content/browser/child_process_security_policy_impl.h" | 22 #include "content/browser/child_process_security_policy_impl.h" |
| 22 #include "content/browser/cross_site_request_manager.h" | 23 #include "content/browser/cross_site_request_manager.h" |
| 23 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 24 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
| 24 #include "content/browser/gpu/gpu_surface_tracker.h" | 25 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 25 #include "content/browser/host_zoom_map_impl.h" | 26 #include "content/browser/host_zoom_map_impl.h" |
| 26 #include "content/browser/power_save_blocker.h" | 27 #include "content/browser/power_save_blocker.h" |
| 27 #include "content/browser/renderer_host/dip_util.h" | 28 #include "content/browser/renderer_host/dip_util.h" |
| 28 #include "content/browser/renderer_host/render_process_host_impl.h" | 29 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 29 #include "content/browser/renderer_host/render_view_host_delegate.h" | 30 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 30 #include "content/common/accessibility_messages.h" | 31 #include "content/common/accessibility_messages.h" |
| 31 #include "content/common/desktop_notification_messages.h" | 32 #include "content/common/desktop_notification_messages.h" |
| 32 #include "content/common/drag_messages.h" | 33 #include "content/common/drag_messages.h" |
| 33 #include "content/common/inter_process_time_ticks_converter.h" | 34 #include "content/common/inter_process_time_ticks_converter.h" |
| 34 #include "content/common/speech_recognition_messages.h" | 35 #include "content/common/speech_recognition_messages.h" |
| 36 #include "content/common/string_constants.h" |
| 35 #include "content/common/swapped_out_messages.h" | 37 #include "content/common/swapped_out_messages.h" |
| 36 #include "content/common/view_messages.h" | 38 #include "content/common/view_messages.h" |
| 37 #include "content/port/browser/render_view_host_delegate_view.h" | 39 #include "content/port/browser/render_view_host_delegate_view.h" |
| 38 #include "content/port/browser/render_widget_host_view_port.h" | 40 #include "content/port/browser/render_widget_host_view_port.h" |
| 39 #include "content/public/browser/browser_accessibility_state.h" | 41 #include "content/public/browser/browser_accessibility_state.h" |
| 40 #include "content/public/browser/browser_context.h" | 42 #include "content/public/browser/browser_context.h" |
| 41 #include "content/public/browser/browser_message_filter.h" | 43 #include "content/public/browser/browser_message_filter.h" |
| 42 #include "content/public/browser/content_browser_client.h" | 44 #include "content/public/browser/content_browser_client.h" |
| 43 #include "content/public/browser/dom_operation_notification_details.h" | 45 #include "content/public/browser/dom_operation_notification_details.h" |
| 44 #include "content/public/browser/native_web_keyboard_event.h" | 46 #include "content/public/browser/native_web_keyboard_event.h" |
| (...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel, | 938 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel, |
| 937 OnCancelDesktopNotification) | 939 OnCancelDesktopNotification) |
| 938 #if defined(OS_MACOSX) | 940 #if defined(OS_MACOSX) |
| 939 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) | 941 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) |
| 940 #endif | 942 #endif |
| 941 IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser) | 943 IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser) |
| 942 IPC_MESSAGE_HANDLER(ViewHostMsg_DomOperationResponse, | 944 IPC_MESSAGE_HANDLER(ViewHostMsg_DomOperationResponse, |
| 943 OnDomOperationResponse) | 945 OnDomOperationResponse) |
| 944 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Notifications, | 946 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Notifications, |
| 945 OnAccessibilityNotifications) | 947 OnAccessibilityNotifications) |
| 948 IPC_MESSAGE_HANDLER(ViewHostMsg_FrameTreeUpdated, OnFrameTreeUpdated) |
| 946 // Have the super handle all other messages. | 949 // Have the super handle all other messages. |
| 947 IPC_MESSAGE_UNHANDLED( | 950 IPC_MESSAGE_UNHANDLED( |
| 948 handled = RenderWidgetHostImpl::OnMessageReceived(msg)) | 951 handled = RenderWidgetHostImpl::OnMessageReceived(msg)) |
| 949 IPC_END_MESSAGE_MAP_EX() | 952 IPC_END_MESSAGE_MAP_EX() |
| 950 | 953 |
| 951 if (!msg_is_ok) { | 954 if (!msg_is_ok) { |
| 952 // The message had a handler, but its de-serialization failed. | 955 // The message had a handler, but its de-serialization failed. |
| 953 // Kill the renderer. | 956 // Kill the renderer. |
| 954 content::RecordAction(UserMetricsAction("BadMessageTerminate_RVH")); | 957 content::RecordAction(UserMetricsAction("BadMessageTerminate_RVH")); |
| 955 GetProcess()->ReceivedBadMessage(); | 958 GetProcess()->ReceivedBadMessage(); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1140 FilterURL(policy, renderer_id, true, &validated_params.referrer.url); | 1143 FilterURL(policy, renderer_id, true, &validated_params.referrer.url); |
| 1141 for (std::vector<GURL>::iterator it(validated_params.redirects.begin()); | 1144 for (std::vector<GURL>::iterator it(validated_params.redirects.begin()); |
| 1142 it != validated_params.redirects.end(); ++it) { | 1145 it != validated_params.redirects.end(); ++it) { |
| 1143 FilterURL(policy, renderer_id, false, &(*it)); | 1146 FilterURL(policy, renderer_id, false, &(*it)); |
| 1144 } | 1147 } |
| 1145 FilterURL(policy, renderer_id, true, &validated_params.searchable_form_url); | 1148 FilterURL(policy, renderer_id, true, &validated_params.searchable_form_url); |
| 1146 FilterURL(policy, renderer_id, true, &validated_params.password_form.origin); | 1149 FilterURL(policy, renderer_id, true, &validated_params.password_form.origin); |
| 1147 FilterURL(policy, renderer_id, true, &validated_params.password_form.action); | 1150 FilterURL(policy, renderer_id, true, &validated_params.password_form.action); |
| 1148 | 1151 |
| 1149 delegate_->DidNavigate(this, validated_params); | 1152 delegate_->DidNavigate(this, validated_params); |
| 1153 |
| 1154 // For top level navigations, if there is no frame tree present for this |
| 1155 // instance (for example when the window is first created), then create |
| 1156 // an unnamed one with the proper frame id from the renderer. |
| 1157 // This should be done after we called DidNavigate, since updating the frame |
| 1158 // tree expects the render view being updated to be the active one. |
| 1159 if (content::PageTransitionIsMainFrame(validated_params.transition)) { |
| 1160 if (frame_tree_.empty()) { |
| 1161 base::DictionaryValue tree; |
| 1162 tree.SetString(content::kFrameTreeNodeNameKey, std::string()); |
| 1163 tree.SetInteger(content::kFrameTreeNodeIdKey, validated_params.frame_id); |
| 1164 base::JSONWriter::Write(&tree, &frame_tree_); |
| 1165 delegate_->DidUpdateFrameTree(this); |
| 1166 } |
| 1167 } |
| 1150 } | 1168 } |
| 1151 | 1169 |
| 1152 void RenderViewHostImpl::OnMsgUpdateState(int32 page_id, | 1170 void RenderViewHostImpl::OnMsgUpdateState(int32 page_id, |
| 1153 const std::string& state) { | 1171 const std::string& state) { |
| 1154 delegate_->UpdateState(this, page_id, state); | 1172 delegate_->UpdateState(this, page_id, state); |
| 1155 } | 1173 } |
| 1156 | 1174 |
| 1157 void RenderViewHostImpl::OnMsgUpdateTitle( | 1175 void RenderViewHostImpl::OnMsgUpdateTitle( |
| 1158 int32 page_id, | 1176 int32 page_id, |
| 1159 const string16& title, | 1177 const string16& title, |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1626 RejectMouseLockOrUnlockIfNecessary(); | 1644 RejectMouseLockOrUnlockIfNecessary(); |
| 1627 // We need to notify the contents that its fullscreen state has changed. This | 1645 // We need to notify the contents that its fullscreen state has changed. This |
| 1628 // is done as part of the resize message. | 1646 // is done as part of the resize message. |
| 1629 WasResized(); | 1647 WasResized(); |
| 1630 } | 1648 } |
| 1631 | 1649 |
| 1632 webkit_glue::WebPreferences RenderViewHostImpl::GetWebkitPreferences() { | 1650 webkit_glue::WebPreferences RenderViewHostImpl::GetWebkitPreferences() { |
| 1633 return delegate_->GetWebkitPrefs(); | 1651 return delegate_->GetWebkitPrefs(); |
| 1634 } | 1652 } |
| 1635 | 1653 |
| 1654 void RenderViewHostImpl::UpdateFrameTree( |
| 1655 int process_id, int route_id, const std::string& frame_tree) { |
| 1656 frame_tree_ = frame_tree; |
| 1657 Send(new ViewMsg_UpdateFrameTree(GetRoutingID(), |
| 1658 process_id, |
| 1659 route_id, |
| 1660 frame_tree_)); |
| 1661 } |
| 1662 |
| 1636 void RenderViewHostImpl::UpdateWebkitPreferences( | 1663 void RenderViewHostImpl::UpdateWebkitPreferences( |
| 1637 const webkit_glue::WebPreferences& prefs) { | 1664 const webkit_glue::WebPreferences& prefs) { |
| 1638 Send(new ViewMsg_UpdateWebPreferences(GetRoutingID(), prefs)); | 1665 Send(new ViewMsg_UpdateWebPreferences(GetRoutingID(), prefs)); |
| 1639 } | 1666 } |
| 1640 | 1667 |
| 1641 void RenderViewHostImpl::ClearFocusedNode() { | 1668 void RenderViewHostImpl::ClearFocusedNode() { |
| 1642 Send(new ViewMsg_ClearFocusedNode(GetRoutingID())); | 1669 Send(new ViewMsg_ClearFocusedNode(GetRoutingID())); |
| 1643 } | 1670 } |
| 1644 | 1671 |
| 1645 void RenderViewHostImpl::SetZoomLevel(double level) { | 1672 void RenderViewHostImpl::SetZoomLevel(double level) { |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1861 | 1888 |
| 1862 void RenderViewHostImpl::OnDomOperationResponse( | 1889 void RenderViewHostImpl::OnDomOperationResponse( |
| 1863 const std::string& json_string, int automation_id) { | 1890 const std::string& json_string, int automation_id) { |
| 1864 DomOperationNotificationDetails details(json_string, automation_id); | 1891 DomOperationNotificationDetails details(json_string, automation_id); |
| 1865 content::NotificationService::current()->Notify( | 1892 content::NotificationService::current()->Notify( |
| 1866 content::NOTIFICATION_DOM_OPERATION_RESPONSE, | 1893 content::NOTIFICATION_DOM_OPERATION_RESPONSE, |
| 1867 content::Source<RenderViewHost>(this), | 1894 content::Source<RenderViewHost>(this), |
| 1868 content::Details<DomOperationNotificationDetails>(&details)); | 1895 content::Details<DomOperationNotificationDetails>(&details)); |
| 1869 } | 1896 } |
| 1870 | 1897 |
| 1898 void RenderViewHostImpl::OnFrameTreeUpdated(const std::string& frame_tree) { |
| 1899 frame_tree_ = frame_tree; |
| 1900 delegate_->DidUpdateFrameTree(this); |
| 1901 } |
| 1902 |
| 1871 void RenderViewHostImpl::SetSwappedOut(bool is_swapped_out) { | 1903 void RenderViewHostImpl::SetSwappedOut(bool is_swapped_out) { |
| 1872 is_swapped_out_ = is_swapped_out; | 1904 is_swapped_out_ = is_swapped_out; |
| 1873 | 1905 |
| 1874 // Whenever we change swap out state, we should not be waiting for | 1906 // Whenever we change swap out state, we should not be waiting for |
| 1875 // beforeunload or unload acks. We clear them here to be safe, since they | 1907 // beforeunload or unload acks. We clear them here to be safe, since they |
| 1876 // can cause navigations to be ignored in OnMsgNavigate. | 1908 // can cause navigations to be ignored in OnMsgNavigate. |
| 1877 is_waiting_for_beforeunload_ack_ = false; | 1909 is_waiting_for_beforeunload_ack_ = false; |
| 1878 is_waiting_for_unload_ack_ = false; | 1910 is_waiting_for_unload_ack_ = false; |
| 1879 } | 1911 } |
| 1880 | 1912 |
| 1881 void RenderViewHostImpl::ClearPowerSaveBlockers() { | 1913 void RenderViewHostImpl::ClearPowerSaveBlockers() { |
| 1882 STLDeleteValues(&power_save_blockers_); | 1914 STLDeleteValues(&power_save_blockers_); |
| 1883 } | 1915 } |
| 1884 | 1916 |
| 1885 } // namespace content | 1917 } // namespace content |
| OLD | NEW |