| 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 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #include "content/renderer/web_intents_host.h" | 57 #include "content/renderer/web_intents_host.h" |
| 58 #include "content/renderer/java/java_bridge_dispatcher.h" | 58 #include "content/renderer/java/java_bridge_dispatcher.h" |
| 59 #include "content/renderer/load_progress_tracker.h" | 59 #include "content/renderer/load_progress_tracker.h" |
| 60 #include "content/renderer/media/audio_message_filter.h" | 60 #include "content/renderer/media/audio_message_filter.h" |
| 61 #include "content/renderer/media/audio_renderer_impl.h" | 61 #include "content/renderer/media/audio_renderer_impl.h" |
| 62 #include "content/renderer/media/media_stream_dependency_factory.h" | 62 #include "content/renderer/media/media_stream_dependency_factory.h" |
| 63 #include "content/renderer/media/media_stream_dispatcher.h" | 63 #include "content/renderer/media/media_stream_dispatcher.h" |
| 64 #include "content/renderer/media/media_stream_impl.h" | 64 #include "content/renderer/media/media_stream_impl.h" |
| 65 #include "content/renderer/media/render_media_log.h" | 65 #include "content/renderer/media/render_media_log.h" |
| 66 #include "content/renderer/mhtml_generator.h" | 66 #include "content/renderer/mhtml_generator.h" |
| 67 #include "content/renderer/mouse_lock_dispatcher.h" |
| 67 #include "content/renderer/notification_provider.h" | 68 #include "content/renderer/notification_provider.h" |
| 68 #include "content/renderer/p2p/socket_dispatcher.h" | 69 #include "content/renderer/p2p/socket_dispatcher.h" |
| 69 #include "content/renderer/plugin_channel_host.h" | 70 #include "content/renderer/plugin_channel_host.h" |
| 70 #include "content/renderer/render_audiosourceprovider.h" | 71 #include "content/renderer/render_audiosourceprovider.h" |
| 71 #include "content/renderer/render_process.h" | 72 #include "content/renderer/render_process.h" |
| 72 #include "content/renderer/render_thread_impl.h" | 73 #include "content/renderer/render_thread_impl.h" |
| 73 #include "content/renderer/render_widget_fullscreen_pepper.h" | 74 #include "content/renderer/render_widget_fullscreen_pepper.h" |
| 74 #include "content/renderer/renderer_accessibility.h" | 75 #include "content/renderer/renderer_accessibility.h" |
| 75 #include "content/renderer/renderer_gpu_video_decoder_factories.h" | 76 #include "content/renderer/renderer_gpu_video_decoder_factories.h" |
| 76 #include "content/renderer/renderer_webapplicationcachehost_impl.h" | 77 #include "content/renderer/renderer_webapplicationcachehost_impl.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 cached_has_main_frame_horizontal_scrollbar_(false), | 362 cached_has_main_frame_horizontal_scrollbar_(false), |
| 362 cached_has_main_frame_vertical_scrollbar_(false), | 363 cached_has_main_frame_vertical_scrollbar_(false), |
| 363 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), | 364 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), |
| 364 geolocation_dispatcher_(NULL), | 365 geolocation_dispatcher_(NULL), |
| 365 speech_input_dispatcher_(NULL), | 366 speech_input_dispatcher_(NULL), |
| 366 device_orientation_dispatcher_(NULL), | 367 device_orientation_dispatcher_(NULL), |
| 367 media_stream_dispatcher_(NULL), | 368 media_stream_dispatcher_(NULL), |
| 368 p2p_socket_dispatcher_(NULL), | 369 p2p_socket_dispatcher_(NULL), |
| 369 devtools_agent_(NULL), | 370 devtools_agent_(NULL), |
| 370 renderer_accessibility_(NULL), | 371 renderer_accessibility_(NULL), |
| 372 mouse_lock_dispatcher_(NULL), |
| 371 session_storage_namespace_id_(session_storage_namespace_id), | 373 session_storage_namespace_id_(session_storage_namespace_id), |
| 372 handling_select_range_(false), | 374 handling_select_range_(false), |
| 373 #if defined(OS_WIN) | 375 #if defined(OS_WIN) |
| 374 focused_plugin_id_(-1), | 376 focused_plugin_id_(-1), |
| 375 #endif | 377 #endif |
| 376 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) { | 378 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) { |
| 377 routing_id_ = routing_id; | 379 routing_id_ = routing_id; |
| 378 if (opener_id != MSG_ROUTING_NONE) | 380 if (opener_id != MSG_ROUTING_NONE) |
| 379 opener_id_ = opener_id; | 381 opener_id_ = opener_id; |
| 380 | 382 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 #endif | 433 #endif |
| 432 | 434 |
| 433 new MHTMLGenerator(this); | 435 new MHTMLGenerator(this); |
| 434 #if defined(OS_MACOSX) | 436 #if defined(OS_MACOSX) |
| 435 new TextInputClientObserver(this); | 437 new TextInputClientObserver(this); |
| 436 #endif // defined(OS_MACOSX) | 438 #endif // defined(OS_MACOSX) |
| 437 | 439 |
| 438 devtools_agent_ = new DevToolsAgent(this); | 440 devtools_agent_ = new DevToolsAgent(this); |
| 439 | 441 |
| 440 renderer_accessibility_ = new RendererAccessibility(this); | 442 renderer_accessibility_ = new RendererAccessibility(this); |
| 443 mouse_lock_dispatcher_ = new MouseLockDispatcher(this); |
| 441 | 444 |
| 442 new IdleUserDetector(this); | 445 new IdleUserDetector(this); |
| 443 | 446 |
| 444 content::GetContentClient()->renderer()->RenderViewCreated(this); | 447 content::GetContentClient()->renderer()->RenderViewCreated(this); |
| 445 } | 448 } |
| 446 | 449 |
| 447 RenderViewImpl::~RenderViewImpl() { | 450 RenderViewImpl::~RenderViewImpl() { |
| 448 history_page_ids_.clear(); | 451 history_page_ids_.clear(); |
| 449 | 452 |
| 450 if (decrement_shared_popup_at_destruction_) | 453 if (decrement_shared_popup_at_destruction_) |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 const std::string& mime_type, | 594 const std::string& mime_type, |
| 592 webkit::WebPluginInfo* plugin_info, | 595 webkit::WebPluginInfo* plugin_info, |
| 593 std::string* actual_mime_type) { | 596 std::string* actual_mime_type) { |
| 594 bool found = false; | 597 bool found = false; |
| 595 Send(new ViewHostMsg_GetPluginInfo( | 598 Send(new ViewHostMsg_GetPluginInfo( |
| 596 routing_id_, url, page_url, mime_type, &found, plugin_info, | 599 routing_id_, url, page_url, mime_type, &found, plugin_info, |
| 597 actual_mime_type)); | 600 actual_mime_type)); |
| 598 return found; | 601 return found; |
| 599 } | 602 } |
| 600 | 603 |
| 604 bool RenderViewImpl::PpapiLockMouse(webkit::ppapi::PluginInstance* plugin) { |
| 605 return mouse_lock_dispatcher_->LockMouse(NULL, plugin); |
| 606 } |
| 607 |
| 608 void RenderViewImpl::PpapiUnlockMouse( |
| 609 webkit::ppapi::PluginInstance* plugin) { |
| 610 mouse_lock_dispatcher_->UnlockMouse(NULL, plugin); |
| 611 } |
| 612 |
| 613 bool RenderViewImpl::PpapiIsMouseLockedTo( |
| 614 webkit::ppapi::PluginInstance* plugin) { |
| 615 return mouse_lock_dispatcher_->IsMouseLockedTo(plugin); |
| 616 } |
| 617 |
| 601 bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { | 618 bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { |
| 602 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; | 619 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; |
| 603 if (main_frame) | 620 if (main_frame) |
| 604 content::GetContentClient()->SetActiveURL(main_frame->document().url()); | 621 content::GetContentClient()->SetActiveURL(main_frame->document().url()); |
| 605 | 622 |
| 606 ObserverListBase<RenderViewObserver>::Iterator it(observers_); | 623 ObserverListBase<RenderViewObserver>::Iterator it(observers_); |
| 607 RenderViewObserver* observer; | 624 RenderViewObserver* observer; |
| 608 while ((observer = it.GetNext()) != NULL) | 625 while ((observer = it.GetNext()) != NULL) |
| 609 if (observer->OnMessageReceived(message)) | 626 if (observer->OnMessageReceived(message)) |
| 610 return true; | 627 return true; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 // TODO(viettrungluu): Move to a separate message filter. | 721 // TODO(viettrungluu): Move to a separate message filter. |
| 705 #if defined(ENABLE_FLAPPER_HACKS) | 722 #if defined(ENABLE_FLAPPER_HACKS) |
| 706 IPC_MESSAGE_HANDLER(PepperMsg_ConnectTcpACK, OnConnectTcpACK) | 723 IPC_MESSAGE_HANDLER(PepperMsg_ConnectTcpACK, OnConnectTcpACK) |
| 707 #endif | 724 #endif |
| 708 #if defined(OS_MACOSX) | 725 #if defined(OS_MACOSX) |
| 709 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) | 726 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) |
| 710 #endif | 727 #endif |
| 711 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, | 728 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, |
| 712 OnSetHistoryLengthAndPrune) | 729 OnSetHistoryLengthAndPrune) |
| 713 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) | 730 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
| 714 IPC_MESSAGE_HANDLER(ViewMsg_LockMouse_ACK, OnLockMouseACK) | |
| 715 IPC_MESSAGE_HANDLER(ViewMsg_MouseLockLost, OnMouseLockLost) | |
| 716 IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit) | 731 IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit) |
| 717 | 732 |
| 718 // Have the super handle all other messages. | 733 // Have the super handle all other messages. |
| 719 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) | 734 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
| 720 IPC_END_MESSAGE_MAP() | 735 IPC_END_MESSAGE_MAP() |
| 721 | 736 |
| 722 if (!msg_is_ok) { | 737 if (!msg_is_ok) { |
| 723 // The message had a handler, but its deserialization failed. | 738 // The message had a handler, but its deserialization failed. |
| 724 // Kill the renderer to avoid potential spoofing attacks. | 739 // Kill the renderer to avoid potential spoofing attacks. |
| 725 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; | 740 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; |
| (...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1882 | 1897 |
| 1883 bool RenderViewImpl::enterFullScreen() { | 1898 bool RenderViewImpl::enterFullScreen() { |
| 1884 Send(new ViewHostMsg_ToggleFullscreen(routing_id_, true)); | 1899 Send(new ViewHostMsg_ToggleFullscreen(routing_id_, true)); |
| 1885 return true; | 1900 return true; |
| 1886 } | 1901 } |
| 1887 | 1902 |
| 1888 void RenderViewImpl::exitFullScreen() { | 1903 void RenderViewImpl::exitFullScreen() { |
| 1889 Send(new ViewHostMsg_ToggleFullscreen(routing_id_, false)); | 1904 Send(new ViewHostMsg_ToggleFullscreen(routing_id_, false)); |
| 1890 } | 1905 } |
| 1891 | 1906 |
| 1907 bool RenderViewImpl::requestPointerLock() { |
| 1908 return mouse_lock_dispatcher_->LockMouse(webwidget(), NULL); |
| 1909 } |
| 1910 |
| 1911 void RenderViewImpl::requestPointerUnlock() { |
| 1912 mouse_lock_dispatcher_->UnlockMouse(webwidget(), NULL); |
| 1913 } |
| 1914 |
| 1915 bool RenderViewImpl::isPointerLocked() { |
| 1916 return mouse_lock_dispatcher_->IsPointerLockedTo(webwidget()); |
| 1917 } |
| 1918 |
| 1892 // WebKit::WebFrameClient ----------------------------------------------------- | 1919 // WebKit::WebFrameClient ----------------------------------------------------- |
| 1893 | 1920 |
| 1894 WebPlugin* RenderViewImpl::createPlugin(WebFrame* frame, | 1921 WebPlugin* RenderViewImpl::createPlugin(WebFrame* frame, |
| 1895 const WebPluginParams& params) { | 1922 const WebPluginParams& params) { |
| 1896 WebPlugin* plugin = NULL; | 1923 WebPlugin* plugin = NULL; |
| 1897 if (content::GetContentClient()->renderer()->OverrideCreatePlugin( | 1924 if (content::GetContentClient()->renderer()->OverrideCreatePlugin( |
| 1898 this, frame, params, &plugin)) { | 1925 this, frame, params, &plugin)) { |
| 1899 return plugin; | 1926 return plugin; |
| 1900 } | 1927 } |
| 1901 | 1928 |
| (...skipping 2429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4331 WebView* doomed = webview(); | 4358 WebView* doomed = webview(); |
| 4332 RenderWidget::Close(); | 4359 RenderWidget::Close(); |
| 4333 g_view_map.Get().erase(doomed); | 4360 g_view_map.Get().erase(doomed); |
| 4334 } | 4361 } |
| 4335 | 4362 |
| 4336 void RenderViewImpl::DidHandleKeyEvent() { | 4363 void RenderViewImpl::DidHandleKeyEvent() { |
| 4337 edit_commands_.clear(); | 4364 edit_commands_.clear(); |
| 4338 } | 4365 } |
| 4339 | 4366 |
| 4340 bool RenderViewImpl::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 4367 bool RenderViewImpl::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
| 4341 return pepper_delegate_.HandleMouseEvent(event); | 4368 pepper_delegate_.WillHandleMouseEvent(); |
| 4369 |
| 4370 // If the mouse is locked, only the current owner of the mouse lock can |
| 4371 // process mouse events. |
| 4372 return mouse_lock_dispatcher_->WillHandleMouseEvent(event); |
| 4342 } | 4373 } |
| 4343 | 4374 |
| 4344 void RenderViewImpl::DidHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 4375 void RenderViewImpl::DidHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
| 4345 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleMouseEvent(event)); | 4376 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleMouseEvent(event)); |
| 4346 } | 4377 } |
| 4347 | 4378 |
| 4348 void RenderViewImpl::DidHandleTouchEvent(const WebTouchEvent& event) { | 4379 void RenderViewImpl::DidHandleTouchEvent(const WebTouchEvent& event) { |
| 4349 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleTouchEvent(event)); | 4380 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleTouchEvent(event)); |
| 4350 } | 4381 } |
| 4351 | 4382 |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4840 | 4871 |
| 4841 void RenderViewImpl::OnEnableViewSourceMode() { | 4872 void RenderViewImpl::OnEnableViewSourceMode() { |
| 4842 if (!webview()) | 4873 if (!webview()) |
| 4843 return; | 4874 return; |
| 4844 WebFrame* main_frame = webview()->mainFrame(); | 4875 WebFrame* main_frame = webview()->mainFrame(); |
| 4845 if (!main_frame) | 4876 if (!main_frame) |
| 4846 return; | 4877 return; |
| 4847 main_frame->enableViewSourceMode(true); | 4878 main_frame->enableViewSourceMode(true); |
| 4848 } | 4879 } |
| 4849 | 4880 |
| 4850 void RenderViewImpl::OnLockMouseACK(bool succeeded) { | |
| 4851 // Mouse Lock removes the system cursor and provides all mouse motion as | |
| 4852 // .movementX/Y values on events all sent to a fixed target. This requires | |
| 4853 // content to specifically request the mode to be entered. | |
| 4854 // Mouse Capture is implicitly given for the duration of a drag event, and | |
| 4855 // sends all mouse events to the initial target of the drag. | |
| 4856 // If Lock is entered it supercedes any in progress Capture. | |
| 4857 if (succeeded) | |
| 4858 OnMouseCaptureLost(); | |
| 4859 | |
| 4860 pepper_delegate_.OnLockMouseACK(succeeded); | |
| 4861 } | |
| 4862 | |
| 4863 void RenderViewImpl::OnMouseLockLost() { | |
| 4864 pepper_delegate_.OnMouseLockLost(); | |
| 4865 } | |
| 4866 | |
| 4867 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { | 4881 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
| 4868 return !!RenderThreadImpl::current()->compositor_thread(); | 4882 return !!RenderThreadImpl::current()->compositor_thread(); |
| 4869 } | 4883 } |
| 4870 | 4884 |
| 4871 void RenderViewImpl::OnJavaBridgeInit() { | 4885 void RenderViewImpl::OnJavaBridgeInit() { |
| 4872 DCHECK(!java_bridge_dispatcher_.get()); | 4886 DCHECK(!java_bridge_dispatcher_.get()); |
| 4873 #if defined(ENABLE_JAVA_BRIDGE) | 4887 #if defined(ENABLE_JAVA_BRIDGE) |
| 4874 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); | 4888 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); |
| 4875 #endif | 4889 #endif |
| 4876 } | 4890 } |
| OLD | NEW |