Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/navigation_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 | 380 |
| 381 NavigationEntryImpl* NavigationControllerImpl::GetEntryWithPageID( | 381 NavigationEntryImpl* NavigationControllerImpl::GetEntryWithPageID( |
| 382 SiteInstance* instance, int32 page_id) const { | 382 SiteInstance* instance, int32 page_id) const { |
| 383 int index = GetEntryIndexWithPageID(instance, page_id); | 383 int index = GetEntryIndexWithPageID(instance, page_id); |
| 384 return (index != -1) ? entries_[index].get() : NULL; | 384 return (index != -1) ? entries_[index].get() : NULL; |
| 385 } | 385 } |
| 386 | 386 |
| 387 bool NavigationControllerImpl::HasCommittedRealLoad( | 387 bool NavigationControllerImpl::HasCommittedRealLoad( |
| 388 FrameTreeNode* frame_tree_node) const { | 388 FrameTreeNode* frame_tree_node) const { |
| 389 NavigationEntryImpl* last_committed = GetLastCommittedEntry(); | 389 NavigationEntryImpl* last_committed = GetLastCommittedEntry(); |
| 390 return last_committed && last_committed->HasFrameEntry(frame_tree_node); | 390 return last_committed && last_committed->GetFrameEntry(frame_tree_node); |
| 391 } | 391 } |
| 392 | 392 |
| 393 void NavigationControllerImpl::LoadEntry(NavigationEntryImpl* entry) { | 393 void NavigationControllerImpl::LoadEntry(NavigationEntryImpl* entry) { |
| 394 // When navigating to a new page, we don't know for sure if we will actually | 394 // When navigating to a new page, we don't know for sure if we will actually |
| 395 // end up leaving the current page. The new page load could for example | 395 // end up leaving the current page. The new page load could for example |
| 396 // result in a download or a 'no content' response (e.g., a mailto: URL). | 396 // result in a download or a 'no content' response (e.g., a mailto: URL). |
| 397 SetPendingEntry(entry); | 397 SetPendingEntry(entry); |
| 398 NavigateToPendingEntry(NO_RELOAD); | 398 NavigateToPendingEntry(NO_RELOAD); |
| 399 } | 399 } |
| 400 | 400 |
| (...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1216 new_entry->SetReferrer(params.referrer); | 1216 new_entry->SetReferrer(params.referrer); |
| 1217 new_entry->SetPageID(params.page_id); | 1217 new_entry->SetPageID(params.page_id); |
| 1218 new_entry->SetTransitionType(params.transition); | 1218 new_entry->SetTransitionType(params.transition); |
| 1219 new_entry->set_site_instance( | 1219 new_entry->set_site_instance( |
| 1220 static_cast<SiteInstanceImpl*>(rfh->GetSiteInstance())); | 1220 static_cast<SiteInstanceImpl*>(rfh->GetSiteInstance())); |
| 1221 new_entry->SetHasPostData(params.is_post); | 1221 new_entry->SetHasPostData(params.is_post); |
| 1222 new_entry->SetPostID(params.post_id); | 1222 new_entry->SetPostID(params.post_id); |
| 1223 new_entry->SetOriginalRequestURL(params.original_request_url); | 1223 new_entry->SetOriginalRequestURL(params.original_request_url); |
| 1224 new_entry->SetIsOverridingUserAgent(params.is_overriding_user_agent); | 1224 new_entry->SetIsOverridingUserAgent(params.is_overriding_user_agent); |
| 1225 | 1225 |
| 1226 // Update the FrameNavigationEntry for new main frame commits. | |
| 1227 FrameNavigationEntry* frame_entry = | |
| 1228 new_entry->GetFrameEntry(rfh->frame_tree_node()); | |
|
Charlie Reis
2015/06/18 20:30:18
I went ahead and added GetFrameEntry, since it's c
| |
| 1229 frame_entry->set_item_sequence_number(params.item_sequence_number); | |
| 1230 frame_entry->set_document_sequence_number(params.document_sequence_number); | |
| 1231 | |
| 1226 // history.pushState() is classified as a navigation to a new page, but | 1232 // history.pushState() is classified as a navigation to a new page, but |
| 1227 // sets was_within_same_page to true. In this case, we already have the | 1233 // sets was_within_same_page to true. In this case, we already have the |
| 1228 // title and favicon available, so set them immediately. | 1234 // title and favicon available, so set them immediately. |
| 1229 if (params.was_within_same_page && GetLastCommittedEntry()) { | 1235 if (params.was_within_same_page && GetLastCommittedEntry()) { |
| 1230 new_entry->SetTitle(GetLastCommittedEntry()->GetTitle()); | 1236 new_entry->SetTitle(GetLastCommittedEntry()->GetTitle()); |
| 1231 new_entry->GetFavicon() = GetLastCommittedEntry()->GetFavicon(); | 1237 new_entry->GetFavicon() = GetLastCommittedEntry()->GetFavicon(); |
| 1232 } | 1238 } |
| 1233 | 1239 |
| 1234 DCHECK(!params.history_list_was_cleared || !replace_entry); | 1240 DCHECK(!params.history_list_was_cleared || !replace_entry); |
| 1235 // The browser requested to clear the session history when it initiated the | 1241 // The browser requested to clear the session history when it initiated the |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1392 // stored in the page state for each of those entries. This happens out of | 1398 // stored in the page state for each of those entries. This happens out of |
| 1393 // band with the actual navigations. | 1399 // band with the actual navigations. |
| 1394 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " | 1400 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " |
| 1395 << "that a last committed entry exists."; | 1401 << "that a last committed entry exists."; |
| 1396 | 1402 |
| 1397 NavigationEntryImpl* new_entry = nullptr; | 1403 NavigationEntryImpl* new_entry = nullptr; |
| 1398 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1404 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1399 switches::kSitePerProcess)) { | 1405 switches::kSitePerProcess)) { |
| 1400 // Make sure new_entry takes ownership of frame_entry in a scoped_refptr. | 1406 // Make sure new_entry takes ownership of frame_entry in a scoped_refptr. |
| 1401 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( | 1407 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( |
| 1402 rfh->frame_tree_node()->frame_tree_node_id(), rfh->GetSiteInstance(), | 1408 rfh->frame_tree_node()->frame_tree_node_id(), |
| 1403 params.url, params.referrer); | 1409 params.item_sequence_number, params.document_sequence_number, |
| 1410 rfh->GetSiteInstance(), params.url, params.referrer); | |
| 1404 new_entry = GetLastCommittedEntry()->CloneAndReplace(rfh->frame_tree_node(), | 1411 new_entry = GetLastCommittedEntry()->CloneAndReplace(rfh->frame_tree_node(), |
| 1405 frame_entry); | 1412 frame_entry); |
| 1406 CHECK(frame_entry->HasOneRef()); | 1413 CHECK(frame_entry->HasOneRef()); |
| 1407 } else { | 1414 } else { |
| 1408 new_entry = GetLastCommittedEntry()->Clone(); | 1415 new_entry = GetLastCommittedEntry()->Clone(); |
| 1409 } | 1416 } |
| 1410 | 1417 |
| 1411 new_entry->SetPageID(params.page_id); | 1418 new_entry->SetPageID(params.page_id); |
| 1412 InsertOrReplaceEntry(new_entry, false); | 1419 InsertOrReplaceEntry(new_entry, false); |
| 1413 } | 1420 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1449 return true; | 1456 return true; |
| 1450 } | 1457 } |
| 1451 } | 1458 } |
| 1452 | 1459 |
| 1453 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1460 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1454 switches::kSitePerProcess)) { | 1461 switches::kSitePerProcess)) { |
| 1455 // This may be a "new auto" case where we add a new FrameNavigationEntry, or | 1462 // This may be a "new auto" case where we add a new FrameNavigationEntry, or |
| 1456 // it may be a "history auto" case where we update an existing one. | 1463 // it may be a "history auto" case where we update an existing one. |
| 1457 NavigationEntryImpl* last_committed = GetLastCommittedEntry(); | 1464 NavigationEntryImpl* last_committed = GetLastCommittedEntry(); |
| 1458 last_committed->AddOrUpdateFrameEntry(rfh->frame_tree_node(), | 1465 last_committed->AddOrUpdateFrameEntry(rfh->frame_tree_node(), |
| 1466 params.item_sequence_number, | |
| 1467 params.document_sequence_number, | |
| 1459 rfh->GetSiteInstance(), params.url, | 1468 rfh->GetSiteInstance(), params.url, |
| 1460 params.referrer, params.page_state); | 1469 params.referrer, params.page_state); |
| 1461 | 1470 |
| 1462 // Cross-process subframe navigations may leave a pending entry around. | 1471 // Cross-process subframe navigations may leave a pending entry around. |
| 1463 // Clear it if it's actually for the subframe. | 1472 // Clear it if it's actually for the subframe. |
| 1464 // TODO(creis): Don't use pending entries for subframe navigations. | 1473 // TODO(creis): Don't use pending entries for subframe navigations. |
| 1465 // See https://crbug.com/495161. | 1474 // See https://crbug.com/495161. |
| 1466 if (pending_entry_ && | 1475 if (pending_entry_ && |
| 1467 pending_entry_->frame_tree_node_id() == | 1476 pending_entry_->frame_tree_node_id() == |
| 1468 rfh->frame_tree_node()->frame_tree_node_id()) { | 1477 rfh->frame_tree_node()->frame_tree_node_id()) { |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2050 } | 2059 } |
| 2051 } | 2060 } |
| 2052 } | 2061 } |
| 2053 | 2062 |
| 2054 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 2063 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
| 2055 const base::Callback<base::Time()>& get_timestamp_callback) { | 2064 const base::Callback<base::Time()>& get_timestamp_callback) { |
| 2056 get_timestamp_callback_ = get_timestamp_callback; | 2065 get_timestamp_callback_ = get_timestamp_callback; |
| 2057 } | 2066 } |
| 2058 | 2067 |
| 2059 } // namespace content | 2068 } // namespace content |
| OLD | NEW |