OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/frame_host/cross_process_frame_connector.h" | 5 #include "content/browser/frame_host/cross_process_frame_connector.h" |
6 | 6 |
7 #include "content/browser/frame_host/render_frame_host_impl.h" | 7 #include "content/browser/frame_host/render_frame_host_impl.h" |
8 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 8 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
9 #include "content/browser/renderer_host/render_widget_host_impl.h" | 9 #include "content/browser/renderer_host/render_widget_host_impl.h" |
10 #include "content/common/frame_messages.h" | 10 #include "content/common/frame_messages.h" |
11 #include "content/common/gpu/gpu_messages.h" | 11 #include "content/common/gpu/gpu_messages.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 | 14 |
15 CrossProcessFrameConnector::CrossProcessFrameConnector( | 15 CrossProcessFrameConnector::CrossProcessFrameConnector( |
16 RenderFrameHostImpl* frame_proxy_in_parent_renderer) | 16 RenderFrameHostImpl* frame_proxy_in_parent_renderer) |
17 : frame_proxy_in_parent_renderer_(frame_proxy_in_parent_renderer), | 17 : frame_proxy_in_parent_renderer_(frame_proxy_in_parent_renderer), |
18 view_(NULL) { | 18 view_(NULL), |
| 19 device_scale_factor_(1) { |
19 frame_proxy_in_parent_renderer->set_cross_process_frame_connector(this); | 20 frame_proxy_in_parent_renderer->set_cross_process_frame_connector(this); |
20 } | 21 } |
21 | 22 |
22 CrossProcessFrameConnector::~CrossProcessFrameConnector() { | 23 CrossProcessFrameConnector::~CrossProcessFrameConnector() { |
23 if (view_) | 24 if (view_) |
24 view_->set_cross_process_frame_connector(NULL); | 25 view_->set_cross_process_frame_connector(NULL); |
25 } | 26 } |
26 | 27 |
27 bool CrossProcessFrameConnector::OnMessageReceived(const IPC::Message& msg) { | 28 bool CrossProcessFrameConnector::OnMessageReceived(const IPC::Message& msg) { |
28 bool handled = true; | 29 bool handled = true; |
29 bool msg_is_ok = true; | 30 bool msg_is_ok = true; |
30 | 31 |
31 IPC_BEGIN_MESSAGE_MAP_EX(CrossProcessFrameConnector, msg, msg_is_ok) | 32 IPC_BEGIN_MESSAGE_MAP_EX(CrossProcessFrameConnector, msg, msg_is_ok) |
32 IPC_MESSAGE_HANDLER(FrameHostMsg_BuffersSwappedACK, OnBuffersSwappedACK) | 33 IPC_MESSAGE_HANDLER(FrameHostMsg_BuffersSwappedACK, OnBuffersSwappedACK) |
33 IPC_MESSAGE_HANDLER(FrameHostMsg_CompositorFrameSwappedACK, | 34 IPC_MESSAGE_HANDLER(FrameHostMsg_CompositorFrameSwappedACK, |
34 OnCompositorFrameSwappedACK) | 35 OnCompositorFrameSwappedACK) |
35 IPC_MESSAGE_HANDLER(FrameHostMsg_ReclaimCompositorResources, | 36 IPC_MESSAGE_HANDLER(FrameHostMsg_ReclaimCompositorResources, |
36 OnReclaimCompositorResources) | 37 OnReclaimCompositorResources) |
| 38 IPC_MESSAGE_HANDLER(FrameHostMsg_InitializeChildFrame, |
| 39 OnInitializeChildFrame) |
37 IPC_MESSAGE_UNHANDLED(handled = false) | 40 IPC_MESSAGE_UNHANDLED(handled = false) |
38 IPC_END_MESSAGE_MAP_EX() | 41 IPC_END_MESSAGE_MAP_EX() |
39 | 42 |
40 return handled; | 43 return handled; |
41 } | 44 } |
42 | 45 |
43 void CrossProcessFrameConnector::set_view( | 46 void CrossProcessFrameConnector::set_view( |
44 RenderWidgetHostViewChildFrame* view) { | 47 RenderWidgetHostViewChildFrame* view) { |
45 // Detach ourselves from the previous |view_|. | 48 // Detach ourselves from the previous |view_|. |
46 if (view_) | 49 if (view_) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 112 } |
110 | 113 |
111 void CrossProcessFrameConnector::OnReclaimCompositorResources( | 114 void CrossProcessFrameConnector::OnReclaimCompositorResources( |
112 const FrameHostMsg_ReclaimCompositorResources_Params& params) { | 115 const FrameHostMsg_ReclaimCompositorResources_Params& params) { |
113 RenderWidgetHostImpl::SendReclaimCompositorResources(params.route_id, | 116 RenderWidgetHostImpl::SendReclaimCompositorResources(params.route_id, |
114 params.output_surface_id, | 117 params.output_surface_id, |
115 params.renderer_host_id, | 118 params.renderer_host_id, |
116 params.ack); | 119 params.ack); |
117 } | 120 } |
118 | 121 |
| 122 void CrossProcessFrameConnector::OnInitializeChildFrame(gfx::Rect frame_rect, |
| 123 float scale_factor) { |
| 124 if (scale_factor != device_scale_factor_) { |
| 125 device_scale_factor_ = scale_factor; |
| 126 if (view_) { |
| 127 RenderWidgetHostImpl* child_widget = |
| 128 RenderWidgetHostImpl::From(view_->GetRenderWidgetHost()); |
| 129 child_widget->NotifyScreenInfoChanged(); |
| 130 } |
| 131 } |
| 132 |
| 133 if (!frame_rect.size().IsEmpty()) { |
| 134 child_frame_rect_ = frame_rect; |
| 135 if (view_) |
| 136 view_->SetSize(frame_rect.size()); |
| 137 } |
| 138 } |
| 139 |
119 gfx::Rect CrossProcessFrameConnector::ChildFrameRect() { | 140 gfx::Rect CrossProcessFrameConnector::ChildFrameRect() { |
120 return child_frame_rect_; | 141 return child_frame_rect_; |
121 } | 142 } |
122 | 143 |
123 } // namespace content | 144 } // namespace content |
OLD | NEW |