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

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: Uploading synced version for commit. 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 } 406 }
407 // Entry not found. 407 // Entry not found.
408 return NULL; 408 return NULL;
409 } 409 }
410 410
411 PrerenderContents* PrerenderManager::GetEntry(const GURL& url) { 411 PrerenderContents* PrerenderManager::GetEntry(const GURL& url) {
412 return GetEntryButNotSpecifiedTC(url, NULL); 412 return GetEntryButNotSpecifiedTC(url, NULL);
413 } 413 }
414 414
415 bool PrerenderManager::MaybeUsePreloadedPageOld(TabContents* tab_contents, 415 bool PrerenderManager::MaybeUsePreloadedPageOld(TabContents* tab_contents,
416 const GURL& url) { 416 const GURL& url,
417 bool has_opener_set) {
417 DCHECK(CalledOnValidThread()); 418 DCHECK(CalledOnValidThread());
418 scoped_ptr<PrerenderContents> prerender_contents(GetEntry(url)); 419 scoped_ptr<PrerenderContents> prerender_contents(GetEntry(url));
419 if (prerender_contents.get() == NULL) 420 if (prerender_contents.get() == NULL)
420 return false; 421 return false;
421 422
423 // Do not use the prerendered version if the opener window.property was
424 // supposed to be set.
425 if (has_opener_set) {
426 prerender_contents.release()->Destroy(FINAL_STATUS_WINDOW_OPENER);
427 return false;
428 }
429
422 // If we are just in the control group (which can be detected by noticing 430 // If we are just in the control group (which can be detected by noticing
423 // that prerendering hasn't even started yet), record that |tab_contents| now 431 // that prerendering hasn't even started yet), record that |tab_contents| now
424 // would be showing a prerendered contents, but otherwise, don't do anything. 432 // would be showing a prerendered contents, but otherwise, don't do anything.
425 if (!prerender_contents->prerendering_has_started()) { 433 if (!prerender_contents->prerendering_has_started()) {
426 MarkTabContentsAsWouldBePrerendered(tab_contents); 434 MarkTabContentsAsWouldBePrerendered(tab_contents);
427 return false; 435 return false;
428 } 436 }
429 437
430 if (!prerender_contents->load_start_time().is_null()) 438 if (!prerender_contents->load_start_time().is_null())
431 RecordTimeUntilUsed(GetCurrentTimeTicks() - 439 RecordTimeUntilUsed(GetCurrentTimeTicks() -
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 urls); 500 urls);
493 } 501 }
494 502
495 if (prerender_contents->has_stopped_loading()) 503 if (prerender_contents->has_stopped_loading())
496 render_view_host_delegate->DidStopLoading(); 504 render_view_host_delegate->DidStopLoading();
497 505
498 return true; 506 return true;
499 } 507 }
500 508
501 bool PrerenderManager::MaybeUsePreloadedPage(TabContents* tab_contents, 509 bool PrerenderManager::MaybeUsePreloadedPage(TabContents* tab_contents,
502 const GURL& url) { 510 const GURL& url,
511 bool has_opener_set) {
503 if (!PrerenderContents::UseTabContents()) { 512 if (!PrerenderContents::UseTabContents()) {
504 VLOG(1) << "Checking for prerender with LEGACY code"; 513 VLOG(1) << "Checking for prerender with LEGACY code";
505 return PrerenderManager::MaybeUsePreloadedPageOld(tab_contents, url); 514 return PrerenderManager::MaybeUsePreloadedPageOld(tab_contents, url,
515 has_opener_set);
506 } 516 }
507 VLOG(1) << "Checking for prerender with NEW code"; 517 VLOG(1) << "Checking for prerender with NEW code";
508 DCHECK(CalledOnValidThread()); 518 DCHECK(CalledOnValidThread());
509 scoped_ptr<PrerenderContents> prerender_contents( 519 scoped_ptr<PrerenderContents> prerender_contents(
510 GetEntryButNotSpecifiedTC(url, tab_contents)); 520 GetEntryButNotSpecifiedTC(url, tab_contents));
511 if (prerender_contents.get() == NULL) 521 if (prerender_contents.get() == NULL)
512 return false; 522 return false;
513 523
524 // Do not use the prerendered version if the opener window.property was
525 // supposed to be set.
526 if (has_opener_set) {
527 prerender_contents.release()->Destroy(FINAL_STATUS_WINDOW_OPENER);
528 return false;
529 }
530
514 // If we are just in the control group (which can be detected by noticing 531 // If we are just in the control group (which can be detected by noticing
515 // that prerendering hasn't even started yet), record that |tab_contents| now 532 // that prerendering hasn't even started yet), record that |tab_contents| now
516 // would be showing a prerendered contents, but otherwise, don't do anything. 533 // would be showing a prerendered contents, but otherwise, don't do anything.
517 if (!prerender_contents->prerendering_has_started()) { 534 if (!prerender_contents->prerendering_has_started()) {
518 MarkTabContentsAsWouldBePrerendered(tab_contents); 535 MarkTabContentsAsWouldBePrerendered(tab_contents);
519 return false; 536 return false;
520 } 537 }
521 538
522 if (!prerender_contents->load_start_time().is_null()) 539 if (!prerender_contents->load_start_time().is_null())
523 RecordTimeUntilUsed(GetCurrentTimeTicks() - 540 RecordTimeUntilUsed(GetCurrentTimeTicks() -
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 return prerendered_tab_contents_set_.count(tab_contents) > 0; 929 return prerendered_tab_contents_set_.count(tab_contents) > 0;
913 } 930 }
914 931
915 bool PrerenderManager::WouldTabContentsBePrerendered( 932 bool PrerenderManager::WouldTabContentsBePrerendered(
916 TabContents* tab_contents) const { 933 TabContents* tab_contents) const {
917 DCHECK(CalledOnValidThread()); 934 DCHECK(CalledOnValidThread());
918 return would_be_prerendered_tab_contents_set_.count(tab_contents) > 0; 935 return would_be_prerendered_tab_contents_set_.count(tab_contents) > 0;
919 } 936 }
920 937
921 } // namespace prerender 938 } // 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