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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
522 // there is a pending entry, it may not commit. | 522 // there is a pending entry, it may not commit. |
523 // TODO(creis): If there is a pending navigation and no last committed | 523 // TODO(creis): If there is a pending navigation and no last committed |
524 // entry, we might be able to transfer the network request instead. | 524 // entry, we might be able to transfer the network request instead. |
525 if (!new_web_contents->GetController().CanPruneAllButLastCommitted()) { | 525 if (!new_web_contents->GetController().CanPruneAllButLastCommitted()) { |
526 // Abort this prerender so it is not used later. http://crbug.com/292121 | 526 // Abort this prerender so it is not used later. http://crbug.com/292121 |
527 prerender_data->contents()->Destroy(FINAL_STATUS_NAVIGATION_UNCOMMITTED); | 527 prerender_data->contents()->Destroy(FINAL_STATUS_NAVIGATION_UNCOMMITTED); |
528 return NULL; | 528 return NULL; |
529 } | 529 } |
530 } | 530 } |
531 | 531 |
532 // Do not use the prerendered version if there is an opener object. | 532 // Do not use the prerendered version if the target WebContents has an opener |
533 if (web_contents->HasOpener()) { | 533 // or was created with one. The latter controls whether window.close() is |
534 // allowed, so the behavior is observable. | |
535 if (web_contents->CreatedWithOpener()) { | |
Charlie Reis
2014/04/05 01:41:25
Unfortunately, using the opener for this was the w
davidben
2014/04/07 17:57:52
Hrm, yeah, I'd been wondering if the opener check
| |
534 prerender_data->contents()->Destroy(FINAL_STATUS_WINDOW_OPENER); | 536 prerender_data->contents()->Destroy(FINAL_STATUS_WINDOW_OPENER); |
535 return NULL; | 537 return NULL; |
536 } | 538 } |
537 | 539 |
538 // Do not swap in the prerender if the current WebContents is being captured. | 540 // Do not swap in the prerender if the current WebContents is being captured. |
539 if (web_contents->GetCapturerCount() > 0) { | 541 if (web_contents->GetCapturerCount() > 0) { |
540 prerender_data->contents()->Destroy(FINAL_STATUS_PAGE_BEING_CAPTURED); | 542 prerender_data->contents()->Destroy(FINAL_STATUS_PAGE_BEING_CAPTURED); |
541 return NULL; | 543 return NULL; |
542 } | 544 } |
543 | 545 |
(...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1823 histograms_->RecordNetworkBytes(used, prerender_bytes, recent_profile_bytes); | 1825 histograms_->RecordNetworkBytes(used, prerender_bytes, recent_profile_bytes); |
1824 } | 1826 } |
1825 | 1827 |
1826 void PrerenderManager::AddProfileNetworkBytesIfEnabled(int64 bytes) { | 1828 void PrerenderManager::AddProfileNetworkBytesIfEnabled(int64 bytes) { |
1827 DCHECK_GE(bytes, 0); | 1829 DCHECK_GE(bytes, 0); |
1828 if (IsEnabled() && ActuallyPrerendering()) | 1830 if (IsEnabled() && ActuallyPrerendering()) |
1829 profile_network_bytes_ += bytes; | 1831 profile_network_bytes_ += bytes; |
1830 } | 1832 } |
1831 | 1833 |
1832 } // namespace prerender | 1834 } // namespace prerender |
OLD | NEW |