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/renderer_host/render_widget_helper.h" | 5 #include "content/browser/renderer_host/render_widget_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/posix/eintr_wrapper.h" | 10 #include "base/posix/eintr_wrapper.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 this, | 81 this, |
82 request_id)); | 82 request_id)); |
83 } | 83 } |
84 | 84 |
85 void RenderWidgetHelper::OnResumeDeferredNavigation( | 85 void RenderWidgetHelper::OnResumeDeferredNavigation( |
86 const GlobalRequestID& request_id) { | 86 const GlobalRequestID& request_id) { |
87 resource_dispatcher_host_->ResumeDeferredNavigation(request_id); | 87 resource_dispatcher_host_->ResumeDeferredNavigation(request_id); |
88 } | 88 } |
89 | 89 |
90 void RenderWidgetHelper::CreateNewWindow( | 90 void RenderWidgetHelper::CreateNewWindow( |
91 const ViewHostMsg_CreateWindow_Params& params, | 91 mojom::CreateNewWindowParamsPtr params, |
92 bool no_javascript_access, | 92 bool no_javascript_access, |
93 base::ProcessHandle render_process, | 93 base::ProcessHandle render_process, |
94 int32_t* route_id, | 94 int32_t* route_id, |
95 int32_t* main_frame_route_id, | 95 int32_t* main_frame_route_id, |
96 int32_t* main_frame_widget_route_id, | 96 int32_t* main_frame_widget_route_id, |
97 SessionStorageNamespace* session_storage_namespace) { | 97 SessionStorageNamespace* session_storage_namespace) { |
98 if (params.opener_suppressed || no_javascript_access) { | 98 if (params->opener_suppressed || no_javascript_access) { |
99 // If the opener is supppressed or script access is disallowed, we should | 99 // If the opener is supppressed or script access is disallowed, we should |
100 // open the window in a new BrowsingInstance, and thus a new process. That | 100 // open the window in a new BrowsingInstance, and thus a new process. That |
101 // means the current renderer process will not be able to route messages to | 101 // means the current renderer process will not be able to route messages to |
102 // it. Because of this, we will immediately show and navigate the window | 102 // it. Because of this, we will immediately show and navigate the window |
103 // in OnCreateWindowOnUI, using the params provided here. | 103 // in OnCreateWindowOnUI, using the params provided here. |
104 *route_id = MSG_ROUTING_NONE; | 104 *route_id = MSG_ROUTING_NONE; |
105 *main_frame_route_id = MSG_ROUTING_NONE; | 105 *main_frame_route_id = MSG_ROUTING_NONE; |
106 *main_frame_widget_route_id = MSG_ROUTING_NONE; | 106 *main_frame_widget_route_id = MSG_ROUTING_NONE; |
107 } else { | 107 } else { |
108 *route_id = GetNextRoutingID(); | 108 *route_id = GetNextRoutingID(); |
109 *main_frame_route_id = GetNextRoutingID(); | 109 *main_frame_route_id = GetNextRoutingID(); |
110 // TODO(avi): When RenderViewHostImpl has-a RenderWidgetHostImpl, this | 110 // TODO(avi): When RenderViewHostImpl has-a RenderWidgetHostImpl, this |
111 // should be updated to give the widget a distinct routing ID. | 111 // should be updated to give the widget a distinct routing ID. |
112 // https://crbug.com/545684 | 112 // https://crbug.com/545684 |
113 *main_frame_widget_route_id = *route_id; | 113 *main_frame_widget_route_id = *route_id; |
114 // Block resource requests until the frame is created, since the HWND might | 114 // Block resource requests until the frame is created, since the HWND might |
115 // be needed if a response ends up creating a plugin. We'll only have a | 115 // be needed if a response ends up creating a plugin. We'll only have a |
116 // single frame at this point. These requests will be resumed either in | 116 // single frame at this point. These requests will be resumed either in |
117 // WebContentsImpl::CreateNewWindow or RenderFrameHost::Init. | 117 // WebContentsImpl::CreateNewWindow or RenderFrameHost::Init. |
118 resource_dispatcher_host_->BlockRequestsForRoute( | 118 resource_dispatcher_host_->BlockRequestsForRoute( |
119 GlobalFrameRoutingId(render_process_id_, *main_frame_route_id)); | 119 GlobalFrameRoutingId(render_process_id_, *main_frame_route_id)); |
120 } | 120 } |
121 | 121 |
122 BrowserThread::PostTask( | 122 BrowserThread::PostTask( |
123 BrowserThread::UI, FROM_HERE, | 123 BrowserThread::UI, FROM_HERE, |
124 base::Bind(&RenderWidgetHelper::OnCreateWindowOnUI, this, params, | 124 base::Bind(&RenderWidgetHelper::OnCreateWindowOnUI, this, |
125 *route_id, *main_frame_route_id, *main_frame_widget_route_id, | 125 base::Passed(¶ms), *route_id, *main_frame_route_id, |
| 126 *main_frame_widget_route_id, |
126 base::RetainedRef(session_storage_namespace))); | 127 base::RetainedRef(session_storage_namespace))); |
127 } | 128 } |
128 | 129 |
129 void RenderWidgetHelper::OnCreateWindowOnUI( | 130 void RenderWidgetHelper::OnCreateWindowOnUI( |
130 const ViewHostMsg_CreateWindow_Params& params, | 131 mojom::CreateNewWindowParamsPtr params, |
131 int32_t route_id, | 132 int32_t route_id, |
132 int32_t main_frame_route_id, | 133 int32_t main_frame_route_id, |
133 int32_t main_frame_widget_route_id, | 134 int32_t main_frame_widget_route_id, |
134 SessionStorageNamespace* session_storage_namespace) { | 135 SessionStorageNamespace* session_storage_namespace) { |
135 RenderViewHostImpl* host = | 136 RenderViewHostImpl* host = |
136 RenderViewHostImpl::FromID(render_process_id_, params.opener_id); | 137 RenderViewHostImpl::FromID(render_process_id_, params->opener_id); |
137 if (host) | 138 if (host) { |
138 host->CreateNewWindow(route_id, main_frame_route_id, | 139 host->CreateNewWindow(route_id, main_frame_route_id, |
139 main_frame_widget_route_id, params, | 140 main_frame_widget_route_id, *params, |
140 session_storage_namespace); | 141 session_storage_namespace); |
| 142 } |
141 } | 143 } |
142 | 144 |
143 void RenderWidgetHelper::CreateNewWidget(int opener_id, | 145 void RenderWidgetHelper::CreateNewWidget(int opener_id, |
144 blink::WebPopupType popup_type, | 146 blink::WebPopupType popup_type, |
145 int* route_id) { | 147 int* route_id) { |
146 *route_id = GetNextRoutingID(); | 148 *route_id = GetNextRoutingID(); |
147 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 149 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
148 base::Bind(&RenderWidgetHelper::OnCreateWidgetOnUI, | 150 base::Bind(&RenderWidgetHelper::OnCreateWidgetOnUI, |
149 this, opener_id, *route_id, popup_type)); | 151 this, opener_id, *route_id, popup_type)); |
150 } | 152 } |
(...skipping 18 matching lines...) Expand all Loading... |
169 | 171 |
170 void RenderWidgetHelper::OnCreateFullscreenWidgetOnUI(int32_t opener_id, | 172 void RenderWidgetHelper::OnCreateFullscreenWidgetOnUI(int32_t opener_id, |
171 int32_t route_id) { | 173 int32_t route_id) { |
172 RenderViewHostImpl* host = RenderViewHostImpl::FromID( | 174 RenderViewHostImpl* host = RenderViewHostImpl::FromID( |
173 render_process_id_, opener_id); | 175 render_process_id_, opener_id); |
174 if (host) | 176 if (host) |
175 host->CreateNewFullscreenWidget(route_id); | 177 host->CreateNewFullscreenWidget(route_id); |
176 } | 178 } |
177 | 179 |
178 } // namespace content | 180 } // namespace content |
OLD | NEW |