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 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1367 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, | 1363 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, |
1368 OnReleaseDisambiguationPopupBitmap) | 1364 OnReleaseDisambiguationPopupBitmap) |
1369 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted, | 1365 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted, |
1370 OnWindowSnapshotCompleted) | 1366 OnWindowSnapshotCompleted) |
1371 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) | 1367 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) |
1372 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) | 1368 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) |
1373 #if defined(OS_ANDROID) | 1369 #if defined(OS_ANDROID) |
1374 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, | 1370 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, |
1375 OnActivateNearestFindResult) | 1371 OnActivateNearestFindResult) |
1376 IPC_MESSAGE_HANDLER(ViewMsg_FindMatchRects, OnFindMatchRects) | 1372 IPC_MESSAGE_HANDLER(ViewMsg_FindMatchRects, OnFindMatchRects) |
1377 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) | |
1378 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, | 1373 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, |
1379 OnUpdateTopControlsState) | 1374 OnUpdateTopControlsState) |
1380 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) | 1375 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) |
1381 #elif defined(OS_MACOSX) | 1376 #elif defined(OS_MACOSX) |
1382 IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText, | 1377 IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText, |
1383 OnGetRenderedText) | 1378 OnGetRenderedText) |
1384 IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted, | 1379 IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted, |
1385 OnPluginImeCompositionCompleted) | 1380 OnPluginImeCompositionCompleted) |
1386 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) | |
1387 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) | 1381 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) |
1388 IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility) | 1382 IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility) |
1389 IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged) | 1383 IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged) |
1390 #endif | 1384 #endif |
1391 // Adding a new message? Add platform independent ones first, then put the | 1385 // Adding a new message? Add platform independent ones first, then put the |
1392 // platform specific ones at the end. | 1386 // platform specific ones at the end. |
1393 | 1387 |
1394 // Have the super handle all other messages. | 1388 // Have the super handle all other messages. |
1395 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) | 1389 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
1396 IPC_END_MESSAGE_MAP() | 1390 IPC_END_MESSAGE_MAP() |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1714 RenderWidget::Create(routing_id_, popup_type, screen_info_); | 1708 RenderWidget::Create(routing_id_, popup_type, screen_info_); |
1715 if (!widget) | 1709 if (!widget) |
1716 return NULL; | 1710 return NULL; |
1717 if (screen_metrics_emulator_) { | 1711 if (screen_metrics_emulator_) { |
1718 widget->SetPopupOriginAdjustmentsForEmulation( | 1712 widget->SetPopupOriginAdjustmentsForEmulation( |
1719 screen_metrics_emulator_.get()); | 1713 screen_metrics_emulator_.get()); |
1720 } | 1714 } |
1721 return widget->webwidget(); | 1715 return widget->webwidget(); |
1722 } | 1716 } |
1723 | 1717 |
1724 WebExternalPopupMenu* RenderViewImpl::createExternalPopupMenu( | |
1725 const WebPopupMenuInfo& popup_menu_info, | |
1726 WebExternalPopupMenuClient* popup_menu_client) { | |
1727 #if defined(OS_MACOSX) || defined(OS_ANDROID) | |
1728 // An IPC message is sent to the browser to build and display the actual | |
1729 // popup. The user could have time to click a different select by the time | |
1730 // the popup is shown. In that case external_popup_menu_ is non NULL. | |
1731 // By returning NULL in that case, we instruct WebKit to cancel that new | |
1732 // popup. So from the user perspective, only the first one will show, and | |
1733 // will have to close the first one before another one can be shown. | |
1734 if (external_popup_menu_) | |
1735 return NULL; | |
1736 external_popup_menu_.reset( | |
1737 new ExternalPopupMenu(this, popup_menu_info, popup_menu_client)); | |
1738 if (screen_metrics_emulator_) { | |
1739 SetExternalPopupOriginAdjustmentsForEmulation( | |
1740 external_popup_menu_.get(), screen_metrics_emulator_.get()); | |
1741 } | |
1742 return external_popup_menu_.get(); | |
1743 #else | |
1744 return NULL; | |
1745 #endif | |
1746 } | |
1747 | |
1748 WebStorageNamespace* RenderViewImpl::createSessionStorageNamespace() { | 1718 WebStorageNamespace* RenderViewImpl::createSessionStorageNamespace() { |
1749 CHECK(session_storage_namespace_id_ != kInvalidSessionStorageNamespaceId); | 1719 CHECK(session_storage_namespace_id_ != kInvalidSessionStorageNamespaceId); |
1750 return new WebStorageNamespaceImpl(session_storage_namespace_id_); | 1720 return new WebStorageNamespaceImpl(session_storage_namespace_id_); |
1751 } | 1721 } |
1752 | 1722 |
1753 void RenderViewImpl::printPage(WebLocalFrame* frame) { | 1723 void RenderViewImpl::printPage(WebLocalFrame* frame) { |
1754 FOR_EACH_OBSERVER(RenderViewObserver, observers_, | 1724 FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
1755 PrintPage(frame, handling_input_event_)); | 1725 PrintPage(frame, handling_input_event_)); |
1756 } | 1726 } |
1757 | 1727 |
(...skipping 2277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4035 return date_time_picker_client_->Open(); | 4005 return date_time_picker_client_->Open(); |
4036 } | 4006 } |
4037 | 4007 |
4038 void RenderViewImpl::DismissDateTimeDialog() { | 4008 void RenderViewImpl::DismissDateTimeDialog() { |
4039 DCHECK(date_time_picker_client_); | 4009 DCHECK(date_time_picker_client_); |
4040 date_time_picker_client_.reset(NULL); | 4010 date_time_picker_client_.reset(NULL); |
4041 } | 4011 } |
4042 | 4012 |
4043 #endif // defined(OS_ANDROID) | 4013 #endif // defined(OS_ANDROID) |
4044 | 4014 |
4045 #if defined(OS_MACOSX) | |
4046 void RenderViewImpl::OnSelectPopupMenuItem(int selected_index) { | |
4047 if (external_popup_menu_ == NULL) | |
4048 return; | |
4049 external_popup_menu_->DidSelectItem(selected_index); | |
4050 external_popup_menu_.reset(); | |
4051 } | |
4052 #endif | |
4053 | |
4054 #if defined(OS_ANDROID) | |
4055 void RenderViewImpl::OnSelectPopupMenuItems( | |
4056 bool canceled, | |
4057 const std::vector<int>& selected_indices) { | |
4058 // It is possible to receive more than one of these calls if the user presses | |
4059 // a select faster than it takes for the show-select-popup IPC message to make | |
4060 // it to the browser UI thread. Ignore the extra-messages. | |
4061 // TODO(jcivelli): http:/b/5793321 Implement a better fix, as detailed in bug. | |
4062 if (!external_popup_menu_) | |
4063 return; | |
4064 | |
4065 external_popup_menu_->DidSelectItems(canceled, selected_indices); | |
4066 external_popup_menu_.reset(); | |
4067 } | |
4068 #endif | |
4069 | |
4070 #if defined(OS_MACOSX) || defined(OS_ANDROID) | |
4071 void RenderViewImpl::DidHideExternalPopupMenu() { | |
4072 // We need to clear external_popup_menu_ as soon as ExternalPopupMenu::close | |
4073 // is called. Otherwise, createExternalPopupMenu() for new popup will fail. | |
4074 external_popup_menu_.reset(); | |
4075 } | |
4076 #endif | |
4077 | |
4078 void RenderViewImpl::OnShowContextMenu( | 4015 void RenderViewImpl::OnShowContextMenu( |
4079 ui::MenuSourceType source_type, const gfx::Point& location) { | 4016 ui::MenuSourceType source_type, const gfx::Point& location) { |
4080 context_menu_source_type_ = source_type; | 4017 context_menu_source_type_ = source_type; |
4081 has_host_context_menu_location_ = true; | 4018 has_host_context_menu_location_ = true; |
4082 host_context_menu_location_ = location; | 4019 host_context_menu_location_ = location; |
4083 if (webview()) | 4020 if (webview()) |
4084 webview()->showContextMenu(); | 4021 webview()->showContextMenu(); |
4085 has_host_context_menu_location_ = false; | 4022 has_host_context_menu_location_ = false; |
4086 } | 4023 } |
4087 | 4024 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4272 std::vector<gfx::Size> sizes; | 4209 std::vector<gfx::Size> sizes; |
4273 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); | 4210 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
4274 if (!url.isEmpty()) | 4211 if (!url.isEmpty()) |
4275 urls.push_back( | 4212 urls.push_back( |
4276 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); | 4213 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
4277 } | 4214 } |
4278 SendUpdateFaviconURL(urls); | 4215 SendUpdateFaviconURL(urls); |
4279 } | 4216 } |
4280 | 4217 |
4281 } // namespace content | 4218 } // namespace content |
OLD | NEW |