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

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: Synced 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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 } 417 }
418 // Entry not found. 418 // Entry not found.
419 return NULL; 419 return NULL;
420 } 420 }
421 421
422 PrerenderContents* PrerenderManager::GetEntry(const GURL& url) { 422 PrerenderContents* PrerenderManager::GetEntry(const GURL& url) {
423 return GetEntryButNotSpecifiedTC(url, NULL); 423 return GetEntryButNotSpecifiedTC(url, NULL);
424 } 424 }
425 425
426 bool PrerenderManager::MaybeUsePreloadedPageOld(TabContents* tab_contents, 426 bool PrerenderManager::MaybeUsePreloadedPageOld(TabContents* tab_contents,
427 const GURL& url) { 427 const GURL& url,
428 bool has_opener_set) {
428 DCHECK(CalledOnValidThread()); 429 DCHECK(CalledOnValidThread());
429 scoped_ptr<PrerenderContents> prerender_contents(GetEntry(url)); 430 scoped_ptr<PrerenderContents> prerender_contents(GetEntry(url));
430 if (prerender_contents.get() == NULL) 431 if (prerender_contents.get() == NULL)
431 return false; 432 return false;
432 433
434 // Do not use the prerendered version if the opener window.property was
435 // supposed to be set.
436 if (has_opener_set) {
437 prerender_contents.release()->Destroy(FINAL_STATUS_WINDOW_OPENER);
438 return false;
439 }
440
433 // If we are just in the control group (which can be detected by noticing 441 // If we are just in the control group (which can be detected by noticing
434 // that prerendering hasn't even started yet), record that |tab_contents| now 442 // that prerendering hasn't even started yet), record that |tab_contents| now
435 // would be showing a prerendered contents, but otherwise, don't do anything. 443 // would be showing a prerendered contents, but otherwise, don't do anything.
436 if (!prerender_contents->prerendering_has_started()) { 444 if (!prerender_contents->prerendering_has_started()) {
437 MarkTabContentsAsWouldBePrerendered(tab_contents); 445 MarkTabContentsAsWouldBePrerendered(tab_contents);
438 return false; 446 return false;
439 } 447 }
440 448
441 int child_id, route_id; 449 int child_id, route_id;
442 CHECK(prerender_contents->GetChildId(&child_id)); 450 CHECK(prerender_contents->GetChildId(&child_id));
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 urls); 516 urls);
509 } 517 }
510 518
511 if (prerender_contents->has_stopped_loading()) 519 if (prerender_contents->has_stopped_loading())
512 render_view_host_delegate->DidStopLoading(); 520 render_view_host_delegate->DidStopLoading();
513 521
514 return true; 522 return true;
515 } 523 }
516 524
517 bool PrerenderManager::MaybeUsePreloadedPage(TabContents* tab_contents, 525 bool PrerenderManager::MaybeUsePreloadedPage(TabContents* tab_contents,
518 const GURL& url) { 526 const GURL& url,
527 bool has_opener_set) {
519 if (!PrerenderContents::UseTabContents()) { 528 if (!PrerenderContents::UseTabContents()) {
520 VLOG(1) << "Checking for prerender with LEGACY code"; 529 VLOG(1) << "Checking for prerender with LEGACY code";
521 return PrerenderManager::MaybeUsePreloadedPageOld(tab_contents, url); 530 return PrerenderManager::MaybeUsePreloadedPageOld(tab_contents, url,
531 has_opener_set);
522 } 532 }
523 VLOG(1) << "Checking for prerender with NEW code"; 533 VLOG(1) << "Checking for prerender with NEW code";
524 DCHECK(CalledOnValidThread()); 534 DCHECK(CalledOnValidThread());
525 scoped_ptr<PrerenderContents> prerender_contents( 535 scoped_ptr<PrerenderContents> prerender_contents(
526 GetEntryButNotSpecifiedTC(url, tab_contents)); 536 GetEntryButNotSpecifiedTC(url, tab_contents));
527 if (prerender_contents.get() == NULL) 537 if (prerender_contents.get() == NULL)
528 return false; 538 return false;
529 539
540 // Do not use the prerendered version if the opener window.property was
541 // supposed to be set.
542 if (has_opener_set) {
543 prerender_contents.release()->Destroy(FINAL_STATUS_WINDOW_OPENER);
544 return false;
545 }
546
530 // If we are just in the control group (which can be detected by noticing 547 // If we are just in the control group (which can be detected by noticing
531 // that prerendering hasn't even started yet), record that |tab_contents| now 548 // that prerendering hasn't even started yet), record that |tab_contents| now
532 // would be showing a prerendered contents, but otherwise, don't do anything. 549 // would be showing a prerendered contents, but otherwise, don't do anything.
533 if (!prerender_contents->prerendering_has_started()) { 550 if (!prerender_contents->prerendering_has_started()) {
534 MarkTabContentsAsWouldBePrerendered(tab_contents); 551 MarkTabContentsAsWouldBePrerendered(tab_contents);
535 return false; 552 return false;
536 } 553 }
537 554
538 int child_id, route_id; 555 int child_id, route_id;
539 CHECK(prerender_contents->GetChildId(&child_id)); 556 CHECK(prerender_contents->GetChildId(&child_id));
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 base::TimeTicks cutoff = GetCurrentTimeTicks() - 994 base::TimeTicks cutoff = GetCurrentTimeTicks() -
978 base::TimeDelta::FromMilliseconds(kNavigationRecordWindowMs); 995 base::TimeDelta::FromMilliseconds(kNavigationRecordWindowMs);
979 while (!navigations_.empty()) { 996 while (!navigations_.empty()) {
980 if (navigations_.front().time_ > cutoff) 997 if (navigations_.front().time_ > cutoff)
981 break; 998 break;
982 navigations_.pop_front(); 999 navigations_.pop_front();
983 } 1000 }
984 } 1001 }
985 1002
986 } // namespace prerender 1003 } // 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