Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(609)

Side by Side Diff: chrome/browser/prerender/prerender_manager.cc

Issue 6915019: Changes to not use the prerendered contents when window.opener needs to be set. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Addresing Chris's comments. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/prerender/prerender_manager.h" 5 #include "chrome/browser/prerender/prerender_manager.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 } 409 }
410 // Entry not found. 410 // Entry not found.
411 return NULL; 411 return NULL;
412 } 412 }
413 413
414 PrerenderContents* PrerenderManager::GetEntry(const GURL& url) { 414 PrerenderContents* PrerenderManager::GetEntry(const GURL& url) {
415 return GetEntryButNotSpecifiedTC(url, NULL); 415 return GetEntryButNotSpecifiedTC(url, NULL);
416 } 416 }
417 417
418 bool PrerenderManager::MaybeUsePreloadedPageOld(TabContents* tab_contents, 418 bool PrerenderManager::MaybeUsePreloadedPageOld(TabContents* tab_contents,
419 const GURL& url) { 419 const GURL& url,
420 bool has_opener_set) {
420 DCHECK(CalledOnValidThread()); 421 DCHECK(CalledOnValidThread());
421 scoped_ptr<PrerenderContents> prerender_contents(GetEntry(url)); 422 scoped_ptr<PrerenderContents> prerender_contents(GetEntry(url));
422 if (prerender_contents.get() == NULL) 423 if (prerender_contents.get() == NULL)
423 return false; 424 return false;
424 425
426 // Do not use the prerendered version if the opener window.property was
427 // supposed to be set.
428 if (has_opener_set) {
429 prerender_contents->set_final_status(FINAL_STATUS_WINDOW_OPENER);
cbentzel 2011/05/06 02:30:01 Should this be Destroy rather than set_final_statu
430 return false;
431 }
432
425 // If we are just in the control group (which can be detected by noticing 433 // If we are just in the control group (which can be detected by noticing
426 // that prerendering hasn't even started yet), record that |tab_contents| now 434 // that prerendering hasn't even started yet), record that |tab_contents| now
427 // would be showing a prerendered contents, but otherwise, don't do anything. 435 // would be showing a prerendered contents, but otherwise, don't do anything.
428 if (!prerender_contents->prerendering_has_started()) { 436 if (!prerender_contents->prerendering_has_started()) {
429 MarkTabContentsAsWouldBePrerendered(tab_contents); 437 MarkTabContentsAsWouldBePrerendered(tab_contents);
430 return false; 438 return false;
431 } 439 }
432 440
433 if (!prerender_contents->load_start_time().is_null()) 441 if (!prerender_contents->load_start_time().is_null())
434 RecordTimeUntilUsed(GetCurrentTimeTicks() - 442 RecordTimeUntilUsed(GetCurrentTimeTicks() -
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 urls); 507 urls);
500 } 508 }
501 509
502 if (prerender_contents->has_stopped_loading()) 510 if (prerender_contents->has_stopped_loading())
503 render_view_host_delegate->DidStopLoading(); 511 render_view_host_delegate->DidStopLoading();
504 512
505 return true; 513 return true;
506 } 514 }
507 515
508 bool PrerenderManager::MaybeUsePreloadedPage(TabContents* tab_contents, 516 bool PrerenderManager::MaybeUsePreloadedPage(TabContents* tab_contents,
509 const GURL& url) { 517 const GURL& url,
518 bool has_opener_set) {
510 if (!PrerenderContents::UseTabContents()) { 519 if (!PrerenderContents::UseTabContents()) {
511 VLOG(1) << "Checking for prerender with LEGACY code"; 520 VLOG(1) << "Checking for prerender with LEGACY code";
512 return PrerenderManager::MaybeUsePreloadedPageOld(tab_contents, url); 521 return PrerenderManager::MaybeUsePreloadedPageOld(tab_contents, url,
522 has_opener_set);
513 } 523 }
514 VLOG(1) << "Checking for prerender with NEW code"; 524 VLOG(1) << "Checking for prerender with NEW code";
515 DCHECK(CalledOnValidThread()); 525 DCHECK(CalledOnValidThread());
516 scoped_ptr<PrerenderContents> prerender_contents( 526 scoped_ptr<PrerenderContents> prerender_contents(
517 GetEntryButNotSpecifiedTC(url, tab_contents)); 527 GetEntryButNotSpecifiedTC(url, tab_contents));
518 if (prerender_contents.get() == NULL) 528 if (prerender_contents.get() == NULL)
519 return false; 529 return false;
520 530
531 // Do not use the prerendered version if the opener window.property was
532 // supposed to be set.
533 if (has_opener_set) {
534 prerender_contents->set_final_status(FINAL_STATUS_WINDOW_OPENER);
535 return false;
536 }
537
521 // If we are just in the control group (which can be detected by noticing 538 // If we are just in the control group (which can be detected by noticing
522 // that prerendering hasn't even started yet), record that |tab_contents| now 539 // that prerendering hasn't even started yet), record that |tab_contents| now
523 // would be showing a prerendered contents, but otherwise, don't do anything. 540 // would be showing a prerendered contents, but otherwise, don't do anything.
524 if (!prerender_contents->prerendering_has_started()) { 541 if (!prerender_contents->prerendering_has_started()) {
525 MarkTabContentsAsWouldBePrerendered(tab_contents); 542 MarkTabContentsAsWouldBePrerendered(tab_contents);
526 return false; 543 return false;
527 } 544 }
528 545
529 if (!prerender_contents->load_start_time().is_null()) 546 if (!prerender_contents->load_start_time().is_null())
530 RecordTimeUntilUsed(GetCurrentTimeTicks() - 547 RecordTimeUntilUsed(GetCurrentTimeTicks() -
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 return prerendered_tab_contents_set_.count(tab_contents) > 0; 902 return prerendered_tab_contents_set_.count(tab_contents) > 0;
886 } 903 }
887 904
888 bool PrerenderManager::WouldTabContentsBePrerendered( 905 bool PrerenderManager::WouldTabContentsBePrerendered(
889 TabContents* tab_contents) const { 906 TabContents* tab_contents) const {
890 DCHECK(CalledOnValidThread()); 907 DCHECK(CalledOnValidThread());
891 return would_be_prerendered_tab_contents_set_.count(tab_contents) > 0; 908 return would_be_prerendered_tab_contents_set_.count(tab_contents) > 0;
892 } 909 }
893 910
894 } // namespace prerender 911 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_manager.h ('k') | chrome/browser/prerender/prerender_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698