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

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

Issue 7618016: Additional fixes for prerender/instant + browsing history. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Wrong signature Created 9 years, 4 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_contents.h" 5 #include "chrome/browser/prerender/prerender_contents.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/process_util.h" 10 #include "base/process_util.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 // TabContentsDelegate implementation: 82 // TabContentsDelegate implementation:
83 virtual bool ShouldAddNavigationToHistory( 83 virtual bool ShouldAddNavigationToHistory(
84 const history::HistoryAddPageArgs& add_page_args, 84 const history::HistoryAddPageArgs& add_page_args,
85 NavigationType::Type navigation_type) OVERRIDE { 85 NavigationType::Type navigation_type) OVERRIDE {
86 add_page_vector_.push_back( 86 add_page_vector_.push_back(
87 scoped_refptr<history::HistoryAddPageArgs>(add_page_args.Clone())); 87 scoped_refptr<history::HistoryAddPageArgs>(add_page_args.Clone()));
88 return false; 88 return false;
89 } 89 }
90 90
91 bool CanDownload(TabContents* source, int request_id) OVERRIDE { 91 virtual bool CanDownload(TabContents* source, int request_id) OVERRIDE {
92 prerender_contents_->Destroy(FINAL_STATUS_DOWNLOAD); 92 prerender_contents_->Destroy(FINAL_STATUS_DOWNLOAD);
93 // Cancel the download. 93 // Cancel the download.
94 return false; 94 return false;
95 } 95 }
96 96
97 void OnStartDownload(TabContents* source, DownloadItem* download) OVERRIDE { 97 virtual void OnStartDownload(TabContents* source,
98 DownloadItem* download) OVERRIDE {
98 // Prerendered pages should never be able to download files. 99 // Prerendered pages should never be able to download files.
99 NOTREACHED(); 100 NOTREACHED();
100 } 101 }
101 102
103 virtual bool OnGoToEntryOffset(int offset) OVERRIDE {
104 // This isn't allowed because the history merge operation
105 // does not work if there are renderer issued challenges.
106 // TODO(cbentzel): Cancel in this case? May not need to do
107 // since render-issued offset navigations are not guaranteed,
108 // but indicates that the page cares about the history.
109 return false;
110 }
111
102 // Commits the History of Pages to the given TabContents. 112 // Commits the History of Pages to the given TabContents.
103 void CommitHistory(TabContentsWrapper* tab) { 113 void CommitHistory(TabContentsWrapper* tab) {
104 for (size_t i = 0; i < add_page_vector_.size(); ++i) 114 for (size_t i = 0; i < add_page_vector_.size(); ++i)
105 tab->history_tab_helper()->UpdateHistoryForNavigation( 115 tab->history_tab_helper()->UpdateHistoryForNavigation(
106 add_page_vector_[i].get()); 116 add_page_vector_[i].get());
107 } 117 }
108 118
109 private: 119 private:
110 typedef std::vector<scoped_refptr<history::HistoryAddPageArgs> > 120 typedef std::vector<scoped_refptr<history::HistoryAddPageArgs> >
111 AddPageVector; 121 AddPageVector;
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 if (!prerender_contents_.get()) 605 if (!prerender_contents_.get())
596 return NULL; 606 return NULL;
597 DictionaryValue* dict_value = new DictionaryValue(); 607 DictionaryValue* dict_value = new DictionaryValue();
598 dict_value->SetString("url", prerender_url_.spec()); 608 dict_value->SetString("url", prerender_url_.spec());
599 base::TimeTicks current_time = base::TimeTicks::Now(); 609 base::TimeTicks current_time = base::TimeTicks::Now();
600 base::TimeDelta duration = current_time - load_start_time_; 610 base::TimeDelta duration = current_time - load_start_time_;
601 dict_value->SetInteger("duration", duration.InSeconds()); 611 dict_value->SetInteger("duration", duration.InSeconds());
602 return dict_value; 612 return dict_value;
603 } 613 }
604 614
615 bool PrerenderContents::IsCrossSiteNavigationPending() const {
616 if (!prerender_contents_.get() || !prerender_contents_->tab_contents())
617 return false;
618 const TabContents* tab_contents = prerender_contents_->tab_contents();
619 return (tab_contents->GetSiteInstance() !=
620 tab_contents->GetPendingSiteInstance());
621 }
622
623
605 } // namespace prerender 624 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698