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 /* | 5 /* |
6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
10 * | 10 * |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 pending_entry_->set_restore_type(NavigationEntryImpl::RESTORE_NONE); | 840 pending_entry_->set_restore_type(NavigationEntryImpl::RESTORE_NONE); |
841 | 841 |
842 // If we are doing a cross-site reload, we need to replace the existing | 842 // If we are doing a cross-site reload, we need to replace the existing |
843 // navigation entry, not add another entry to the history. This has the side | 843 // navigation entry, not add another entry to the history. This has the side |
844 // effect of removing forward browsing history, if such existed. Or if we are | 844 // effect of removing forward browsing history, if such existed. Or if we are |
845 // doing a cross-site redirect navigation, we will do a similar thing. | 845 // doing a cross-site redirect navigation, we will do a similar thing. |
846 // | 846 // |
847 // If this is an error load, we may have already removed the pending entry | 847 // If this is an error load, we may have already removed the pending entry |
848 // when we got the notice of the load failure. If so, look at the copy of the | 848 // when we got the notice of the load failure. If so, look at the copy of the |
849 // pending parameters that were saved. | 849 // pending parameters that were saved. |
850 // | |
851 // TODO(creis): This block should be unnecessary now that we pass | |
852 // params.should_replace_current_entry. Remove it once we verify with the | |
853 // check below. | |
854 if (params.url_is_unreachable && failed_pending_entry_id_ != 0) { | 850 if (params.url_is_unreachable && failed_pending_entry_id_ != 0) { |
855 details->did_replace_entry = failed_pending_entry_should_replace_; | 851 details->did_replace_entry = failed_pending_entry_should_replace_; |
856 } else { | 852 } else { |
857 details->did_replace_entry = pending_entry_ && | 853 details->did_replace_entry = pending_entry_ && |
858 pending_entry_->should_replace_entry(); | 854 pending_entry_->should_replace_entry(); |
859 } | 855 } |
860 CHECK(!details->did_replace_entry || params.should_replace_current_entry); | |
861 if (params.should_replace_current_entry) | |
862 details->did_replace_entry = true; | |
863 | 856 |
864 // Do navigation-type specific actions. These will make and commit an entry. | 857 // Do navigation-type specific actions. These will make and commit an entry. |
865 details->type = ClassifyNavigation(rfh, params); | 858 details->type = ClassifyNavigation(rfh, params); |
866 | 859 |
867 // is_in_page must be computed before the entry gets committed. | 860 // is_in_page must be computed before the entry gets committed. |
868 details->is_in_page = IsURLInPageNavigation( | 861 details->is_in_page = IsURLInPageNavigation( |
869 params.url, params.was_within_same_page, rfh); | 862 params.url, params.was_within_same_page, rfh); |
870 | 863 |
871 switch (details->type) { | 864 switch (details->type) { |
872 case NAVIGATION_TYPE_NEW_PAGE: | 865 case NAVIGATION_TYPE_NEW_PAGE: |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 // navigated on a popup navigated to about:blank (the iframe would be | 990 // navigated on a popup navigated to about:blank (the iframe would be |
998 // written into the popup by script on the main page). For these cases, | 991 // written into the popup by script on the main page). For these cases, |
999 // there isn't any navigation stuff we can do, so just ignore it. | 992 // there isn't any navigation stuff we can do, so just ignore it. |
1000 if (!GetLastCommittedEntry()) | 993 if (!GetLastCommittedEntry()) |
1001 return NAVIGATION_TYPE_NAV_IGNORE; | 994 return NAVIGATION_TYPE_NAV_IGNORE; |
1002 | 995 |
1003 // Valid subframe navigation. | 996 // Valid subframe navigation. |
1004 return NAVIGATION_TYPE_NEW_SUBFRAME; | 997 return NAVIGATION_TYPE_NEW_SUBFRAME; |
1005 } | 998 } |
1006 | 999 |
1007 // Cross-process location.replace navigations should be classified as New with | |
1008 // replacement rather than ExistingPage, since it is not safe to reuse the | |
1009 // NavigationEntry. | |
1010 // TODO(creis): Have the renderer classify location.replace as | |
1011 // did_create_new_entry for all cases and eliminate this special case. This | |
1012 // requires updating several test expectations. See https://crbug.com/317872. | |
1013 if (!rfh->GetParent() && GetLastCommittedEntry() && | |
1014 GetLastCommittedEntry()->site_instance() != rfh->GetSiteInstance() && | |
1015 params.should_replace_current_entry) { | |
1016 return NAVIGATION_TYPE_NEW_PAGE; | |
1017 } | |
1018 | |
1019 // We only clear the session history when navigating to a new page. | 1000 // We only clear the session history when navigating to a new page. |
1020 DCHECK(!params.history_list_was_cleared); | 1001 DCHECK(!params.history_list_was_cleared); |
1021 | 1002 |
1022 if (rfh->GetParent()) { | 1003 if (rfh->GetParent()) { |
1023 // All manual subframes would be did_create_new_entry and handled above, so | 1004 // All manual subframes would be did_create_new_entry and handled above, so |
1024 // we know this is auto. | 1005 // we know this is auto. |
1025 if (GetLastCommittedEntry()) { | 1006 if (GetLastCommittedEntry()) { |
1026 return NAVIGATION_TYPE_AUTO_SUBFRAME; | 1007 return NAVIGATION_TYPE_AUTO_SUBFRAME; |
1027 } else { | 1008 } else { |
1028 // We ignore subframes created in non-committed pages; we'd appreciate if | 1009 // We ignore subframes created in non-committed pages; we'd appreciate if |
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2067 } | 2048 } |
2068 } | 2049 } |
2069 } | 2050 } |
2070 | 2051 |
2071 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 2052 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
2072 const base::Callback<base::Time()>& get_timestamp_callback) { | 2053 const base::Callback<base::Time()>& get_timestamp_callback) { |
2073 get_timestamp_callback_ = get_timestamp_callback; | 2054 get_timestamp_callback_ = get_timestamp_callback; |
2074 } | 2055 } |
2075 | 2056 |
2076 } // namespace content | 2057 } // namespace content |
OLD | NEW |