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/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 23 matching lines...) Expand all Loading... | |
34 #include "content/browser/frame_host/navigator_impl.h" | 34 #include "content/browser/frame_host/navigator_impl.h" |
35 #include "content/browser/frame_host/render_frame_host_impl.h" | 35 #include "content/browser/frame_host/render_frame_host_impl.h" |
36 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 36 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
37 #include "content/browser/geolocation/geolocation_service_context.h" | 37 #include "content/browser/geolocation/geolocation_service_context.h" |
38 #include "content/browser/host_zoom_map_impl.h" | 38 #include "content/browser/host_zoom_map_impl.h" |
39 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 39 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
40 #include "content/browser/manifest/manifest_manager_host.h" | 40 #include "content/browser/manifest/manifest_manager_host.h" |
41 #include "content/browser/media/audio_stream_monitor.h" | 41 #include "content/browser/media/audio_stream_monitor.h" |
42 #include "content/browser/media/capture/web_contents_audio_muter.h" | 42 #include "content/browser/media/capture/web_contents_audio_muter.h" |
43 #include "content/browser/message_port_message_filter.h" | 43 #include "content/browser/message_port_message_filter.h" |
44 #include "content/browser/message_port_service.h" | |
45 #include "content/browser/plugin_content_origin_whitelist.h" | 44 #include "content/browser/plugin_content_origin_whitelist.h" |
46 #include "content/browser/power_save_blocker_impl.h" | 45 #include "content/browser/power_save_blocker_impl.h" |
47 #include "content/browser/renderer_host/render_process_host_impl.h" | 46 #include "content/browser/renderer_host/render_process_host_impl.h" |
48 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 47 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
49 #include "content/browser/renderer_host/render_view_host_impl.h" | 48 #include "content/browser/renderer_host/render_view_host_impl.h" |
50 #include "content/browser/renderer_host/render_widget_host_impl.h" | 49 #include "content/browser/renderer_host/render_widget_host_impl.h" |
51 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 50 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
52 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host_ impl.h" | 51 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host_ impl.h" |
53 #include "content/browser/site_instance_impl.h" | 52 #include "content/browser/site_instance_impl.h" |
54 #include "content/browser/web_contents/web_contents_view_guest.h" | 53 #include "content/browser/web_contents/web_contents_view_guest.h" |
(...skipping 3922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3977 // Note: This check means that an embedder could theoretically receive a | 3976 // Note: This check means that an embedder could theoretically receive a |
3978 // postMessage from anyone (not just its own guests). However, this is | 3977 // postMessage from anyone (not just its own guests). However, this is |
3979 // probably not a risk for apps since other pages won't have references | 3978 // probably not a risk for apps since other pages won't have references |
3980 // to App windows. | 3979 // to App windows. |
3981 if (!rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance()) && | 3980 if (!rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance()) && |
3982 !GetBrowserPluginGuest() && !GetBrowserPluginEmbedder()) | 3981 !GetBrowserPluginGuest() && !GetBrowserPluginEmbedder()) |
3983 return; | 3982 return; |
3984 | 3983 |
3985 ViewMsg_PostMessage_Params new_params(params); | 3984 ViewMsg_PostMessage_Params new_params(params); |
3986 | 3985 |
3987 if (!params.message_port_ids.empty()) { | |
3988 MessagePortMessageFilter* message_port_message_filter = | |
3989 static_cast<RenderProcessHostImpl*>(GetRenderProcessHost()) | |
3990 ->message_port_message_filter(); | |
3991 message_port_message_filter->UpdateMessagePortsWithNewRoutes( | |
3992 params.message_port_ids, | |
3993 &new_params.new_routing_ids); | |
3994 } | |
3995 | |
3996 // If there is a source_routing_id, translate it to the routing ID for | 3986 // If there is a source_routing_id, translate it to the routing ID for |
3997 // the equivalent swapped out RVH in the target process. If we need | 3987 // the equivalent swapped out RVH in the target process. If we need |
3998 // to create a swapped out RVH for the source tab, we create its opener | 3988 // to create a swapped out RVH for the source tab, we create its opener |
3999 // chain as well, since those will also be accessible to the target page. | 3989 // chain as well, since those will also be accessible to the target page. |
4000 if (new_params.source_routing_id != MSG_ROUTING_NONE) { | 3990 if (new_params.source_routing_id != MSG_ROUTING_NONE) { |
4001 // Try to look up the WebContents for the source page. | 3991 // Try to look up the WebContents for the source page. |
4002 WebContentsImpl* source_contents = NULL; | 3992 WebContentsImpl* source_contents = NULL; |
4003 RenderViewHostImpl* source_rvh = RenderViewHostImpl::FromID( | 3993 RenderViewHostImpl* source_rvh = RenderViewHostImpl::FromID( |
4004 rvh->GetProcess()->GetID(), params.source_routing_id); | 3994 rvh->GetProcess()->GetID(), params.source_routing_id); |
4005 if (source_rvh) { | 3995 if (source_rvh) { |
(...skipping 14 matching lines...) Expand all Loading... | |
4020 } | 4010 } |
4021 } else { | 4011 } else { |
4022 // We couldn't find it, so don't pass a source frame. | 4012 // We couldn't find it, so don't pass a source frame. |
4023 new_params.source_routing_id = MSG_ROUTING_NONE; | 4013 new_params.source_routing_id = MSG_ROUTING_NONE; |
4024 } | 4014 } |
4025 } | 4015 } |
4026 | 4016 |
4027 // In most cases, we receive this from a swapped out RenderViewHost. | 4017 // In most cases, we receive this from a swapped out RenderViewHost. |
4028 // It is possible to receive it from one that has just been swapped in, | 4018 // It is possible to receive it from one that has just been swapped in, |
4029 // in which case we might as well deliver the message anyway. | 4019 // in which case we might as well deliver the message anyway. |
4030 Send(new ViewMsg_PostMessageEvent(GetRoutingID(), new_params)); | 4020 if (!params.message_port_ids.empty()) { |
4021 // Updating the message port information has to be done in the IO thread; | |
4022 // MessagePortMessageFilter::RouteMessageEventWithMessagePorts will send | |
4023 // ViewMsg_PostMessageEvent after it's done with the updating. | |
Mike West
2015/02/18 14:20:55
Can you add something to this comment about the li
marja
2015/02/18 15:04:04
Done.
| |
4024 scoped_refptr<MessagePortMessageFilter> message_port_message_filter( | |
4025 static_cast<RenderProcessHostImpl*>(GetRenderProcessHost()) | |
4026 ->message_port_message_filter()); | |
4027 BrowserThread::PostTask( | |
4028 BrowserThread::IO, FROM_HERE, | |
4029 base::Bind(&MessagePortMessageFilter::RouteMessageEventWithMessagePorts, | |
4030 message_port_message_filter, GetRoutingID(), new_params)); | |
4031 } else { | |
4032 Send(new ViewMsg_PostMessageEvent(GetRoutingID(), new_params)); | |
4033 } | |
4031 } | 4034 } |
4032 | 4035 |
4033 bool WebContentsImpl::AddMessageToConsole(int32 level, | 4036 bool WebContentsImpl::AddMessageToConsole(int32 level, |
4034 const base::string16& message, | 4037 const base::string16& message, |
4035 int32 line_no, | 4038 int32 line_no, |
4036 const base::string16& source_id) { | 4039 const base::string16& source_id) { |
4037 if (!delegate_) | 4040 if (!delegate_) |
4038 return false; | 4041 return false; |
4039 return delegate_->AddMessageToConsole(this, level, message, line_no, | 4042 return delegate_->AddMessageToConsole(this, level, message, line_no, |
4040 source_id); | 4043 source_id); |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4506 node->render_manager()->ResumeResponseDeferredAtStart(); | 4509 node->render_manager()->ResumeResponseDeferredAtStart(); |
4507 } | 4510 } |
4508 | 4511 |
4509 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4512 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
4510 force_disable_overscroll_content_ = force_disable; | 4513 force_disable_overscroll_content_ = force_disable; |
4511 if (view_) | 4514 if (view_) |
4512 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4515 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
4513 } | 4516 } |
4514 | 4517 |
4515 } // namespace content | 4518 } // namespace content |
OLD | NEW |