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/tab_contents/tab_contents.h" | 5 #include "content/browser/tab_contents/tab_contents.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 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 new WebIntentsDispatcherImpl(this, intent, intent_id); | 1428 new WebIntentsDispatcherImpl(this, intent, intent_id); |
1429 delegate_->WebIntentDispatch(this, intents_dispatcher); | 1429 delegate_->WebIntentDispatch(this, intents_dispatcher); |
1430 } | 1430 } |
1431 | 1431 |
1432 void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, | 1432 void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, |
1433 bool is_main_frame, | 1433 bool is_main_frame, |
1434 const GURL& opener_url, | 1434 const GURL& opener_url, |
1435 const GURL& url) { | 1435 const GURL& url) { |
1436 bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL); | 1436 bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL); |
1437 GURL validated_url(url); | 1437 GURL validated_url(url); |
| 1438 GURL validated_opener_url(opener_url); |
1438 GetRenderViewHostImpl()->FilterURL( | 1439 GetRenderViewHostImpl()->FilterURL( |
1439 ChildProcessSecurityPolicyImpl::GetInstance(), | 1440 ChildProcessSecurityPolicyImpl::GetInstance(), |
1440 GetRenderProcessHost()->GetID(), | 1441 GetRenderProcessHost()->GetID(), |
| 1442 false, |
1441 &validated_url); | 1443 &validated_url); |
| 1444 GetRenderViewHostImpl()->FilterURL( |
| 1445 ChildProcessSecurityPolicyImpl::GetInstance(), |
| 1446 GetRenderProcessHost()->GetID(), |
| 1447 true, |
| 1448 &validated_opener_url); |
1442 | 1449 |
1443 RenderViewHost* rvh = | 1450 RenderViewHost* rvh = |
1444 render_manager_.pending_render_view_host() ? | 1451 render_manager_.pending_render_view_host() ? |
1445 render_manager_.pending_render_view_host() : GetRenderViewHost(); | 1452 render_manager_.pending_render_view_host() : GetRenderViewHost(); |
1446 // Notify observers about the start of the provisional load. | 1453 // Notify observers about the start of the provisional load. |
1447 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1454 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
1448 DidStartProvisionalLoadForFrame(frame_id, is_main_frame, | 1455 DidStartProvisionalLoadForFrame(frame_id, is_main_frame, |
1449 validated_url, is_error_page, rvh)); | 1456 validated_url, is_error_page, rvh)); |
1450 | 1457 |
1451 if (is_main_frame) { | 1458 if (is_main_frame) { |
1452 // Notify observers about the provisional change in the main frame URL. | 1459 // Notify observers about the provisional change in the main frame URL. |
1453 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1460 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
1454 ProvisionalChangeToMainFrameUrl(url, opener_url)); | 1461 ProvisionalChangeToMainFrameUrl(validated_url, |
| 1462 validated_opener_url)); |
1455 } | 1463 } |
1456 } | 1464 } |
1457 | 1465 |
1458 void TabContents::OnDidRedirectProvisionalLoad(int32 page_id, | 1466 void TabContents::OnDidRedirectProvisionalLoad(int32 page_id, |
1459 const GURL& opener_url, | 1467 const GURL& opener_url, |
1460 const GURL& source_url, | 1468 const GURL& source_url, |
1461 const GURL& target_url) { | 1469 const GURL& target_url) { |
1462 // TODO(creis): Remove this method and have the pre-rendering code listen to | 1470 // TODO(creis): Remove this method and have the pre-rendering code listen to |
1463 // the ResourceDispatcherHost's RESOURCE_RECEIVED_REDIRECT notification | 1471 // the ResourceDispatcherHost's RESOURCE_RECEIVED_REDIRECT notification |
1464 // instead. See http://crbug.com/78512. | 1472 // instead. See http://crbug.com/78512. |
| 1473 GURL validated_source_url(source_url); |
| 1474 GURL validated_target_url(target_url); |
| 1475 GURL validated_opener_url(opener_url); |
| 1476 GetRenderViewHostImpl()->FilterURL( |
| 1477 ChildProcessSecurityPolicyImpl::GetInstance(), |
| 1478 GetRenderProcessHost()->GetID(), |
| 1479 false, |
| 1480 &validated_source_url); |
| 1481 GetRenderViewHostImpl()->FilterURL( |
| 1482 ChildProcessSecurityPolicyImpl::GetInstance(), |
| 1483 GetRenderProcessHost()->GetID(), |
| 1484 false, |
| 1485 &validated_target_url); |
| 1486 GetRenderViewHostImpl()->FilterURL( |
| 1487 ChildProcessSecurityPolicyImpl::GetInstance(), |
| 1488 GetRenderProcessHost()->GetID(), |
| 1489 true, |
| 1490 &validated_opener_url); |
1465 NavigationEntry* entry; | 1491 NavigationEntry* entry; |
1466 if (page_id == -1) | 1492 if (page_id == -1) |
1467 entry = controller_.GetPendingEntry(); | 1493 entry = controller_.GetPendingEntry(); |
1468 else | 1494 else |
1469 entry = controller_.GetEntryWithPageID(GetSiteInstance(), page_id); | 1495 entry = controller_.GetEntryWithPageID(GetSiteInstance(), page_id); |
1470 if (!entry || entry->GetURL() != source_url) | 1496 if (!entry || entry->GetURL() != validated_source_url) |
1471 return; | 1497 return; |
1472 | 1498 |
1473 // Notify observers about the provisional change in the main frame URL. | 1499 // Notify observers about the provisional change in the main frame URL. |
1474 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1500 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
1475 ProvisionalChangeToMainFrameUrl(target_url, | 1501 ProvisionalChangeToMainFrameUrl(validated_target_url, |
1476 opener_url)); | 1502 validated_opener_url)); |
1477 } | 1503 } |
1478 | 1504 |
1479 void TabContents::OnDidFailProvisionalLoadWithError( | 1505 void TabContents::OnDidFailProvisionalLoadWithError( |
1480 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params) { | 1506 const ViewHostMsg_DidFailProvisionalLoadWithError_Params& params) { |
1481 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() | 1507 VLOG(1) << "Failed Provisional Load: " << params.url.possibly_invalid_spec() |
1482 << ", error_code: " << params.error_code | 1508 << ", error_code: " << params.error_code |
1483 << ", error_description: " << params.error_description | 1509 << ", error_description: " << params.error_description |
1484 << ", is_main_frame: " << params.is_main_frame | 1510 << ", is_main_frame: " << params.is_main_frame |
1485 << ", showing_repost_interstitial: " << | 1511 << ", showing_repost_interstitial: " << |
1486 params.showing_repost_interstitial | 1512 params.showing_repost_interstitial |
1487 << ", frame_id: " << params.frame_id; | 1513 << ", frame_id: " << params.frame_id; |
1488 GURL validated_url(params.url); | 1514 GURL validated_url(params.url); |
1489 GetRenderViewHostImpl()->FilterURL( | 1515 GetRenderViewHostImpl()->FilterURL( |
1490 ChildProcessSecurityPolicyImpl::GetInstance(), | 1516 ChildProcessSecurityPolicyImpl::GetInstance(), |
1491 GetRenderProcessHost()->GetID(), | 1517 GetRenderProcessHost()->GetID(), |
| 1518 false, |
1492 &validated_url); | 1519 &validated_url); |
1493 | 1520 |
1494 if (net::ERR_ABORTED == params.error_code) { | 1521 if (net::ERR_ABORTED == params.error_code) { |
1495 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. | 1522 // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. |
1496 // This means that the interstitial won't be torn down properly, which is | 1523 // This means that the interstitial won't be torn down properly, which is |
1497 // bad. But if we have an interstitial, go back to another tab type, and | 1524 // bad. But if we have an interstitial, go back to another tab type, and |
1498 // then load the same interstitial again, we could end up getting the first | 1525 // then load the same interstitial again, we could end up getting the first |
1499 // interstitial's "failed" message (as a result of the cancel) when we're on | 1526 // interstitial's "failed" message (as a result of the cancel) when we're on |
1500 // the second one. | 1527 // the second one. |
1501 // | 1528 // |
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2562 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2589 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
2563 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); | 2590 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); |
2564 // Can be NULL during tests. | 2591 // Can be NULL during tests. |
2565 if (rwh_view) | 2592 if (rwh_view) |
2566 rwh_view->SetSize(GetView()->GetContainerSize()); | 2593 rwh_view->SetSize(GetView()->GetContainerSize()); |
2567 } | 2594 } |
2568 | 2595 |
2569 RenderViewHostImpl* TabContents::GetRenderViewHostImpl() { | 2596 RenderViewHostImpl* TabContents::GetRenderViewHostImpl() { |
2570 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); | 2597 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); |
2571 } | 2598 } |
OLD | NEW |