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 "chrome/browser/prerender/prerender_manager.h" | 5 #include "chrome/browser/prerender/prerender_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 if (!prerender_data) | 414 if (!prerender_data) |
415 return false; | 415 return false; |
416 DCHECK(prerender_data->contents()); | 416 DCHECK(prerender_data->contents()); |
417 if (IsNoSwapInExperiment(prerender_data->contents()->experiment_id())) | 417 if (IsNoSwapInExperiment(prerender_data->contents()->experiment_id())) |
418 return false; | 418 return false; |
419 | 419 |
420 if (WebContents* new_web_contents = | 420 if (WebContents* new_web_contents = |
421 prerender_data->contents()->prerender_contents()) { | 421 prerender_data->contents()->prerender_contents()) { |
422 if (web_contents == new_web_contents) | 422 if (web_contents == new_web_contents) |
423 return false; // Do not swap in to ourself. | 423 return false; // Do not swap in to ourself. |
| 424 |
| 425 // We cannot swap in if there is no last committed entry, because we would |
| 426 // show a blank page under an existing entry from the current tab. Even if |
| 427 // there is a pending entry, it may not commit. |
| 428 // TODO(creis): If there is a pending navigation and no last committed |
| 429 // entry, we might be able to transfer the network request instead. |
| 430 if (!new_web_contents->GetController().CanPruneAllButVisible()) |
| 431 return false; |
424 } | 432 } |
425 | 433 |
426 // Do not use the prerendered version if there is an opener object. | 434 // Do not use the prerendered version if there is an opener object. |
427 if (web_contents->HasOpener()) { | 435 if (web_contents->HasOpener()) { |
428 prerender_data->contents()->Destroy(FINAL_STATUS_WINDOW_OPENER); | 436 prerender_data->contents()->Destroy(FINAL_STATUS_WINDOW_OPENER); |
429 return false; | 437 return false; |
430 } | 438 } |
431 | 439 |
432 // If we are just in the control group (which can be detected by noticing | 440 // If we are just in the control group (which can be detected by noticing |
433 // that prerendering hasn't even started yet), record that |web_contents| now | 441 // that prerendering hasn't even started yet), record that |web_contents| now |
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 logged_in_state_->erase(domain_key); | 1527 logged_in_state_->erase(domain_key); |
1520 } | 1528 } |
1521 | 1529 |
1522 void PrerenderManager::LoggedInPredictorDataReceived( | 1530 void PrerenderManager::LoggedInPredictorDataReceived( |
1523 scoped_ptr<LoggedInStateMap> new_map) { | 1531 scoped_ptr<LoggedInStateMap> new_map) { |
1524 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1532 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
1525 logged_in_state_.swap(new_map); | 1533 logged_in_state_.swap(new_map); |
1526 } | 1534 } |
1527 | 1535 |
1528 } // namespace prerender | 1536 } // namespace prerender |
OLD | NEW |