| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 using content::RenderWidgetHost; | 153 using content::RenderWidgetHost; |
| 154 using content::RenderWidgetHostImpl; | 154 using content::RenderWidgetHostImpl; |
| 155 using content::RenderWidgetHostView; | 155 using content::RenderWidgetHostView; |
| 156 using content::RenderWidgetHostViewPort; | 156 using content::RenderWidgetHostViewPort; |
| 157 using content::ResourceDispatcherHostImpl; | 157 using content::ResourceDispatcherHostImpl; |
| 158 using content::SSLStatus; | 158 using content::SSLStatus; |
| 159 using content::SessionStorageNamespace; | 159 using content::SessionStorageNamespace; |
| 160 using content::SiteInstance; | 160 using content::SiteInstance; |
| 161 using content::UserMetricsAction; | 161 using content::UserMetricsAction; |
| 162 using content::WebContents; | 162 using content::WebContents; |
| 163 using content::WebContentsDelegate; |
| 163 using content::WebContentsObserver; | 164 using content::WebContentsObserver; |
| 164 using content::WebUI; | 165 using content::WebUI; |
| 165 using content::WebUIController; | 166 using content::WebUIController; |
| 166 using content::WebUIControllerFactory; | 167 using content::WebUIControllerFactory; |
| 167 using webkit_glue::WebPreferences; | 168 using webkit_glue::WebPreferences; |
| 168 | 169 |
| 169 namespace { | 170 namespace { |
| 170 | 171 |
| 171 // Amount of time we wait between when a key event is received and the renderer | 172 // Amount of time we wait between when a key event is received and the renderer |
| 172 // is queried for its state and pushed to the NavigationEntry. | 173 // is queried for its state and pushed to the NavigationEntry. |
| (...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 // We use our current SiteInstance since the cloned entry will use it anyway. | 1030 // We use our current SiteInstance since the cloned entry will use it anyway. |
| 1030 // We pass |this| for the |base_web_contents| to size the view correctly, and | 1031 // We pass |this| for the |base_web_contents| to size the view correctly, and |
| 1031 // our own opener so that the cloned page can access it if it was before. | 1032 // our own opener so that the cloned page can access it if it was before. |
| 1032 WebContentsImpl* tc = CreateWithOpener(GetBrowserContext(), | 1033 WebContentsImpl* tc = CreateWithOpener(GetBrowserContext(), |
| 1033 GetSiteInstance(), MSG_ROUTING_NONE, | 1034 GetSiteInstance(), MSG_ROUTING_NONE, |
| 1034 this, opener_); | 1035 this, opener_); |
| 1035 tc->GetController().CopyStateFrom(controller_); | 1036 tc->GetController().CopyStateFrom(controller_); |
| 1036 return tc; | 1037 return tc; |
| 1037 } | 1038 } |
| 1038 | 1039 |
| 1039 void WebContentsImpl::AddNewContents(WebContents* new_contents, | |
| 1040 WindowOpenDisposition disposition, | |
| 1041 const gfx::Rect& initial_pos, | |
| 1042 bool user_gesture) { | |
| 1043 if (!delegate_) | |
| 1044 return; | |
| 1045 | |
| 1046 delegate_->AddNewContents(this, new_contents, disposition, initial_pos, | |
| 1047 user_gesture); | |
| 1048 } | |
| 1049 | |
| 1050 gfx::NativeView WebContentsImpl::GetContentNativeView() const { | 1040 gfx::NativeView WebContentsImpl::GetContentNativeView() const { |
| 1051 return view_->GetContentNativeView(); | 1041 return view_->GetContentNativeView(); |
| 1052 } | 1042 } |
| 1053 | 1043 |
| 1054 gfx::NativeView WebContentsImpl::GetNativeView() const { | 1044 gfx::NativeView WebContentsImpl::GetNativeView() const { |
| 1055 return view_->GetNativeView(); | 1045 return view_->GetNativeView(); |
| 1056 } | 1046 } |
| 1057 | 1047 |
| 1058 void WebContentsImpl::GetContainerBounds(gfx::Rect* out) const { | 1048 void WebContentsImpl::GetContainerBounds(gfx::Rect* out) const { |
| 1059 view_->GetContainerBounds(out); | 1049 view_->GetContainerBounds(out); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1283 } | 1273 } |
| 1284 | 1274 |
| 1285 if (delegate_) { | 1275 if (delegate_) { |
| 1286 delegate_->WebContentsCreated( | 1276 delegate_->WebContentsCreated( |
| 1287 this, params.opener_frame_id, params.target_url, new_contents); | 1277 this, params.opener_frame_id, params.target_url, new_contents); |
| 1288 } | 1278 } |
| 1289 | 1279 |
| 1290 if (params.opener_suppressed) { | 1280 if (params.opener_suppressed) { |
| 1291 // When the opener is suppressed, the original renderer cannot access the | 1281 // When the opener is suppressed, the original renderer cannot access the |
| 1292 // new window. As a result, we need to show and navigate the window here. | 1282 // new window. As a result, we need to show and navigate the window here. |
| 1293 gfx::Rect initial_pos; | 1283 bool was_blocked = false; |
| 1294 // TODO(cdn) Fix popup white-listing for links that open in a new process. | 1284 if (delegate_) { |
| 1295 AddNewContents( | 1285 gfx::Rect initial_pos; |
| 1296 new_contents, params.user_gesture ? params.disposition : NEW_POPUP, | 1286 delegate_->AddNewContents( |
| 1297 initial_pos, params.user_gesture); | 1287 this, new_contents, params.disposition, initial_pos, |
| 1298 | 1288 params.user_gesture, &was_blocked); |
| 1299 content::OpenURLParams open_params(params.target_url, content::Referrer(), | 1289 } |
| 1300 CURRENT_TAB, | 1290 if (!was_blocked) { |
| 1301 content::PAGE_TRANSITION_LINK, | 1291 content::OpenURLParams open_params(params.target_url, |
| 1302 true /* is_renderer_initiated */); | 1292 content::Referrer(), |
| 1303 new_contents->OpenURL(open_params); | 1293 CURRENT_TAB, |
| 1294 content::PAGE_TRANSITION_LINK, |
| 1295 true /* is_renderer_initiated */); |
| 1296 new_contents->OpenURL(open_params); |
| 1297 } |
| 1304 } | 1298 } |
| 1305 } | 1299 } |
| 1306 | 1300 |
| 1307 void WebContentsImpl::CreateNewWidget(int route_id, | 1301 void WebContentsImpl::CreateNewWidget(int route_id, |
| 1308 WebKit::WebPopupType popup_type) { | 1302 WebKit::WebPopupType popup_type) { |
| 1309 CreateNewWidget(route_id, false, popup_type); | 1303 CreateNewWidget(route_id, false, popup_type); |
| 1310 } | 1304 } |
| 1311 | 1305 |
| 1312 void WebContentsImpl::CreateNewFullscreenWidget(int route_id) { | 1306 void WebContentsImpl::CreateNewFullscreenWidget(int route_id) { |
| 1313 CreateNewWidget(route_id, true, WebKit::WebPopupTypeNone); | 1307 CreateNewWidget(route_id, true, WebKit::WebPopupTypeNone); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1333 // to allow it to survive the trip without being hosted. | 1327 // to allow it to survive the trip without being hosted. |
| 1334 base::mac::NSObjectRetain(widget_view->GetNativeView()); | 1328 base::mac::NSObjectRetain(widget_view->GetNativeView()); |
| 1335 #endif | 1329 #endif |
| 1336 } | 1330 } |
| 1337 | 1331 |
| 1338 void WebContentsImpl::ShowCreatedWindow(int route_id, | 1332 void WebContentsImpl::ShowCreatedWindow(int route_id, |
| 1339 WindowOpenDisposition disposition, | 1333 WindowOpenDisposition disposition, |
| 1340 const gfx::Rect& initial_pos, | 1334 const gfx::Rect& initial_pos, |
| 1341 bool user_gesture) { | 1335 bool user_gesture) { |
| 1342 WebContentsImpl* contents = GetCreatedWindow(route_id); | 1336 WebContentsImpl* contents = GetCreatedWindow(route_id); |
| 1343 if (contents) | 1337 if (contents) { |
| 1344 AddNewContents(contents, disposition, initial_pos, user_gesture); | 1338 WebContentsDelegate* delegate = GetDelegate(); |
| 1339 if (delegate) { |
| 1340 delegate->AddNewContents( |
| 1341 this, contents, disposition, initial_pos, user_gesture, NULL); |
| 1342 } |
| 1343 } |
| 1345 } | 1344 } |
| 1346 | 1345 |
| 1347 void WebContentsImpl::ShowCreatedWidget(int route_id, | 1346 void WebContentsImpl::ShowCreatedWidget(int route_id, |
| 1348 const gfx::Rect& initial_pos) { | 1347 const gfx::Rect& initial_pos) { |
| 1349 ShowCreatedWidget(route_id, false, initial_pos); | 1348 ShowCreatedWidget(route_id, false, initial_pos); |
| 1350 } | 1349 } |
| 1351 | 1350 |
| 1352 void WebContentsImpl::ShowCreatedFullscreenWidget(int route_id) { | 1351 void WebContentsImpl::ShowCreatedFullscreenWidget(int route_id) { |
| 1353 ShowCreatedWidget(route_id, true, gfx::Rect()); | 1352 ShowCreatedWidget(route_id, true, gfx::Rect()); |
| 1354 } | 1353 } |
| (...skipping 1915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3270 old_browser_plugin_host()->embedder_render_process_host(); | 3269 old_browser_plugin_host()->embedder_render_process_host(); |
| 3271 *embedder_container_id = old_browser_plugin_host()->instance_id(); | 3270 *embedder_container_id = old_browser_plugin_host()->instance_id(); |
| 3272 int embedder_process_id = | 3271 int embedder_process_id = |
| 3273 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; | 3272 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; |
| 3274 if (embedder_process_id != -1) { | 3273 if (embedder_process_id != -1) { |
| 3275 *embedder_channel_name = | 3274 *embedder_channel_name = |
| 3276 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), | 3275 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), |
| 3277 embedder_process_id); | 3276 embedder_process_id); |
| 3278 } | 3277 } |
| 3279 } | 3278 } |
| OLD | NEW |