| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 270 |
| 270 static const size_t kExtraCharsBeforeAndAfterSelection = 100; | 271 static const size_t kExtraCharsBeforeAndAfterSelection = 100; |
| 271 | 272 |
| 272 // The maximum number of popups that can be spawned from one page. | 273 // The maximum number of popups that can be spawned from one page. |
| 273 static const int kMaximumNumberOfUnacknowledgedPopups = 25; | 274 static const int kMaximumNumberOfUnacknowledgedPopups = 25; |
| 274 | 275 |
| 275 static const float kScalingIncrement = 0.1f; | 276 static const float kScalingIncrement = 0.1f; |
| 276 | 277 |
| 277 static const float kScalingIncrementForGesture = 0.01f; | 278 static const float kScalingIncrementForGesture = 0.01f; |
| 278 | 279 |
| 280 static const char* kPredefinedAllowedSocketOrigins[] = { |
| 281 "okddffdblfhhnmhodogpojmfkjmhinfp" |
| 282 }; |
| 283 |
| 279 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { | 284 static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { |
| 280 WebVector<WebURL> urls; | 285 WebVector<WebURL> urls; |
| 281 ds->redirectChain(urls); | 286 ds->redirectChain(urls); |
| 282 result->reserve(urls.size()); | 287 result->reserve(urls.size()); |
| 283 for (size_t i = 0; i < urls.size(); ++i) | 288 for (size_t i = 0; i < urls.size(); ++i) |
| 284 result->push_back(urls[i]); | 289 result->push_back(urls[i]); |
| 285 } | 290 } |
| 286 | 291 |
| 287 // If |data_source| is non-null and has a DocumentState associated with it, | 292 // If |data_source| is non-null and has a DocumentState associated with it, |
| 288 // the AltErrorPageResourceFetcher is reset. | 293 // the AltErrorPageResourceFetcher is reset. |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 renderer_accessibility_ = new RendererAccessibility(this); | 422 renderer_accessibility_ = new RendererAccessibility(this); |
| 418 | 423 |
| 419 new IdleUserDetector(this); | 424 new IdleUserDetector(this); |
| 420 | 425 |
| 421 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 426 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 422 if (command_line.HasSwitch(switches::kEnableMediaStream)) { | 427 if (command_line.HasSwitch(switches::kEnableMediaStream)) { |
| 423 media_stream_impl_ = new MediaStreamImpl( | 428 media_stream_impl_ = new MediaStreamImpl( |
| 424 RenderThreadImpl::current()->video_capture_impl_manager()); | 429 RenderThreadImpl::current()->video_capture_impl_manager()); |
| 425 } | 430 } |
| 426 | 431 |
| 432 for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i) |
| 433 allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]); |
| 434 |
| 435 std::string allowed_list = |
| 436 command_line.GetSwitchValueASCII(switches::kAllowNaClSocketAPI); |
| 437 if (!allowed_list.empty()) { |
| 438 StringTokenizer t(allowed_list, ","); |
| 439 while (t.GetNext()) { |
| 440 allowed_socket_origins_.insert(t.token()); |
| 441 } |
| 442 } |
| 443 |
| 427 content::GetContentClient()->renderer()->RenderViewCreated(this); | 444 content::GetContentClient()->renderer()->RenderViewCreated(this); |
| 428 } | 445 } |
| 429 | 446 |
| 430 RenderViewImpl::~RenderViewImpl() { | 447 RenderViewImpl::~RenderViewImpl() { |
| 431 history_page_ids_.clear(); | 448 history_page_ids_.clear(); |
| 432 | 449 |
| 433 if (decrement_shared_popup_at_destruction_) | 450 if (decrement_shared_popup_at_destruction_) |
| 434 shared_popup_counter_->data--; | 451 shared_popup_counter_->data--; |
| 435 | 452 |
| 436 // If file chooser is still waiting for answer, dispatch empty answer. | 453 // If file chooser is still waiting for answer, dispatch empty answer. |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 const std::string& mime_type, | 586 const std::string& mime_type, |
| 570 webkit::WebPluginInfo* plugin_info, | 587 webkit::WebPluginInfo* plugin_info, |
| 571 std::string* actual_mime_type) { | 588 std::string* actual_mime_type) { |
| 572 bool found = false; | 589 bool found = false; |
| 573 Send(new ViewHostMsg_GetPluginInfo( | 590 Send(new ViewHostMsg_GetPluginInfo( |
| 574 routing_id_, url, page_url, mime_type, &found, plugin_info, | 591 routing_id_, url, page_url, mime_type, &found, plugin_info, |
| 575 actual_mime_type)); | 592 actual_mime_type)); |
| 576 return found; | 593 return found; |
| 577 } | 594 } |
| 578 | 595 |
| 596 bool RenderViewImpl::CanUseSocketAPIs() { |
| 597 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; |
| 598 GURL url(main_frame ? GURL(main_frame->document().url()) : GURL()); |
| 599 if (!url.is_valid()) |
| 600 return false; |
| 601 |
| 602 return allowed_socket_origins_.find(url.host()) != |
| 603 allowed_socket_origins_.end(); |
| 604 } |
| 605 |
| 579 bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { | 606 bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { |
| 580 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; | 607 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; |
| 581 if (main_frame) | 608 if (main_frame) |
| 582 content::GetContentClient()->SetActiveURL(main_frame->document().url()); | 609 content::GetContentClient()->SetActiveURL(main_frame->document().url()); |
| 583 | 610 |
| 584 ObserverListBase<RenderViewObserver>::Iterator it(observers_); | 611 ObserverListBase<RenderViewObserver>::Iterator it(observers_); |
| 585 RenderViewObserver* observer; | 612 RenderViewObserver* observer; |
| 586 while ((observer = it.GetNext()) != NULL) | 613 while ((observer = it.GetNext()) != NULL) |
| 587 if (observer->OnMessageReceived(message)) | 614 if (observer->OnMessageReceived(message)) |
| 588 return true; | 615 return true; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, | 703 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, |
| 677 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) | 704 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) |
| 678 #if defined(OS_MACOSX) | 705 #if defined(OS_MACOSX) |
| 679 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) | 706 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) |
| 680 #endif | 707 #endif |
| 681 IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) | 708 IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) |
| 682 // TODO(viettrungluu): Move to a separate message filter. | 709 // TODO(viettrungluu): Move to a separate message filter. |
| 683 #if defined(ENABLE_FLAPPER_HACKS) | 710 #if defined(ENABLE_FLAPPER_HACKS) |
| 684 IPC_MESSAGE_HANDLER(PepperMsg_ConnectTcpACK, OnConnectTcpACK) | 711 IPC_MESSAGE_HANDLER(PepperMsg_ConnectTcpACK, OnConnectTcpACK) |
| 685 #endif | 712 #endif |
| 713 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ConnectACK, |
| 714 OnTCPSocketConnectACK) |
| 715 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_SSLHandshakeACK, |
| 716 OnTCPSocketSSLHandshakeACK) |
| 717 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_ReadACK, OnTCPSocketReadACK) |
| 718 IPC_MESSAGE_HANDLER(PpapiMsg_PPBTCPSocket_WriteACK, OnTCPSocketWriteACK) |
| 719 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_BindACK, OnUDPSocketBindACK) |
| 720 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_RecvFromACK, |
| 721 OnUDPSocketRecvFromACK) |
| 722 IPC_MESSAGE_HANDLER(PpapiMsg_PPBUDPSocket_SendToACK, OnUDPSocketSendToACK) |
| 686 #if defined(OS_MACOSX) | 723 #if defined(OS_MACOSX) |
| 687 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) | 724 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) |
| 688 #endif | 725 #endif |
| 689 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, | 726 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, |
| 690 OnSetHistoryLengthAndPrune) | 727 OnSetHistoryLengthAndPrune) |
| 691 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) | 728 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
| 692 IPC_MESSAGE_HANDLER(ViewMsg_LockMouse_ACK, OnLockMouseACK) | 729 IPC_MESSAGE_HANDLER(ViewMsg_LockMouse_ACK, OnLockMouseACK) |
| 693 IPC_MESSAGE_HANDLER(ViewMsg_MouseLockLost, OnMouseLockLost) | 730 IPC_MESSAGE_HANDLER(ViewMsg_MouseLockLost, OnMouseLockLost) |
| 694 IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit) | 731 IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit) |
| 695 | 732 |
| (...skipping 3990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4686 const PP_NetAddress_Private& local_addr, | 4723 const PP_NetAddress_Private& local_addr, |
| 4687 const PP_NetAddress_Private& remote_addr) { | 4724 const PP_NetAddress_Private& remote_addr) { |
| 4688 pepper_delegate_.OnConnectTcpACK( | 4725 pepper_delegate_.OnConnectTcpACK( |
| 4689 request_id, | 4726 request_id, |
| 4690 IPC::PlatformFileForTransitToPlatformFile(socket_for_transit), | 4727 IPC::PlatformFileForTransitToPlatformFile(socket_for_transit), |
| 4691 local_addr, | 4728 local_addr, |
| 4692 remote_addr); | 4729 remote_addr); |
| 4693 } | 4730 } |
| 4694 #endif | 4731 #endif |
| 4695 | 4732 |
| 4733 void RenderViewImpl::OnTCPSocketConnectACK( |
| 4734 uint32 /* plugin_dispatcher_id */, |
| 4735 uint32 socket_id, |
| 4736 bool succeeded, |
| 4737 const PP_NetAddress_Private& local_addr, |
| 4738 const PP_NetAddress_Private& remote_addr) { |
| 4739 pepper_delegate_.OnTCPSocketConnectACK( |
| 4740 socket_id, succeeded, local_addr, remote_addr); |
| 4741 } |
| 4742 |
| 4743 void RenderViewImpl::OnTCPSocketSSLHandshakeACK( |
| 4744 uint32 /* plugin_dispatcher_id */, |
| 4745 uint32 socket_id, |
| 4746 bool succeeded) { |
| 4747 pepper_delegate_.OnTCPSocketSSLHandshakeACK(socket_id, succeeded); |
| 4748 } |
| 4749 |
| 4750 void RenderViewImpl::OnTCPSocketReadACK(uint32 /* plugin_dispatcher_id */, |
| 4751 uint32 socket_id, |
| 4752 bool succeeded, |
| 4753 const std::string& data) { |
| 4754 pepper_delegate_.OnTCPSocketReadACK(socket_id, succeeded, data); |
| 4755 } |
| 4756 |
| 4757 void RenderViewImpl::OnTCPSocketWriteACK(uint32 /* plugin_dispatcher_id */, |
| 4758 uint32 socket_id, |
| 4759 bool succeeded, |
| 4760 int32_t bytes_written) { |
| 4761 pepper_delegate_.OnTCPSocketWriteACK(socket_id, succeeded, bytes_written); |
| 4762 } |
| 4763 |
| 4764 void RenderViewImpl::OnUDPSocketBindACK(uint32 /* plugin_dispatcher_id */, |
| 4765 uint32 socket_id, |
| 4766 bool succeeded) { |
| 4767 pepper_delegate_.OnUDPSocketBindACK(socket_id, succeeded); |
| 4768 } |
| 4769 |
| 4770 void RenderViewImpl::OnUDPSocketRecvFromACK( |
| 4771 uint32 /* plugin_dispatcher_id */, |
| 4772 uint32 socket_id, |
| 4773 bool succeeded, |
| 4774 const std::string& data, |
| 4775 const PP_NetAddress_Private& remote_addr) { |
| 4776 pepper_delegate_.OnUDPSocketRecvFromACK(socket_id, |
| 4777 succeeded, |
| 4778 data, |
| 4779 remote_addr); |
| 4780 } |
| 4781 |
| 4782 void RenderViewImpl::OnUDPSocketSendToACK(uint32 /* plugin_dispatcher_id */, |
| 4783 uint32 socket_id, |
| 4784 bool succeeded, |
| 4785 int32_t bytes_written) { |
| 4786 pepper_delegate_.OnUDPSocketSendToACK(socket_id, succeeded, bytes_written); |
| 4787 } |
| 4788 |
| 4696 void RenderViewImpl::OnContextMenuClosed( | 4789 void RenderViewImpl::OnContextMenuClosed( |
| 4697 const webkit_glue::CustomContextMenuContext& custom_context) { | 4790 const webkit_glue::CustomContextMenuContext& custom_context) { |
| 4698 if (custom_context.is_pepper_menu) | 4791 if (custom_context.is_pepper_menu) |
| 4699 pepper_delegate_.OnContextMenuClosed(custom_context); | 4792 pepper_delegate_.OnContextMenuClosed(custom_context); |
| 4700 else | 4793 else |
| 4701 context_menu_node_.reset(); | 4794 context_menu_node_.reset(); |
| 4702 } | 4795 } |
| 4703 | 4796 |
| 4704 void RenderViewImpl::OnEnableViewSourceMode() { | 4797 void RenderViewImpl::OnEnableViewSourceMode() { |
| 4705 if (!webview()) | 4798 if (!webview()) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 4731 return !!RenderThreadImpl::current()->compositor_thread(); | 4824 return !!RenderThreadImpl::current()->compositor_thread(); |
| 4732 } | 4825 } |
| 4733 | 4826 |
| 4734 void RenderViewImpl::OnJavaBridgeInit( | 4827 void RenderViewImpl::OnJavaBridgeInit( |
| 4735 const IPC::ChannelHandle& channel_handle) { | 4828 const IPC::ChannelHandle& channel_handle) { |
| 4736 DCHECK(!java_bridge_dispatcher_.get()); | 4829 DCHECK(!java_bridge_dispatcher_.get()); |
| 4737 #if defined(ENABLE_JAVA_BRIDGE) | 4830 #if defined(ENABLE_JAVA_BRIDGE) |
| 4738 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); | 4831 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); |
| 4739 #endif | 4832 #endif |
| 4740 } | 4833 } |
| OLD | NEW |