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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 low_water_mark_ = high_water_mark_ = t; | 221 low_water_mark_ = high_water_mark_ = t; |
222 return t; | 222 return t; |
223 } | 223 } |
224 | 224 |
225 NavigationControllerImpl::NavigationControllerImpl( | 225 NavigationControllerImpl::NavigationControllerImpl( |
226 NavigationControllerDelegate* delegate, | 226 NavigationControllerDelegate* delegate, |
227 BrowserContext* browser_context) | 227 BrowserContext* browser_context) |
228 : browser_context_(browser_context), | 228 : browser_context_(browser_context), |
229 pending_entry_(NULL), | 229 pending_entry_(NULL), |
230 failed_pending_entry_id_(0), | 230 failed_pending_entry_id_(0), |
231 failed_pending_entry_should_replace_(false), | |
232 last_committed_entry_index_(-1), | 231 last_committed_entry_index_(-1), |
233 pending_entry_index_(-1), | 232 pending_entry_index_(-1), |
234 transient_entry_index_(-1), | 233 transient_entry_index_(-1), |
235 delegate_(delegate), | 234 delegate_(delegate), |
236 max_restored_page_id_(-1), | 235 max_restored_page_id_(-1), |
237 ssl_manager_(this), | 236 ssl_manager_(this), |
238 needs_reload_(false), | 237 needs_reload_(false), |
239 is_initial_navigation_(true), | 238 is_initial_navigation_(true), |
240 in_navigate_to_pending_entry_(false), | 239 in_navigate_to_pending_entry_(false), |
241 pending_reload_(NO_RELOAD), | 240 pending_reload_(NO_RELOAD), |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
847 | 846 |
848 // If there is a pending entry at this point, it should have a SiteInstance, | 847 // If there is a pending entry at this point, it should have a SiteInstance, |
849 // except for restored entries. | 848 // except for restored entries. |
850 DCHECK(pending_entry_index_ == -1 || | 849 DCHECK(pending_entry_index_ == -1 || |
851 pending_entry_->site_instance() || | 850 pending_entry_->site_instance() || |
852 pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE); | 851 pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE); |
853 if (pending_entry_ && | 852 if (pending_entry_ && |
854 pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE) | 853 pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE) |
855 pending_entry_->set_restore_type(NavigationEntryImpl::RESTORE_NONE); | 854 pending_entry_->set_restore_type(NavigationEntryImpl::RESTORE_NONE); |
856 | 855 |
857 // If we are doing a cross-site reload, we need to replace the existing | 856 // The renderer tells us whether the navigation replaces the current entry. |
858 // navigation entry, not add another entry to the history. This has the side | 857 details->did_replace_entry = params.should_replace_current_entry; |
Avi (use Gerrit)
2016/03/14 20:49:59
When we specify the error page load, do we copy ov
Charlie Reis
2016/03/14 21:18:19
In which context? In general, if the browser proc
| |
859 // effect of removing forward browsing history, if such existed. Or if we are | |
860 // doing a cross-site redirect navigation, we will do a similar thing. | |
861 // | |
862 // If this is an error load, we may have already removed the pending entry | |
863 // when we got the notice of the load failure. If so, look at the copy of the | |
864 // pending parameters that were saved. | |
865 if (params.url_is_unreachable && failed_pending_entry_id_ != 0) { | |
866 details->did_replace_entry = failed_pending_entry_should_replace_; | |
867 } else { | |
868 details->did_replace_entry = pending_entry_ && | |
869 pending_entry_->should_replace_entry(); | |
870 } | |
871 | 858 |
872 // Do navigation-type specific actions. These will make and commit an entry. | 859 // Do navigation-type specific actions. These will make and commit an entry. |
873 details->type = ClassifyNavigation(rfh, params); | 860 details->type = ClassifyNavigation(rfh, params); |
874 | 861 |
875 // is_in_page must be computed before the entry gets committed. | 862 // is_in_page must be computed before the entry gets committed. |
876 details->is_in_page = IsURLInPageNavigation( | 863 details->is_in_page = IsURLInPageNavigation( |
877 params.url, params.was_within_same_page, rfh); | 864 params.url, params.was_within_same_page, rfh); |
878 | 865 |
879 switch (details->type) { | 866 switch (details->type) { |
880 case NAVIGATION_TYPE_NEW_PAGE: | 867 case NAVIGATION_TYPE_NEW_PAGE: |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1005 // navigated on a popup navigated to about:blank (the iframe would be | 992 // navigated on a popup navigated to about:blank (the iframe would be |
1006 // written into the popup by script on the main page). For these cases, | 993 // written into the popup by script on the main page). For these cases, |
1007 // there isn't any navigation stuff we can do, so just ignore it. | 994 // there isn't any navigation stuff we can do, so just ignore it. |
1008 if (!GetLastCommittedEntry()) | 995 if (!GetLastCommittedEntry()) |
1009 return NAVIGATION_TYPE_NAV_IGNORE; | 996 return NAVIGATION_TYPE_NAV_IGNORE; |
1010 | 997 |
1011 // Valid subframe navigation. | 998 // Valid subframe navigation. |
1012 return NAVIGATION_TYPE_NEW_SUBFRAME; | 999 return NAVIGATION_TYPE_NEW_SUBFRAME; |
1013 } | 1000 } |
1014 | 1001 |
1002 // Cross-process location.replace navigations should be classified as New with | |
1003 // replacement rather than ExistingPage, since it is not safe to reuse the | |
1004 // NavigationEntry. | |
1005 // TODO(creis): Have the renderer classify location.replace as | |
1006 // did_create_new_entry for all cases and eliminate this special case. This | |
1007 // requires updating several test expectations. See https://crbug.com/317872. | |
1008 if (!rfh->GetParent() && GetLastCommittedEntry() && | |
1009 GetLastCommittedEntry()->site_instance() != rfh->GetSiteInstance() && | |
1010 params.should_replace_current_entry) { | |
1011 return NAVIGATION_TYPE_NEW_PAGE; | |
1012 } | |
1013 | |
1015 // We only clear the session history when navigating to a new page. | 1014 // We only clear the session history when navigating to a new page. |
1016 DCHECK(!params.history_list_was_cleared); | 1015 DCHECK(!params.history_list_was_cleared); |
1017 | 1016 |
1018 if (rfh->GetParent()) { | 1017 if (rfh->GetParent()) { |
1019 // All manual subframes would be did_create_new_entry and handled above, so | 1018 // All manual subframes would be did_create_new_entry and handled above, so |
1020 // we know this is auto. | 1019 // we know this is auto. |
1021 if (GetLastCommittedEntry()) { | 1020 if (GetLastCommittedEntry()) { |
1022 return NAVIGATION_TYPE_AUTO_SUBFRAME; | 1021 return NAVIGATION_TYPE_AUTO_SUBFRAME; |
1023 } else { | 1022 } else { |
1024 // We ignore subframes created in non-committed pages; we'd appreciate if | 1023 // We ignore subframes created in non-committed pages; we'd appreciate if |
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1989 | 1988 |
1990 void NavigationControllerImpl::DiscardPendingEntry(bool was_failure) { | 1989 void NavigationControllerImpl::DiscardPendingEntry(bool was_failure) { |
1991 // It is not safe to call DiscardPendingEntry while NavigateToEntry is in | 1990 // It is not safe to call DiscardPendingEntry while NavigateToEntry is in |
1992 // progress, since this will cause a use-after-free. (We only allow this | 1991 // progress, since this will cause a use-after-free. (We only allow this |
1993 // when the tab is being destroyed for shutdown, since it won't return to | 1992 // when the tab is being destroyed for shutdown, since it won't return to |
1994 // NavigateToEntry in that case.) http://crbug.com/347742. | 1993 // NavigateToEntry in that case.) http://crbug.com/347742. |
1995 CHECK(!in_navigate_to_pending_entry_ || delegate_->IsBeingDestroyed()); | 1994 CHECK(!in_navigate_to_pending_entry_ || delegate_->IsBeingDestroyed()); |
1996 | 1995 |
1997 if (was_failure && pending_entry_) { | 1996 if (was_failure && pending_entry_) { |
1998 failed_pending_entry_id_ = pending_entry_->GetUniqueID(); | 1997 failed_pending_entry_id_ = pending_entry_->GetUniqueID(); |
1999 failed_pending_entry_should_replace_ = | |
2000 pending_entry_->should_replace_entry(); | |
2001 } else { | 1998 } else { |
2002 failed_pending_entry_id_ = 0; | 1999 failed_pending_entry_id_ = 0; |
2003 } | 2000 } |
2004 | 2001 |
2005 if (pending_entry_index_ == -1) | 2002 if (pending_entry_index_ == -1) |
2006 delete pending_entry_; | 2003 delete pending_entry_; |
2007 pending_entry_ = NULL; | 2004 pending_entry_ = NULL; |
2008 pending_entry_index_ = -1; | 2005 pending_entry_index_ = -1; |
2009 } | 2006 } |
2010 | 2007 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2071 } | 2068 } |
2072 } | 2069 } |
2073 } | 2070 } |
2074 | 2071 |
2075 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 2072 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
2076 const base::Callback<base::Time()>& get_timestamp_callback) { | 2073 const base::Callback<base::Time()>& get_timestamp_callback) { |
2077 get_timestamp_callback_ = get_timestamp_callback; | 2074 get_timestamp_callback_ = get_timestamp_callback; |
2078 } | 2075 } |
2079 | 2076 |
2080 } // namespace content | 2077 } // namespace content |
OLD | NEW |