| 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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1022 // We use our current SiteInstance since the cloned entry will use it anyway. | 1022 // We use our current SiteInstance since the cloned entry will use it anyway. |
| 1023 // We pass |this| for the |base_web_contents| to size the view correctly, and | 1023 // We pass |this| for the |base_web_contents| to size the view correctly, and |
| 1024 // our own opener so that the cloned page can access it if it was before. | 1024 // our own opener so that the cloned page can access it if it was before. |
| 1025 WebContentsImpl* tc = CreateWithOpener(GetBrowserContext(), | 1025 WebContentsImpl* tc = CreateWithOpener(GetBrowserContext(), |
| 1026 GetSiteInstance(), MSG_ROUTING_NONE, | 1026 GetSiteInstance(), MSG_ROUTING_NONE, |
| 1027 this, opener_); | 1027 this, opener_); |
| 1028 tc->GetController().CopyStateFrom(controller_); | 1028 tc->GetController().CopyStateFrom(controller_); |
| 1029 return tc; | 1029 return tc; |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 void WebContentsImpl::AddNewContents(WebContents* new_contents, | 1032 bool WebContentsImpl::AddNewContents(WebContents* new_contents, |
| 1033 WindowOpenDisposition disposition, | 1033 WindowOpenDisposition disposition, |
| 1034 const gfx::Rect& initial_pos, | 1034 const gfx::Rect& initial_pos, |
| 1035 bool user_gesture) { | 1035 bool user_gesture) { |
| 1036 if (!delegate_) | 1036 if (!delegate_) |
| 1037 return; | 1037 return false; |
| 1038 | 1038 |
| 1039 delegate_->AddNewContents(this, new_contents, disposition, initial_pos, | 1039 return delegate_->AddNewContents( |
| 1040 user_gesture); | 1040 this, new_contents, disposition, initial_pos, user_gesture); |
| 1041 } | 1041 } |
| 1042 | 1042 |
| 1043 gfx::NativeView WebContentsImpl::GetContentNativeView() const { | 1043 gfx::NativeView WebContentsImpl::GetContentNativeView() const { |
| 1044 return view_->GetContentNativeView(); | 1044 return view_->GetContentNativeView(); |
| 1045 } | 1045 } |
| 1046 | 1046 |
| 1047 gfx::NativeView WebContentsImpl::GetNativeView() const { | 1047 gfx::NativeView WebContentsImpl::GetNativeView() const { |
| 1048 return view_->GetNativeView(); | 1048 return view_->GetNativeView(); |
| 1049 } | 1049 } |
| 1050 | 1050 |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1268 // TODO(brettw): It seems bogus that we have to call this function on the | 1268 // TODO(brettw): It seems bogus that we have to call this function on the |
| 1269 // newly created object and give it one of its own member variables. | 1269 // newly created object and give it one of its own member variables. |
| 1270 new_view->CreateViewForWidget(new_contents->GetRenderViewHost()); | 1270 new_view->CreateViewForWidget(new_contents->GetRenderViewHost()); |
| 1271 | 1271 |
| 1272 // Save the created window associated with the route so we can show it | 1272 // Save the created window associated with the route so we can show it |
| 1273 // later. | 1273 // later. |
| 1274 DCHECK_NE(MSG_ROUTING_NONE, route_id); | 1274 DCHECK_NE(MSG_ROUTING_NONE, route_id); |
| 1275 pending_contents_[route_id] = new_contents; | 1275 pending_contents_[route_id] = new_contents; |
| 1276 } | 1276 } |
| 1277 | 1277 |
| 1278 bool not_blocked = true; |
| 1278 if (delegate_) { | 1279 if (delegate_) { |
| 1279 delegate_->WebContentsCreated( | 1280 not_blocked = delegate_->WebContentsCreated( |
| 1280 this, params.opener_frame_id, params.target_url, new_contents); | 1281 this, params.opener_frame_id, params.target_url, new_contents); |
| 1281 } | 1282 } |
| 1282 | 1283 |
| 1283 if (params.opener_suppressed) { | 1284 if (params.opener_suppressed && not_blocked) { |
| 1284 // When the opener is suppressed, the original renderer cannot access the | 1285 // When the opener is suppressed, the original renderer cannot access the |
| 1285 // new window. As a result, we need to show and navigate the window here. | 1286 // new window. As a result, we need to show and navigate the window here. |
| 1286 gfx::Rect initial_pos; | 1287 gfx::Rect initial_pos; |
| 1287 AddNewContents( | 1288 not_blocked = AddNewContents( |
| 1288 new_contents, params.disposition, initial_pos, params.user_gesture); | 1289 new_contents, params.disposition, initial_pos, params.user_gesture); |
| 1289 | 1290 |
| 1290 content::OpenURLParams open_params(params.target_url, content::Referrer(), | 1291 if (not_blocked) { |
| 1291 CURRENT_TAB, | 1292 content::OpenURLParams open_params(params.target_url, |
| 1292 content::PAGE_TRANSITION_LINK, | 1293 content::Referrer(), |
| 1293 true /* is_renderer_initiated */); | 1294 CURRENT_TAB, |
| 1294 new_contents->OpenURL(open_params); | 1295 content::PAGE_TRANSITION_LINK, |
| 1296 true /* is_renderer_initiated */); |
| 1297 new_contents->OpenURL(open_params); |
| 1298 } |
| 1295 } | 1299 } |
| 1296 } | 1300 } |
| 1297 | 1301 |
| 1298 void WebContentsImpl::CreateNewWidget(int route_id, | 1302 void WebContentsImpl::CreateNewWidget(int route_id, |
| 1299 WebKit::WebPopupType popup_type) { | 1303 WebKit::WebPopupType popup_type) { |
| 1300 CreateNewWidget(route_id, false, popup_type); | 1304 CreateNewWidget(route_id, false, popup_type); |
| 1301 } | 1305 } |
| 1302 | 1306 |
| 1303 void WebContentsImpl::CreateNewFullscreenWidget(int route_id) { | 1307 void WebContentsImpl::CreateNewFullscreenWidget(int route_id) { |
| 1304 CreateNewWidget(route_id, true, WebKit::WebPopupTypeNone); | 1308 CreateNewWidget(route_id, true, WebKit::WebPopupTypeNone); |
| (...skipping 1926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3231 old_browser_plugin_host()->embedder_render_process_host(); | 3235 old_browser_plugin_host()->embedder_render_process_host(); |
| 3232 *embedder_container_id = old_browser_plugin_host()->instance_id(); | 3236 *embedder_container_id = old_browser_plugin_host()->instance_id(); |
| 3233 int embedder_process_id = | 3237 int embedder_process_id = |
| 3234 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; | 3238 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; |
| 3235 if (embedder_process_id != -1) { | 3239 if (embedder_process_id != -1) { |
| 3236 *embedder_channel_name = | 3240 *embedder_channel_name = |
| 3237 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), | 3241 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), |
| 3238 embedder_process_id); | 3242 embedder_process_id); |
| 3239 } | 3243 } |
| 3240 } | 3244 } |
| OLD | NEW |