| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1380 | 1380 |
| 1381 // Check if the URL we are about to load has been prerendered by any chance, | 1381 // Check if the URL we are about to load has been prerendered by any chance, |
| 1382 // and use it if possible. | 1382 // and use it if possible. |
| 1383 MaybeUsePreloadedPage(url); | 1383 MaybeUsePreloadedPage(url); |
| 1384 } | 1384 } |
| 1385 } | 1385 } |
| 1386 | 1386 |
| 1387 void TabContents::OnDidRedirectProvisionalLoad(int32 page_id, | 1387 void TabContents::OnDidRedirectProvisionalLoad(int32 page_id, |
| 1388 const GURL& source_url, | 1388 const GURL& source_url, |
| 1389 const GURL& target_url) { | 1389 const GURL& target_url) { |
| 1390 // TODO(creis): Remove this method and have the pre-rendering code listen to |
| 1391 // the ResourceDispatcherHost's RESOURCE_RECEIVED_REDIRECT notification |
| 1392 // instead. See http://crbug.com/78512. |
| 1390 NavigationEntry* entry; | 1393 NavigationEntry* entry; |
| 1391 if (page_id == -1) | 1394 if (page_id == -1) |
| 1392 entry = controller_.pending_entry(); | 1395 entry = controller_.pending_entry(); |
| 1393 else | 1396 else |
| 1394 entry = controller_.GetEntryWithPageID(GetSiteInstance(), page_id); | 1397 entry = controller_.GetEntryWithPageID(GetSiteInstance(), page_id); |
| 1395 if (!entry || entry->url() != source_url) | 1398 if (!entry || entry->url() != source_url) |
| 1396 return; | 1399 return; |
| 1397 entry->set_url(target_url); | |
| 1398 | 1400 |
| 1399 // Check if the URL we are about to load has been prerendered by any chance, | 1401 // Check if the URL we are about to load has been prerendered by any chance, |
| 1400 // and use it if possible. | 1402 // and use it if possible. |
| 1401 MaybeUsePreloadedPage(target_url); | 1403 MaybeUsePreloadedPage(target_url); |
| 1402 } | 1404 } |
| 1403 | 1405 |
| 1404 void TabContents::OnDidFailProvisionalLoadWithError( | 1406 void TabContents::OnDidFailProvisionalLoadWithError( |
| 1405 int64 frame_id, | 1407 int64 frame_id, |
| 1406 bool is_main_frame, | 1408 bool is_main_frame, |
| 1407 int error_code, | 1409 int error_code, |
| (...skipping 1444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2852 } | 2854 } |
| 2853 | 2855 |
| 2854 bool TabContents::MaybeUsePreloadedPage(const GURL& url) { | 2856 bool TabContents::MaybeUsePreloadedPage(const GURL& url) { |
| 2855 prerender::PrerenderManager* pm = profile()->GetPrerenderManager(); | 2857 prerender::PrerenderManager* pm = profile()->GetPrerenderManager(); |
| 2856 if (pm != NULL) { | 2858 if (pm != NULL) { |
| 2857 if (pm->MaybeUsePreloadedPage(this, url)) | 2859 if (pm->MaybeUsePreloadedPage(this, url)) |
| 2858 return true; | 2860 return true; |
| 2859 } | 2861 } |
| 2860 return false; | 2862 return false; |
| 2861 } | 2863 } |
| OLD | NEW |