Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 8688002: PPB_TCPSocket_Private/PPB_UDPSocket_Private are exposed to Browser (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed issues. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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"
brettw 2011/12/02 03:56:14 What is this?
Dmitry Polukhin 2011/12/05 11:29:06 Added comment.
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
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);
jam 2011/12/01 19:50:31 here and in the header, please don't mention nacl
Dmitry Polukhin 2011/12/02 11:37:33 Will do it in next cl, see my replay in header.
Dmitry Polukhin 2011/12/05 11:29:06 Done.
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
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
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 4009 matching lines...) Expand 10 before | Expand all | Expand 10 after
4707 const PP_NetAddress_Private& local_addr, 4744 const PP_NetAddress_Private& local_addr,
4708 const PP_NetAddress_Private& remote_addr) { 4745 const PP_NetAddress_Private& remote_addr) {
4709 pepper_delegate_.OnConnectTcpACK( 4746 pepper_delegate_.OnConnectTcpACK(
4710 request_id, 4747 request_id,
4711 IPC::PlatformFileForTransitToPlatformFile(socket_for_transit), 4748 IPC::PlatformFileForTransitToPlatformFile(socket_for_transit),
4712 local_addr, 4749 local_addr,
4713 remote_addr); 4750 remote_addr);
4714 } 4751 }
4715 #endif 4752 #endif
4716 4753
4754 void RenderViewImpl::OnTCPSocketConnectACK(
4755 uint32 /* plugin_dispatcher_id */,
jam 2011/12/01 19:50:31 nit: here and below, commenting out parameter name
Dmitry Polukhin 2011/12/02 11:37:33 Done.
4756 uint32 socket_id,
4757 bool succeeded,
4758 const PP_NetAddress_Private& local_addr,
4759 const PP_NetAddress_Private& remote_addr) {
4760 pepper_delegate_.OnTCPSocketConnectACK(
brettw 2011/12/02 03:56:14 Is it possible to add a filter from the pepper del
Dmitry Polukhin 2011/12/02 11:37:33 Potential yes but not in given time frame before b
Dmitry Polukhin 2011/12/05 11:29:06 RenderViewObserver is huge interface but for messa
4761 socket_id, succeeded, local_addr, remote_addr);
4762 }
4763
4764 void RenderViewImpl::OnTCPSocketSSLHandshakeACK(
4765 uint32 /* plugin_dispatcher_id */,
4766 uint32 socket_id,
4767 bool succeeded) {
4768 pepper_delegate_.OnTCPSocketSSLHandshakeACK(socket_id, succeeded);
4769 }
4770
4771 void RenderViewImpl::OnTCPSocketReadACK(uint32 /* plugin_dispatcher_id */,
4772 uint32 socket_id,
4773 bool succeeded,
4774 const std::string& data) {
4775 pepper_delegate_.OnTCPSocketReadACK(socket_id, succeeded, data);
4776 }
4777
4778 void RenderViewImpl::OnTCPSocketWriteACK(uint32 /* plugin_dispatcher_id */,
4779 uint32 socket_id,
4780 bool succeeded,
4781 int32_t bytes_written) {
4782 pepper_delegate_.OnTCPSocketWriteACK(socket_id, succeeded, bytes_written);
4783 }
4784
4785 void RenderViewImpl::OnUDPSocketBindACK(uint32 /* plugin_dispatcher_id */,
4786 uint32 socket_id,
4787 bool succeeded) {
4788 pepper_delegate_.OnUDPSocketBindACK(socket_id, succeeded);
4789 }
4790
4791 void RenderViewImpl::OnUDPSocketRecvFromACK(
4792 uint32 /* plugin_dispatcher_id */,
4793 uint32 socket_id,
4794 bool succeeded,
4795 const std::string& data,
4796 const PP_NetAddress_Private& remote_addr) {
4797 pepper_delegate_.OnUDPSocketRecvFromACK(socket_id,
4798 succeeded,
4799 data,
4800 remote_addr);
4801 }
4802
4803 void RenderViewImpl::OnUDPSocketSendToACK(uint32 /* plugin_dispatcher_id */,
4804 uint32 socket_id,
4805 bool succeeded,
4806 int32_t bytes_written) {
4807 pepper_delegate_.OnUDPSocketSendToACK(socket_id, succeeded, bytes_written);
4808 }
4809
4717 void RenderViewImpl::OnContextMenuClosed( 4810 void RenderViewImpl::OnContextMenuClosed(
4718 const webkit_glue::CustomContextMenuContext& custom_context) { 4811 const webkit_glue::CustomContextMenuContext& custom_context) {
4719 if (custom_context.is_pepper_menu) 4812 if (custom_context.is_pepper_menu)
4720 pepper_delegate_.OnContextMenuClosed(custom_context); 4813 pepper_delegate_.OnContextMenuClosed(custom_context);
4721 else 4814 else
4722 context_menu_node_.reset(); 4815 context_menu_node_.reset();
4723 } 4816 }
4724 4817
4725 void RenderViewImpl::OnEnableViewSourceMode() { 4818 void RenderViewImpl::OnEnableViewSourceMode() {
4726 if (!webview()) 4819 if (!webview())
(...skipping 25 matching lines...) Expand all
4752 return !!RenderThreadImpl::current()->compositor_thread(); 4845 return !!RenderThreadImpl::current()->compositor_thread();
4753 } 4846 }
4754 4847
4755 void RenderViewImpl::OnJavaBridgeInit( 4848 void RenderViewImpl::OnJavaBridgeInit(
4756 const IPC::ChannelHandle& channel_handle) { 4849 const IPC::ChannelHandle& channel_handle) {
4757 DCHECK(!java_bridge_dispatcher_.get()); 4850 DCHECK(!java_bridge_dispatcher_.get());
4758 #if defined(ENABLE_JAVA_BRIDGE) 4851 #if defined(ENABLE_JAVA_BRIDGE)
4759 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); 4852 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle));
4760 #endif 4853 #endif
4761 } 4854 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698