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