Chromium Code Reviews| 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 "content/browser/tab_contents/navigation_controller.h" | 5 #include "content/browser/tab_contents/navigation_controller.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 if (transient_entry_index_ != -1) | 283 if (transient_entry_index_ != -1) |
| 284 return entries_[transient_entry_index_].get(); | 284 return entries_[transient_entry_index_].get(); |
| 285 if (pending_entry_) | 285 if (pending_entry_) |
| 286 return pending_entry_; | 286 return pending_entry_; |
| 287 return GetLastCommittedEntry(); | 287 return GetLastCommittedEntry(); |
| 288 } | 288 } |
| 289 | 289 |
| 290 NavigationEntry* NavigationController::GetVisibleEntry() const { | 290 NavigationEntry* NavigationController::GetVisibleEntry() const { |
| 291 if (transient_entry_index_ != -1) | 291 if (transient_entry_index_ != -1) |
| 292 return entries_[transient_entry_index_].get(); | 292 return entries_[transient_entry_index_].get(); |
| 293 // Only return pending_entry for new navigations. | 293 // Only return pending_entry for new browser-initiated navigations, and not |
| 294 if (pending_entry_ && pending_entry_->page_id() == -1) | 294 // during link clicks (which might allow URL spoof attacks). |
| 295 // Ideally we would also show the pending entry's URL if there is no last | |
| 296 // committed entry (e.g., a link opening in a new tab), but the opener window | |
| 297 // can insert content into that about:blank page while the pending URL loads. | |
| 298 if (pending_entry_ && | |
| 299 pending_entry_->page_id() == -1 && | |
| 300 pending_entry_->transition_type() != PageTransition::LINK) | |
|
brettw
2011/10/11 18:11:29
I'm kind of freaked out by this condition. Is this
Charlie Reis
2011/10/11 19:40:42
There's two conditions here:
1) page_id == -1 mea
brettw
2011/10/11 19:51:09
I don't think we ever expected page transition typ
Charlie Reis
2011/10/11 20:14:29
Well, if we wanted to approach this another way, w
| |
| 295 return pending_entry_; | 301 return pending_entry_; |
| 296 return GetLastCommittedEntry(); | 302 return GetLastCommittedEntry(); |
| 297 } | 303 } |
| 298 | 304 |
| 299 int NavigationController::GetCurrentEntryIndex() const { | 305 int NavigationController::GetCurrentEntryIndex() const { |
| 300 if (transient_entry_index_ != -1) | 306 if (transient_entry_index_ != -1) |
| 301 return transient_entry_index_; | 307 return transient_entry_index_; |
| 302 if (pending_entry_index_ != -1) | 308 if (pending_entry_index_ != -1) |
| 303 return pending_entry_index_; | 309 return pending_entry_index_; |
| 304 return last_committed_entry_index_; | 310 return last_committed_entry_index_; |
| (...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1194 size_t insert_index = 0; | 1200 size_t insert_index = 0; |
| 1195 for (int i = 0; i < max_index; i++) { | 1201 for (int i = 0; i < max_index; i++) { |
| 1196 // When cloning a tab, copy all entries except interstitial pages | 1202 // When cloning a tab, copy all entries except interstitial pages |
| 1197 if (source.entries_[i].get()->page_type() != INTERSTITIAL_PAGE) { | 1203 if (source.entries_[i].get()->page_type() != INTERSTITIAL_PAGE) { |
| 1198 entries_.insert(entries_.begin() + insert_index++, | 1204 entries_.insert(entries_.begin() + insert_index++, |
| 1199 linked_ptr<NavigationEntry>( | 1205 linked_ptr<NavigationEntry>( |
| 1200 new NavigationEntry(*source.entries_[i]))); | 1206 new NavigationEntry(*source.entries_[i]))); |
| 1201 } | 1207 } |
| 1202 } | 1208 } |
| 1203 } | 1209 } |
| OLD | NEW |