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/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 #include "content/renderer/accessibility/renderer_accessibility.h" | 71 #include "content/renderer/accessibility/renderer_accessibility.h" |
72 #include "content/renderer/accessibility/renderer_accessibility_complete.h" | 72 #include "content/renderer/accessibility/renderer_accessibility_complete.h" |
73 #include "content/renderer/accessibility/renderer_accessibility_focus_only.h" | 73 #include "content/renderer/accessibility/renderer_accessibility_focus_only.h" |
74 #include "content/renderer/browser_plugin/browser_plugin.h" | 74 #include "content/renderer/browser_plugin/browser_plugin.h" |
75 #include "content/renderer/browser_plugin/browser_plugin_manager.h" | 75 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
76 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" | 76 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" |
77 #include "content/renderer/devtools/devtools_agent.h" | 77 #include "content/renderer/devtools/devtools_agent.h" |
78 #include "content/renderer/disambiguation_popup_helper.h" | 78 #include "content/renderer/disambiguation_popup_helper.h" |
79 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" | 79 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
80 #include "content/renderer/drop_data_builder.h" | 80 #include "content/renderer/drop_data_builder.h" |
81 #include "content/renderer/external_popup_menu.h" | |
82 #include "content/renderer/gpu/render_widget_compositor.h" | 81 #include "content/renderer/gpu/render_widget_compositor.h" |
83 #include "content/renderer/history_controller.h" | 82 #include "content/renderer/history_controller.h" |
84 #include "content/renderer/history_serialization.h" | 83 #include "content/renderer/history_serialization.h" |
85 #include "content/renderer/idle_user_detector.h" | 84 #include "content/renderer/idle_user_detector.h" |
86 #include "content/renderer/ime_event_guard.h" | 85 #include "content/renderer/ime_event_guard.h" |
87 #include "content/renderer/input/input_handler_manager.h" | 86 #include "content/renderer/input/input_handler_manager.h" |
88 #include "content/renderer/internal_document_state_data.h" | 87 #include "content/renderer/internal_document_state_data.h" |
89 #include "content/renderer/media/audio_device_factory.h" | 88 #include "content/renderer/media/audio_device_factory.h" |
90 #include "content/renderer/media/video_capture_impl_manager.h" | 89 #include "content/renderer/media/video_capture_impl_manager.h" |
91 #include "content/renderer/memory_benchmarking_extension.h" | 90 #include "content/renderer/memory_benchmarking_extension.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 using blink::WebConsoleMessage; | 237 using blink::WebConsoleMessage; |
239 using blink::WebData; | 238 using blink::WebData; |
240 using blink::WebDataSource; | 239 using blink::WebDataSource; |
241 using blink::WebDocument; | 240 using blink::WebDocument; |
242 using blink::WebDOMEvent; | 241 using blink::WebDOMEvent; |
243 using blink::WebDOMMessageEvent; | 242 using blink::WebDOMMessageEvent; |
244 using blink::WebDragData; | 243 using blink::WebDragData; |
245 using blink::WebDragOperation; | 244 using blink::WebDragOperation; |
246 using blink::WebDragOperationsMask; | 245 using blink::WebDragOperationsMask; |
247 using blink::WebElement; | 246 using blink::WebElement; |
248 using blink::WebExternalPopupMenu; | |
249 using blink::WebExternalPopupMenuClient; | |
250 using blink::WebFileChooserCompletion; | 247 using blink::WebFileChooserCompletion; |
251 using blink::WebFindOptions; | 248 using blink::WebFindOptions; |
252 using blink::WebFormControlElement; | 249 using blink::WebFormControlElement; |
253 using blink::WebFormElement; | 250 using blink::WebFormElement; |
254 using blink::WebFrame; | 251 using blink::WebFrame; |
255 using blink::WebGestureEvent; | 252 using blink::WebGestureEvent; |
256 using blink::WebHistoryItem; | 253 using blink::WebHistoryItem; |
257 using blink::WebHTTPBody; | 254 using blink::WebHTTPBody; |
258 using blink::WebIconURL; | 255 using blink::WebIconURL; |
259 using blink::WebImage; | 256 using blink::WebImage; |
260 using blink::WebInputElement; | 257 using blink::WebInputElement; |
261 using blink::WebInputEvent; | 258 using blink::WebInputEvent; |
262 using blink::WebLocalFrame; | 259 using blink::WebLocalFrame; |
263 using blink::WebMediaPlayerAction; | 260 using blink::WebMediaPlayerAction; |
264 using blink::WebMouseEvent; | 261 using blink::WebMouseEvent; |
265 using blink::WebNavigationPolicy; | 262 using blink::WebNavigationPolicy; |
266 using blink::WebNavigationType; | 263 using blink::WebNavigationType; |
267 using blink::WebNode; | 264 using blink::WebNode; |
268 using blink::WebPageSerializer; | 265 using blink::WebPageSerializer; |
269 using blink::WebPageSerializerClient; | 266 using blink::WebPageSerializerClient; |
270 using blink::WebPeerConnection00Handler; | 267 using blink::WebPeerConnection00Handler; |
271 using blink::WebPeerConnection00HandlerClient; | 268 using blink::WebPeerConnection00HandlerClient; |
272 using blink::WebPeerConnectionHandler; | 269 using blink::WebPeerConnectionHandler; |
273 using blink::WebPeerConnectionHandlerClient; | 270 using blink::WebPeerConnectionHandlerClient; |
274 using blink::WebPluginAction; | 271 using blink::WebPluginAction; |
275 using blink::WebPluginContainer; | 272 using blink::WebPluginContainer; |
276 using blink::WebPluginDocument; | 273 using blink::WebPluginDocument; |
277 using blink::WebPoint; | 274 using blink::WebPoint; |
278 using blink::WebPopupMenuInfo; | |
279 using blink::WebRange; | 275 using blink::WebRange; |
280 using blink::WebRect; | 276 using blink::WebRect; |
281 using blink::WebReferrerPolicy; | 277 using blink::WebReferrerPolicy; |
282 using blink::WebScriptSource; | 278 using blink::WebScriptSource; |
283 using blink::WebSearchableFormData; | 279 using blink::WebSearchableFormData; |
284 using blink::WebSecurityOrigin; | 280 using blink::WebSecurityOrigin; |
285 using blink::WebSecurityPolicy; | 281 using blink::WebSecurityPolicy; |
286 using blink::WebSerializedScriptValue; | 282 using blink::WebSerializedScriptValue; |
287 using blink::WebSettings; | 283 using blink::WebSettings; |
288 using blink::WebSize; | 284 using blink::WebSize; |
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, | 1360 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, |
1365 OnReleaseDisambiguationPopupBitmap) | 1361 OnReleaseDisambiguationPopupBitmap) |
1366 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted, | 1362 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted, |
1367 OnWindowSnapshotCompleted) | 1363 OnWindowSnapshotCompleted) |
1368 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) | 1364 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) |
1369 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) | 1365 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) |
1370 #if defined(OS_ANDROID) | 1366 #if defined(OS_ANDROID) |
1371 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, | 1367 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, |
1372 OnActivateNearestFindResult) | 1368 OnActivateNearestFindResult) |
1373 IPC_MESSAGE_HANDLER(ViewMsg_FindMatchRects, OnFindMatchRects) | 1369 IPC_MESSAGE_HANDLER(ViewMsg_FindMatchRects, OnFindMatchRects) |
1374 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) | |
1375 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, | 1370 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, |
1376 OnUpdateTopControlsState) | 1371 OnUpdateTopControlsState) |
1377 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) | 1372 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) |
1378 #elif defined(OS_MACOSX) | 1373 #elif defined(OS_MACOSX) |
1379 IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText, | 1374 IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText, |
1380 OnGetRenderedText) | 1375 OnGetRenderedText) |
1381 IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted, | 1376 IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted, |
1382 OnPluginImeCompositionCompleted) | 1377 OnPluginImeCompositionCompleted) |
1383 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) | |
1384 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) | 1378 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) |
1385 IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility) | 1379 IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility) |
1386 IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged) | 1380 IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged) |
1387 #endif | 1381 #endif |
1388 // Adding a new message? Add platform independent ones first, then put the | 1382 // Adding a new message? Add platform independent ones first, then put the |
1389 // platform specific ones at the end. | 1383 // platform specific ones at the end. |
1390 | 1384 |
1391 // Have the super handle all other messages. | 1385 // Have the super handle all other messages. |
1392 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) | 1386 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
1393 IPC_END_MESSAGE_MAP() | 1387 IPC_END_MESSAGE_MAP() |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1711 RenderWidget::Create(routing_id_, popup_type, screen_info_); | 1705 RenderWidget::Create(routing_id_, popup_type, screen_info_); |
1712 if (!widget) | 1706 if (!widget) |
1713 return NULL; | 1707 return NULL; |
1714 if (screen_metrics_emulator_) { | 1708 if (screen_metrics_emulator_) { |
1715 widget->SetPopupOriginAdjustmentsForEmulation( | 1709 widget->SetPopupOriginAdjustmentsForEmulation( |
1716 screen_metrics_emulator_.get()); | 1710 screen_metrics_emulator_.get()); |
1717 } | 1711 } |
1718 return widget->webwidget(); | 1712 return widget->webwidget(); |
1719 } | 1713 } |
1720 | 1714 |
1721 WebExternalPopupMenu* RenderViewImpl::createExternalPopupMenu( | |
1722 const WebPopupMenuInfo& popup_menu_info, | |
1723 WebExternalPopupMenuClient* popup_menu_client) { | |
1724 #if defined(OS_MACOSX) || defined(OS_ANDROID) | |
1725 // An IPC message is sent to the browser to build and display the actual | |
1726 // popup. The user could have time to click a different select by the time | |
1727 // the popup is shown. In that case external_popup_menu_ is non NULL. | |
1728 // By returning NULL in that case, we instruct WebKit to cancel that new | |
1729 // popup. So from the user perspective, only the first one will show, and | |
1730 // will have to close the first one before another one can be shown. | |
1731 if (external_popup_menu_) | |
1732 return NULL; | |
1733 external_popup_menu_.reset( | |
1734 new ExternalPopupMenu(this, popup_menu_info, popup_menu_client)); | |
1735 if (screen_metrics_emulator_) { | |
1736 SetExternalPopupOriginAdjustmentsForEmulation( | |
1737 external_popup_menu_.get(), screen_metrics_emulator_.get()); | |
1738 } | |
1739 return external_popup_menu_.get(); | |
1740 #else | |
1741 return NULL; | |
1742 #endif | |
1743 } | |
1744 | |
1745 WebStorageNamespace* RenderViewImpl::createSessionStorageNamespace() { | 1715 WebStorageNamespace* RenderViewImpl::createSessionStorageNamespace() { |
1746 CHECK(session_storage_namespace_id_ != kInvalidSessionStorageNamespaceId); | 1716 CHECK(session_storage_namespace_id_ != kInvalidSessionStorageNamespaceId); |
1747 return new WebStorageNamespaceImpl(session_storage_namespace_id_); | 1717 return new WebStorageNamespaceImpl(session_storage_namespace_id_); |
1748 } | 1718 } |
1749 | 1719 |
1750 void RenderViewImpl::printPage(WebLocalFrame* frame) { | 1720 void RenderViewImpl::printPage(WebLocalFrame* frame) { |
1751 FOR_EACH_OBSERVER(RenderViewObserver, observers_, | 1721 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
1752 PrintPage(frame, handling_input_event_)); | 1722 PrintPage(frame, handling_input_event_)); |
1753 } | 1723 } |
1754 | 1724 |
(...skipping 2281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4036 return date_time_picker_client_->Open(); | 4006 return date_time_picker_client_->Open(); |
4037 } | 4007 } |
4038 | 4008 |
4039 void RenderViewImpl::DismissDateTimeDialog() { | 4009 void RenderViewImpl::DismissDateTimeDialog() { |
4040 DCHECK(date_time_picker_client_); | 4010 DCHECK(date_time_picker_client_); |
4041 date_time_picker_client_.reset(NULL); | 4011 date_time_picker_client_.reset(NULL); |
4042 } | 4012 } |
4043 | 4013 |
4044 #endif // defined(OS_ANDROID) | 4014 #endif // defined(OS_ANDROID) |
4045 | 4015 |
4046 #if defined(OS_MACOSX) | |
4047 void RenderViewImpl::OnSelectPopupMenuItem(int selected_index) { | |
4048 if (external_popup_menu_ == NULL) | |
4049 return; | |
4050 external_popup_menu_->DidSelectItem(selected_index); | |
4051 external_popup_menu_.reset(); | |
4052 } | |
4053 #endif | |
4054 | |
4055 #if defined(OS_ANDROID) | |
4056 void RenderViewImpl::OnSelectPopupMenuItems( | |
4057 bool canceled, | |
4058 const std::vector<int>& selected_indices) { | |
4059 // It is possible to receive more than one of these calls if the user presses | |
4060 // a select faster than it takes for the show-select-popup IPC message to make | |
4061 // it to the browser UI thread. Ignore the extra-messages. | |
4062 // TODO(jcivelli): http:/b/5793321 Implement a better fix, as detailed in bug. | |
4063 if (!external_popup_menu_) | |
4064 return; | |
4065 | |
4066 external_popup_menu_->DidSelectItems(canceled, selected_indices); | |
4067 external_popup_menu_.reset(); | |
4068 } | |
4069 #endif | |
4070 | |
4071 #if defined(OS_MACOSX) || defined(OS_ANDROID) | |
4072 void RenderViewImpl::DidHideExternalPopupMenu() { | |
4073 // We need to clear external_popup_menu_ as soon as ExternalPopupMenu::close | |
4074 // is called. Otherwise, createExternalPopupMenu() for new popup will fail. | |
4075 external_popup_menu_.reset(); | |
4076 } | |
4077 #endif | |
4078 | |
4079 void RenderViewImpl::OnShowContextMenu( | 4016 void RenderViewImpl::OnShowContextMenu( |
4080 ui::MenuSourceType source_type, const gfx::Point& location) { | 4017 ui::MenuSourceType source_type, const gfx::Point& location) { |
4081 context_menu_source_type_ = source_type; | 4018 context_menu_source_type_ = source_type; |
4082 has_host_context_menu_location_ = true; | 4019 has_host_context_menu_location_ = true; |
4083 host_context_menu_location_ = location; | 4020 host_context_menu_location_ = location; |
4084 if (webview()) | 4021 if (webview()) |
4085 webview()->showContextMenu(); | 4022 webview()->showContextMenu(); |
4086 has_host_context_menu_location_ = false; | 4023 has_host_context_menu_location_ = false; |
4087 } | 4024 } |
4088 | 4025 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4264 std::vector<gfx::Size> sizes; | 4201 std::vector<gfx::Size> sizes; |
4265 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4202 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4266 if (!url.isEmpty()) | 4203 if (!url.isEmpty()) |
4267 urls.push_back( | 4204 urls.push_back( |
4268 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4205 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4269 } | 4206 } |
4270 SendUpdateFaviconURL(urls); | 4207 SendUpdateFaviconURL(urls); |
4271 } | 4208 } |
4272 | 4209 |
4273 } // namespace content | 4210 } // namespace content |
OLD | NEW |