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 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 void RenderViewHostImpl::DesktopNotificationPostClose(int notification_id, | 845 void RenderViewHostImpl::DesktopNotificationPostClose(int notification_id, |
846 bool by_user) { | 846 bool by_user) { |
847 Send(new DesktopNotificationMsg_PostClose( | 847 Send(new DesktopNotificationMsg_PostClose( |
848 GetRoutingID(), notification_id, by_user)); | 848 GetRoutingID(), notification_id, by_user)); |
849 } | 849 } |
850 | 850 |
851 void RenderViewHostImpl::DesktopNotificationPostClick(int notification_id) { | 851 void RenderViewHostImpl::DesktopNotificationPostClick(int notification_id) { |
852 Send(new DesktopNotificationMsg_PostClick(GetRoutingID(), notification_id)); | 852 Send(new DesktopNotificationMsg_PostClick(GetRoutingID(), notification_id)); |
853 } | 853 } |
854 | 854 |
855 void RenderViewHostImpl::ExecuteJavascriptInWebFrame( | |
856 const base::string16& frame_xpath, | |
857 const base::string16& jscript) { | |
858 Send(new ViewMsg_ScriptEvalRequest(GetRoutingID(), frame_xpath, jscript, | |
859 0, false)); | |
860 } | |
861 | |
862 void RenderViewHostImpl::ExecuteJavascriptInWebFrameCallbackResult( | |
863 const base::string16& frame_xpath, | |
864 const base::string16& jscript, | |
865 const JavascriptResultCallback& callback) { | |
866 static int next_id = 1; | |
867 int key = next_id++; | |
868 Send(new ViewMsg_ScriptEvalRequest(GetRoutingID(), frame_xpath, jscript, | |
869 key, true)); | |
870 javascript_callbacks_.insert(std::make_pair(key, callback)); | |
871 } | |
872 | |
873 void RenderViewHostImpl::JavaScriptDialogClosed( | 855 void RenderViewHostImpl::JavaScriptDialogClosed( |
874 IPC::Message* reply_msg, | 856 IPC::Message* reply_msg, |
875 bool success, | 857 bool success, |
876 const base::string16& user_input) { | 858 const base::string16& user_input) { |
877 GetProcess()->SetIgnoreInputEvents(false); | 859 GetProcess()->SetIgnoreInputEvents(false); |
878 bool is_waiting = is_waiting_for_beforeunload_ack_ || IsWaitingForUnloadACK(); | 860 bool is_waiting = is_waiting_for_beforeunload_ack_ || IsWaitingForUnloadACK(); |
879 | 861 |
880 // If we are executing as part of (before)unload event handling, we don't | 862 // If we are executing as part of (before)unload event handling, we don't |
881 // want to use the regular hung_renderer_delay_ms_ if the user has agreed to | 863 // want to use the regular hung_renderer_delay_ms_ if the user has agreed to |
882 // leave the current page. In this case, use the regular timeout value used | 864 // leave the current page. In this case, use the regular timeout value used |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) | 1101 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) |
1120 IPC_MESSAGE_HANDLER(DragHostMsg_TargetDrop_ACK, OnTargetDropACK) | 1102 IPC_MESSAGE_HANDLER(DragHostMsg_TargetDrop_ACK, OnTargetDropACK) |
1121 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) | 1103 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) |
1122 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) | 1104 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) |
1123 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) | 1105 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) |
1124 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) | 1106 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) |
1125 #if defined(OS_ANDROID) | 1107 #if defined(OS_ANDROID) |
1126 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionRootBoundsChanged, | 1108 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionRootBoundsChanged, |
1127 OnSelectionRootBoundsChanged) | 1109 OnSelectionRootBoundsChanged) |
1128 #endif | 1110 #endif |
1129 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) | |
1130 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) | 1111 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) |
1131 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission, | 1112 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission, |
1132 OnRequestDesktopNotificationPermission) | 1113 OnRequestDesktopNotificationPermission) |
1133 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show, | 1114 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show, |
1134 OnShowDesktopNotification) | 1115 OnShowDesktopNotification) |
1135 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel, | 1116 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel, |
1136 OnCancelDesktopNotification) | 1117 OnCancelDesktopNotification) |
1137 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 1118 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
1138 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup) | 1119 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup) |
1139 IPC_MESSAGE_HANDLER(ViewHostMsg_HidePopup, OnHidePopup) | 1120 IPC_MESSAGE_HANDLER(ViewHostMsg_HidePopup, OnHidePopup) |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1787 view_->CreateBrowserAccessibilityManagerIfNeeded(); | 1768 view_->CreateBrowserAccessibilityManagerIfNeeded(); |
1788 BrowserAccessibilityManager* manager = | 1769 BrowserAccessibilityManager* manager = |
1789 view_->GetBrowserAccessibilityManager(); | 1770 view_->GetBrowserAccessibilityManager(); |
1790 if (manager) | 1771 if (manager) |
1791 manager->OnLocationChanges(params); | 1772 manager->OnLocationChanges(params); |
1792 } | 1773 } |
1793 // TODO(aboxhall): send location change events to web contents observers too | 1774 // TODO(aboxhall): send location change events to web contents observers too |
1794 } | 1775 } |
1795 } | 1776 } |
1796 | 1777 |
1797 void RenderViewHostImpl::OnScriptEvalResponse(int id, | |
1798 const base::ListValue& result) { | |
1799 const base::Value* result_value; | |
1800 if (!result.Get(0, &result_value)) { | |
1801 // Programming error or rogue renderer. | |
1802 NOTREACHED() << "Got bad arguments for OnScriptEvalResponse"; | |
1803 return; | |
1804 } | |
1805 | |
1806 std::map<int, JavascriptResultCallback>::iterator it = | |
1807 javascript_callbacks_.find(id); | |
1808 if (it != javascript_callbacks_.end()) { | |
1809 // ExecuteJavascriptInWebFrameCallbackResult was used; do callback. | |
1810 it->second.Run(result_value); | |
1811 javascript_callbacks_.erase(it); | |
1812 } else { | |
1813 NOTREACHED() << "Received script response for unknown request"; | |
1814 } | |
1815 } | |
1816 | |
1817 void RenderViewHostImpl::OnDidZoomURL(double zoom_level, | 1778 void RenderViewHostImpl::OnDidZoomURL(double zoom_level, |
1818 bool remember, | 1779 bool remember, |
1819 const GURL& url) { | 1780 const GURL& url) { |
1820 HostZoomMapImpl* host_zoom_map = static_cast<HostZoomMapImpl*>( | 1781 HostZoomMapImpl* host_zoom_map = static_cast<HostZoomMapImpl*>( |
1821 HostZoomMap::GetForBrowserContext(GetProcess()->GetBrowserContext())); | 1782 HostZoomMap::GetForBrowserContext(GetProcess()->GetBrowserContext())); |
1822 if (remember) { | 1783 if (remember) { |
1823 host_zoom_map-> | 1784 host_zoom_map-> |
1824 SetZoomLevelForHost(net::GetHostOrSpecFromURL(url), zoom_level); | 1785 SetZoomLevelForHost(net::GetHostOrSpecFromURL(url), zoom_level); |
1825 } else { | 1786 } else { |
1826 host_zoom_map->SetTemporaryZoomLevel( | 1787 host_zoom_map->SetTemporaryZoomLevel( |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1922 return true; | 1883 return true; |
1923 } | 1884 } |
1924 | 1885 |
1925 void RenderViewHostImpl::AttachToFrameTree() { | 1886 void RenderViewHostImpl::AttachToFrameTree() { |
1926 FrameTree* frame_tree = delegate_->GetFrameTree(); | 1887 FrameTree* frame_tree = delegate_->GetFrameTree(); |
1927 | 1888 |
1928 frame_tree->ResetForMainFrameSwap(); | 1889 frame_tree->ResetForMainFrameSwap(); |
1929 } | 1890 } |
1930 | 1891 |
1931 } // namespace content | 1892 } // namespace content |
OLD | NEW |