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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 using blink::WebDragOperation; | 102 using blink::WebDragOperation; |
103 using blink::WebDragOperationNone; | 103 using blink::WebDragOperationNone; |
104 using blink::WebDragOperationsMask; | 104 using blink::WebDragOperationsMask; |
105 using blink::WebInputEvent; | 105 using blink::WebInputEvent; |
106 using blink::WebMediaPlayerAction; | 106 using blink::WebMediaPlayerAction; |
107 using blink::WebPluginAction; | 107 using blink::WebPluginAction; |
108 | 108 |
109 namespace content { | 109 namespace content { |
110 namespace { | 110 namespace { |
111 | 111 |
112 // Translate a WebKit text direction into a base::i18n one. | |
113 base::i18n::TextDirection WebTextDirectionToChromeTextDirection( | |
114 blink::WebTextDirection dir) { | |
115 switch (dir) { | |
116 case blink::WebTextDirectionLeftToRight: | |
117 return base::i18n::LEFT_TO_RIGHT; | |
118 case blink::WebTextDirectionRightToLeft: | |
119 return base::i18n::RIGHT_TO_LEFT; | |
120 default: | |
121 NOTREACHED(); | |
122 return base::i18n::UNKNOWN_DIRECTION; | |
123 } | |
124 } | |
125 | |
126 #if defined(OS_WIN) | 112 #if defined(OS_WIN) |
127 | 113 |
128 const int kVirtualKeyboardDisplayWaitTimeoutMs = 100; | 114 const int kVirtualKeyboardDisplayWaitTimeoutMs = 100; |
129 const int kMaxVirtualKeyboardDisplayRetries = 5; | 115 const int kMaxVirtualKeyboardDisplayRetries = 5; |
130 | 116 |
131 void DismissVirtualKeyboardTask() { | 117 void DismissVirtualKeyboardTask() { |
132 static int virtual_keyboard_display_retries = 0; | 118 static int virtual_keyboard_display_retries = 0; |
133 // If the virtual keyboard is not yet visible, then we execute the task again | 119 // If the virtual keyboard is not yet visible, then we execute the task again |
134 // waiting for it to show up. | 120 // waiting for it to show up. |
135 if (!base::win::DismissVirtualKeyboard()) { | 121 if (!base::win::DismissVirtualKeyboard()) { |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 bool msg_is_ok = true; | 972 bool msg_is_ok = true; |
987 IPC_BEGIN_MESSAGE_MAP_EX(RenderViewHostImpl, msg, msg_is_ok) | 973 IPC_BEGIN_MESSAGE_MAP_EX(RenderViewHostImpl, msg, msg_is_ok) |
988 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowView, OnShowView) | 974 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowView, OnShowView) |
989 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) | 975 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) |
990 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowFullscreenWidget, | 976 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowFullscreenWidget, |
991 OnShowFullscreenWidget) | 977 OnShowFullscreenWidget) |
992 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunModal, OnRunModal) | 978 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunModal, OnRunModal) |
993 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnRenderViewReady) | 979 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnRenderViewReady) |
994 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderProcessGone, OnRenderProcessGone) | 980 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderProcessGone, OnRenderProcessGone) |
995 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateState, OnUpdateState) | 981 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateState, OnUpdateState) |
996 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTitle, OnUpdateTitle) | |
997 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateEncoding, OnUpdateEncoding) | |
998 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTargetURL, OnUpdateTargetURL) | 982 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTargetURL, OnUpdateTargetURL) |
999 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateInspectorSetting, | 983 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateInspectorSetting, |
1000 OnUpdateInspectorSetting) | 984 OnUpdateInspectorSetting) |
1001 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnClose) | 985 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnClose) |
1002 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnRequestMove) | 986 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnRequestMove) |
1003 IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeLoadProgress, | 987 IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeLoadProgress, |
1004 OnDidChangeLoadProgress) | 988 OnDidChangeLoadProgress) |
1005 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentAvailableInMainFrame, | 989 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentAvailableInMainFrame, |
1006 OnDocumentAvailableInMainFrame) | 990 OnDocumentAvailableInMainFrame) |
1007 IPC_MESSAGE_HANDLER(ViewHostMsg_ToggleFullscreen, OnToggleFullscreen) | 991 IPC_MESSAGE_HANDLER(ViewHostMsg_ToggleFullscreen, OnToggleFullscreen) |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1176 // Without this check, the renderer can trick the browser into using | 1160 // Without this check, the renderer can trick the browser into using |
1177 // filenames it can't access in a future session restore. | 1161 // filenames it can't access in a future session restore. |
1178 if (!CanAccessFilesOfPageState(state)) { | 1162 if (!CanAccessFilesOfPageState(state)) { |
1179 GetProcess()->ReceivedBadMessage(); | 1163 GetProcess()->ReceivedBadMessage(); |
1180 return; | 1164 return; |
1181 } | 1165 } |
1182 | 1166 |
1183 delegate_->UpdateState(this, page_id, state); | 1167 delegate_->UpdateState(this, page_id, state); |
1184 } | 1168 } |
1185 | 1169 |
1186 void RenderViewHostImpl::OnUpdateTitle( | |
1187 int32 page_id, | |
1188 const base::string16& title, | |
1189 blink::WebTextDirection title_direction) { | |
1190 if (title.length() > kMaxTitleChars) { | |
1191 NOTREACHED() << "Renderer sent too many characters in title."; | |
1192 return; | |
1193 } | |
1194 | |
1195 delegate_->UpdateTitle(this, page_id, title, | |
1196 WebTextDirectionToChromeTextDirection( | |
1197 title_direction)); | |
1198 } | |
1199 | |
1200 void RenderViewHostImpl::OnUpdateEncoding(const std::string& encoding_name) { | |
1201 delegate_->UpdateEncoding(this, encoding_name); | |
1202 } | |
1203 | |
1204 void RenderViewHostImpl::OnUpdateTargetURL(int32 page_id, const GURL& url) { | 1170 void RenderViewHostImpl::OnUpdateTargetURL(int32 page_id, const GURL& url) { |
1205 if (IsRVHStateActive(rvh_state_)) | 1171 if (IsRVHStateActive(rvh_state_)) |
1206 delegate_->UpdateTargetURL(page_id, url); | 1172 delegate_->UpdateTargetURL(page_id, url); |
1207 | 1173 |
1208 // Send a notification back to the renderer that we are ready to | 1174 // Send a notification back to the renderer that we are ready to |
1209 // receive more target urls. | 1175 // receive more target urls. |
1210 Send(new ViewMsg_UpdateTargetURL_ACK(GetRoutingID())); | 1176 Send(new ViewMsg_UpdateTargetURL_ACK(GetRoutingID())); |
1211 } | 1177 } |
1212 | 1178 |
1213 void RenderViewHostImpl::OnUpdateInspectorSetting( | 1179 void RenderViewHostImpl::OnUpdateInspectorSetting( |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1727 return true; | 1693 return true; |
1728 } | 1694 } |
1729 | 1695 |
1730 void RenderViewHostImpl::AttachToFrameTree() { | 1696 void RenderViewHostImpl::AttachToFrameTree() { |
1731 FrameTree* frame_tree = delegate_->GetFrameTree(); | 1697 FrameTree* frame_tree = delegate_->GetFrameTree(); |
1732 | 1698 |
1733 frame_tree->ResetForMainFrameSwap(); | 1699 frame_tree->ResetForMainFrameSwap(); |
1734 } | 1700 } |
1735 | 1701 |
1736 } // namespace content | 1702 } // namespace content |
OLD | NEW |