OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 #include "content/renderer/web_ui_bindings.h" | 77 #include "content/renderer/web_ui_bindings.h" |
78 #include "content/renderer/webplugin_delegate_proxy.h" | 78 #include "content/renderer/webplugin_delegate_proxy.h" |
79 #include "content/renderer/websharedworker_proxy.h" | 79 #include "content/renderer/websharedworker_proxy.h" |
80 #include "media/base/filter_collection.h" | 80 #include "media/base/filter_collection.h" |
81 #include "media/base/media_switches.h" | 81 #include "media/base/media_switches.h" |
82 #include "media/base/message_loop_factory_impl.h" | 82 #include "media/base/message_loop_factory_impl.h" |
83 #include "net/base/escape.h" | 83 #include "net/base/escape.h" |
84 #include "net/base/net_errors.h" | 84 #include "net/base/net_errors.h" |
85 #include "net/http/http_util.h" | 85 #include "net/http/http_util.h" |
86 #include "ppapi/c/private/ppb_flash_net_connector.h" | 86 #include "ppapi/c/private/ppb_flash_net_connector.h" |
| 87 #include "ppapi/proxy/ppapi_messages.h" |
87 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec
t.h" | 88 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec
t.h" |
88 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" | 89 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" |
89 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" | 90 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" |
90 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 91 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
91 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragData.h" | 92 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragData.h" |
92 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 93 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
93 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.
h" | 94 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.
h" |
94 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback
s.h" | 95 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallback
s.h" |
95 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" | 96 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" |
96 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement
.h" | 97 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement
.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 272 |
272 static const size_t kExtraCharsBeforeAndAfterSelection = 100; | 273 static const size_t kExtraCharsBeforeAndAfterSelection = 100; |
273 | 274 |
274 // The maximum number of popups that can be spawned from one page. | 275 // The maximum number of popups that can be spawned from one page. |
275 static const int kMaximumNumberOfUnacknowledgedPopups = 25; | 276 static const int kMaximumNumberOfUnacknowledgedPopups = 25; |
276 | 277 |
277 static const float kScalingIncrement = 0.1f; | 278 static const float kScalingIncrement = 0.1f; |
278 | 279 |
279 static const float kScalingIncrementForGesture = 0.01f; | 280 static const float kScalingIncrementForGesture = 0.01f; |
280 | 281 |
| 282 static const char* kPredefinedAllowedSocketOrigins[] = { |
| 283 "okddffdblfhhnmhodogpojmfkjmhinfp" |
| 284 }; |
| 285 |
281 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { | 286 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { |
282 WebVector<WebURL> urls; | 287 WebVector<WebURL> urls; |
283 ds->redirectChain(urls); | 288 ds->redirectChain(urls); |
284 result->reserve(urls.size()); | 289 result->reserve(urls.size()); |
285 for (size_t i = 0; i < urls.size(); ++i) | 290 for (size_t i = 0; i < urls.size(); ++i) |
286 result->push_back(urls[i]); | 291 result->push_back(urls[i]); |
287 } | 292 } |
288 | 293 |
289 // If |data_source| is non-null and has a DocumentState associated with it, | 294 // If |data_source| is non-null and has a DocumentState associated with it, |
290 // the AltErrorPageResourceFetcher is reset. | 295 // the AltErrorPageResourceFetcher is reset. |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 renderer_accessibility_ = new RendererAccessibility(this); | 424 renderer_accessibility_ = new RendererAccessibility(this); |
420 | 425 |
421 new IdleUserDetector(this); | 426 new IdleUserDetector(this); |
422 | 427 |
423 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 428 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
424 if (command_line.HasSwitch(switches::kEnableMediaStream)) { | 429 if (command_line.HasSwitch(switches::kEnableMediaStream)) { |
425 media_stream_impl_ = new MediaStreamImpl( | 430 media_stream_impl_ = new MediaStreamImpl( |
426 RenderThreadImpl::current()->video_capture_impl_manager()); | 431 RenderThreadImpl::current()->video_capture_impl_manager()); |
427 } | 432 } |
428 | 433 |
| 434 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) |
| 435 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); |
| 436 |
| 437 std::string allowed_list = |
| 438 command_line.GetSwitchValueASCII(switches::kAllowNaClSocketAPI); |
| 439 if (!allowed_list.empty()) { |
| 440 StringTokenizer t(allowed_list, ","); |
| 441 while (t.GetNext()) { |
| 442 allowed_socket_origins_.insert(t.token()); |
| 443 } |
| 444 } |
| 445 |
429 content::GetContentClient()->renderer()->RenderViewCreated(this); | 446 content::GetContentClient()->renderer()->RenderViewCreated(this); |
430 } | 447 } |
431 | 448 |
432 RenderViewImpl::~RenderViewImpl() { | 449 RenderViewImpl::~RenderViewImpl() { |
433 history_page_ids_.clear(); | 450 history_page_ids_.clear(); |
434 | 451 |
435 if (decrement_shared_popup_at_destruction_) | 452 if (decrement_shared_popup_at_destruction_) |
436 shared_popup_counter_->data--; | 453 shared_popup_counter_->data--; |
437 | 454 |
438 // If file chooser is still waiting for answer, dispatch empty answer. | 455 // If file chooser is still waiting for answer, dispatch empty answer. |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 const std::string& mime_type, | 588 const std::string& mime_type, |
572 webkit::WebPluginInfo* plugin_info, | 589 webkit::WebPluginInfo* plugin_info, |
573 std::string* actual_mime_type) { | 590 std::string* actual_mime_type) { |
574 bool found = false; | 591 bool found = false; |
575 Send(new ViewHostMsg_GetPluginInfo( | 592 Send(new ViewHostMsg_GetPluginInfo( |
576 routing_id_, url, page_url, mime_type, &found, plugin_info, | 593 routing_id_, url, page_url, mime_type, &found, plugin_info, |
577 actual_mime_type)); | 594 actual_mime_type)); |
578 return found; | 595 return found; |
579 } | 596 } |
580 | 597 |
| 598 bool RenderViewImpl::CanUseSocketAPIs() { |
| 599 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; |
| 600 GURL url(main_frame ? GURL(main_frame->document().url()) : GURL()); |
| 601 if (!url.is_valid()) |
| 602 return false; |
| 603 |
| 604 return allowed_socket_origins_.find(url.host()) != |
| 605 allowed_socket_origins_.end(); |
| 606 } |
| 607 |
581 bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { | 608 bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { |
582 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; | 609 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; |
583 if (main_frame) | 610 if (main_frame) |
584 content::GetContentClient()->SetActiveURL(main_frame->document().url()); | 611 content::GetContentClient()->SetActiveURL(main_frame->document().url()); |
585 | 612 |
586 ObserverListBase<RenderViewObserver>::Iterator it(observers_); | 613 ObserverListBase<RenderViewObserver>::Iterator it(observers_); |
587 RenderViewObserver* observer; | 614 RenderViewObserver* observer; |
588 while ((observer = it.GetNext()) != NULL) | 615 while ((observer = it.GetNext()) != NULL) |
589 if (observer->OnMessageReceived(message)) | 616 if (observer->OnMessageReceived(message)) |
590 return true; | 617 return true; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, | 705 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, |
679 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) | 706 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) |
680 #if defined(OS_MACOSX) | 707 #if defined(OS_MACOSX) |
681 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) | 708 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) |
682 #endif | 709 #endif |
683 IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) | 710 IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) |
684 // TODO(viettrungluu): Move to a separate message filter. | 711 // TODO(viettrungluu): Move to a separate message filter. |
685 #if defined(ENABLE_FLAPPER_HACKS) | 712 #if defined(ENABLE_FLAPPER_HACKS) |
686 IPC_MESSAGE_HANDLER(PepperMsg_ConnectTcpACK, OnConnectTcpACK) | 713 IPC_MESSAGE_HANDLER(PepperMsg_ConnectTcpACK, OnConnectTcpACK) |
687 #endif | 714 #endif |
| 715 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, |
| 716 OnTCPSocketConnectACK) |
| 717 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, |
| 718 OnTCPSocketSSLHandshakeACK) |
| 719 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK) |
| 720 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK) |
| 721 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_BindACK, OnUDPSocketBindACK) |
| 722 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_RecvFromACK, |
| 723 OnUDPSocketRecvFromACK) |
| 724 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_SendToACK, OnUDPSocketSendToACK) |
688 #if defined(OS_MACOSX) | 725 #if defined(OS_MACOSX) |
689 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) | 726 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) |
690 #endif | 727 #endif |
691 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, | 728 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, |
692 OnSetHistoryLengthAndPrune) | 729 OnSetHistoryLengthAndPrune) |
693 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) | 730 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
694 IPC_MESSAGE_HANDLER(ViewMsg_LockMouse_ACK, OnLockMouseACK) | 731 IPC_MESSAGE_HANDLER(ViewMsg_LockMouse_ACK, OnLockMouseACK) |
695 IPC_MESSAGE_HANDLER(ViewMsg_MouseLockLost, OnMouseLockLost) | 732 IPC_MESSAGE_HANDLER(ViewMsg_MouseLockLost, OnMouseLockLost) |
696 IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit) | 733 IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit) |
697 | 734 |
(...skipping 4006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4704 const PP_NetAddress_Private& local_addr, | 4741 const PP_NetAddress_Private& local_addr, |
4705 const PP_NetAddress_Private& remote_addr) { | 4742 const PP_NetAddress_Private& remote_addr) { |
4706 pepper_delegate_.OnConnectTcpACK( | 4743 pepper_delegate_.OnConnectTcpACK( |
4707 request_id, | 4744 request_id, |
4708 IPC::PlatformFileForTransitToPlatformFile(socket_for_transit), | 4745 IPC::PlatformFileForTransitToPlatformFile(socket_for_transit), |
4709 local_addr, | 4746 local_addr, |
4710 remote_addr); | 4747 remote_addr); |
4711 } | 4748 } |
4712 #endif | 4749 #endif |
4713 | 4750 |
| 4751 void RenderViewImpl::OnTCPSocketConnectACK( |
| 4752 uint32 /* plugin_dispatcher_id */, |
| 4753 uint32 socket_id, |
| 4754 bool succeeded, |
| 4755 const PP_NetAddress_Private& local_addr, |
| 4756 const PP_NetAddress_Private& remote_addr) { |
| 4757 pepper_delegate_.OnTCPSocketConnectACK( |
| 4758 socket_id, succeeded, local_addr, remote_addr); |
| 4759 } |
| 4760 |
| 4761 void RenderViewImpl::OnTCPSocketSSLHandshakeACK( |
| 4762 uint32 /* plugin_dispatcher_id */, |
| 4763 uint32 socket_id, |
| 4764 bool succeeded) { |
| 4765 pepper_delegate_.OnTCPSocketSSLHandshakeACK(socket_id, succeeded); |
| 4766 } |
| 4767 |
| 4768 void RenderViewImpl::OnTCPSocketReadACK(uint32 /* plugin_dispatcher_id */, |
| 4769 uint32 socket_id, |
| 4770 bool succeeded, |
| 4771 const std::string& data) { |
| 4772 pepper_delegate_.OnTCPSocketReadACK(socket_id, succeeded, data); |
| 4773 } |
| 4774 |
| 4775 void RenderViewImpl::OnTCPSocketWriteACK(uint32 /* plugin_dispatcher_id */, |
| 4776 uint32 socket_id, |
| 4777 bool succeeded, |
| 4778 int32_t bytes_written) { |
| 4779 pepper_delegate_.OnTCPSocketWriteACK(socket_id, succeeded, bytes_written); |
| 4780 } |
| 4781 |
| 4782 void RenderViewImpl::OnUDPSocketBindACK(uint32 /* plugin_dispatcher_id */, |
| 4783 uint32 socket_id, |
| 4784 bool succeeded) { |
| 4785 pepper_delegate_.OnUDPSocketBindACK(socket_id, succeeded); |
| 4786 } |
| 4787 |
| 4788 void RenderViewImpl::OnUDPSocketRecvFromACK( |
| 4789 uint32 /* plugin_dispatcher_id */, |
| 4790 uint32 socket_id, |
| 4791 bool succeeded, |
| 4792 const std::string& data, |
| 4793 const PP_NetAddress_Private& remote_addr) { |
| 4794 pepper_delegate_.OnUDPSocketRecvFromACK(socket_id, |
| 4795 succeeded, |
| 4796 data, |
| 4797 remote_addr); |
| 4798 } |
| 4799 |
| 4800 void RenderViewImpl::OnUDPSocketSendToACK(uint32 /* plugin_dispatcher_id */, |
| 4801 uint32 socket_id, |
| 4802 bool succeeded, |
| 4803 int32_t bytes_written) { |
| 4804 pepper_delegate_.OnUDPSocketSendToACK(socket_id, succeeded, bytes_written); |
| 4805 } |
| 4806 |
4714 void RenderViewImpl::OnContextMenuClosed( | 4807 void RenderViewImpl::OnContextMenuClosed( |
4715 const webkit_glue::CustomContextMenuContext& custom_context) { | 4808 const webkit_glue::CustomContextMenuContext& custom_context) { |
4716 if (custom_context.is_pepper_menu) | 4809 if (custom_context.is_pepper_menu) |
4717 pepper_delegate_.OnContextMenuClosed(custom_context); | 4810 pepper_delegate_.OnContextMenuClosed(custom_context); |
4718 else | 4811 else |
4719 context_menu_node_.reset(); | 4812 context_menu_node_.reset(); |
4720 } | 4813 } |
4721 | 4814 |
4722 void RenderViewImpl::OnEnableViewSourceMode() { | 4815 void RenderViewImpl::OnEnableViewSourceMode() { |
4723 if (!webview()) | 4816 if (!webview()) |
(...skipping 25 matching lines...) Expand all Loading... |
4749 return !!RenderThreadImpl::current()->compositor_thread(); | 4842 return !!RenderThreadImpl::current()->compositor_thread(); |
4750 } | 4843 } |
4751 | 4844 |
4752 void RenderViewImpl::OnJavaBridgeInit( | 4845 void RenderViewImpl::OnJavaBridgeInit( |
4753 const IPC::ChannelHandle& channel_handle) { | 4846 const IPC::ChannelHandle& channel_handle) { |
4754 DCHECK(!java_bridge_dispatcher_.get()); | 4847 DCHECK(!java_bridge_dispatcher_.get()); |
4755 #if defined(ENABLE_JAVA_BRIDGE) | 4848 #if defined(ENABLE_JAVA_BRIDGE) |
4756 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); | 4849 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); |
4757 #endif | 4850 #endif |
4758 } | 4851 } |
OLD | NEW |