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 /* | 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 return true; | 155 return true; |
| 156 } | 156 } |
| 157 | 157 |
| 158 if (ui::PageTransitionCoreTypeIs(entry->GetTransitionType(), | 158 if (ui::PageTransitionCoreTypeIs(entry->GetTransitionType(), |
| 159 ui::PAGE_TRANSITION_LINK)) { | 159 ui::PAGE_TRANSITION_LINK)) { |
| 160 return true; | 160 return true; |
| 161 } | 161 } |
| 162 return false; | 162 return false; |
| 163 } | 163 } |
| 164 | 164 |
| 165 bool IsBlockedNavigation(net::Error error_code) { | |
| 166 switch (error_code) { | |
|
Charlie Reis
2017/05/18 22:41:46
I'm nervous about hand picking these out of net_er
nasko
2017/05/18 22:55:11
I don't think that such a distinction exists actua
| |
| 167 case net::ERR_ACCESS_DENIED: | |
| 168 case net::ERR_NOT_IMPLEMENTED: | |
| 169 case net::ERR_BLOCKED_BY_CLIENT: | |
| 170 case net::ERR_BLOCKED_BY_ADMINISTRATOR: | |
| 171 case net::ERR_BLOCKED_BY_RESPONSE: | |
| 172 case net::ERR_BLOCKED_BY_XSS_AUDITOR: | |
| 173 case net::ERR_CLEARTEXT_NOT_PERMITTED: | |
| 174 case net::ERR_NETWORK_ACCESS_DENIED: // Does this mean blocked? | |
|
Charlie Reis
2017/05/18 22:41:46
I would probably remove this. Network access deni
nasko
2017/05/18 22:55:11
My goal was to pick the errors that aren't transie
| |
| 175 case net::ERR_INVALID_URL: | |
|
Charlie Reis
2017/05/18 22:41:46
Should we remove this to get the test to pass, or
nasko
2017/05/18 22:55:11
I don't think the test is doing what it is expecti
Charlie Reis
2017/05/18 23:15:51
Agreed-- let's look more closely at it tomorrow.
| |
| 176 case net::ERR_DISALLOWED_URL_SCHEME: | |
| 177 case net::ERR_UNSAFE_REDIRECT: | |
| 178 case net::ERR_UNSAFE_PORT: | |
| 179 return true; | |
| 180 default: | |
| 181 return false; | |
| 182 } | |
| 183 } | |
| 184 | |
| 165 } // namespace | 185 } // namespace |
| 166 | 186 |
| 167 // NavigationControllerImpl ---------------------------------------------------- | 187 // NavigationControllerImpl ---------------------------------------------------- |
| 168 | 188 |
| 169 const size_t kMaxEntryCountForTestingNotSet = static_cast<size_t>(-1); | 189 const size_t kMaxEntryCountForTestingNotSet = static_cast<size_t>(-1); |
| 170 | 190 |
| 171 // static | 191 // static |
| 172 size_t NavigationControllerImpl::max_entry_count_for_testing_ = | 192 size_t NavigationControllerImpl::max_entry_count_for_testing_ = |
| 173 kMaxEntryCountForTestingNotSet; | 193 kMaxEntryCountForTestingNotSet; |
| 174 | 194 |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 878 case NAVIGATION_TYPE_NEW_SUBFRAME: | 898 case NAVIGATION_TYPE_NEW_SUBFRAME: |
| 879 RendererDidNavigateNewSubframe(rfh, params, details->is_same_document, | 899 RendererDidNavigateNewSubframe(rfh, params, details->is_same_document, |
| 880 details->did_replace_entry); | 900 details->did_replace_entry); |
| 881 break; | 901 break; |
| 882 case NAVIGATION_TYPE_AUTO_SUBFRAME: | 902 case NAVIGATION_TYPE_AUTO_SUBFRAME: |
| 883 if (!RendererDidNavigateAutoSubframe(rfh, params)) { | 903 if (!RendererDidNavigateAutoSubframe(rfh, params)) { |
| 884 // We don't send a notification about auto-subframe PageState during | 904 // We don't send a notification about auto-subframe PageState during |
| 885 // UpdateStateForFrame, since it looks like nothing has changed. Send | 905 // UpdateStateForFrame, since it looks like nothing has changed. Send |
| 886 // it here at commit time instead. | 906 // it here at commit time instead. |
| 887 NotifyEntryChanged(GetLastCommittedEntry()); | 907 NotifyEntryChanged(GetLastCommittedEntry()); |
| 888 return false; | 908 return false; |
|
Charlie Reis
2017/05/18 22:41:46
If we later extend this fix to subframes, we'll ne
nasko
2017/05/18 22:55:11
Noted! Should we add a TODO/Note?
Charlie Reis
2017/05/18 23:15:51
Yes, maybe down on the comment you're adding for t
nasko
2017/05/19 18:30:52
Done.
| |
| 889 } | 909 } |
| 890 break; | 910 break; |
| 891 case NAVIGATION_TYPE_NAV_IGNORE: | 911 case NAVIGATION_TYPE_NAV_IGNORE: |
| 892 // If a pending navigation was in progress, this canceled it. We should | 912 // If a pending navigation was in progress, this canceled it. We should |
| 893 // discard it and make sure it is removed from the URL bar. After that, | 913 // discard it and make sure it is removed from the URL bar. After that, |
| 894 // there is nothing we can do with this navigation, so we just return to | 914 // there is nothing we can do with this navigation, so we just return to |
| 895 // the caller that nothing has happened. | 915 // the caller that nothing has happened. |
| 896 if (pending_entry_) { | 916 if (pending_entry_) { |
| 897 DiscardNonCommittedEntries(); | 917 DiscardNonCommittedEntries(); |
| 898 delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); | 918 delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 926 FrameNavigationEntry* frame_entry = | 946 FrameNavigationEntry* frame_entry = |
| 927 active_entry->GetFrameEntry(rfh->frame_tree_node()); | 947 active_entry->GetFrameEntry(rfh->frame_tree_node()); |
| 928 // Update the frame-specific PageState and RedirectChain | 948 // Update the frame-specific PageState and RedirectChain |
| 929 // We may not find a frame_entry in some cases; ignore the PageState if so. | 949 // We may not find a frame_entry in some cases; ignore the PageState if so. |
| 930 // TODO(creis): Remove the "if" once https://crbug.com/522193 is fixed. | 950 // TODO(creis): Remove the "if" once https://crbug.com/522193 is fixed. |
| 931 if (frame_entry) { | 951 if (frame_entry) { |
| 932 frame_entry->SetPageState(params.page_state); | 952 frame_entry->SetPageState(params.page_state); |
| 933 frame_entry->set_redirect_chain(params.redirects); | 953 frame_entry->set_redirect_chain(params.redirects); |
| 934 } | 954 } |
| 935 | 955 |
| 956 // When a navigation in the main frame is blocked, it will display an error | |
| 957 // page. To avoid committing the blocked URL in back/forward/reload | |
| 958 // navigations, ensure the underlying URL is safe to load and preserve the | |
| 959 // UX by setting the blocked URL as the virtual URL on |active_entry|. To | |
| 960 // ensure the renderer process doesn't also navigate there, overwrite the | |
| 961 // PageState with a new one. | |
|
Charlie Reis
2017/05/18 22:41:46
Sounds good. Slight rephrase:
... To avoid loadi
nasko
2017/05/18 22:55:11
Done.
| |
| 962 if (!rfh->GetParent() && | |
| 963 IsBlockedNavigation(navigation_handle->GetNetErrorCode())) { | |
| 964 DCHECK(params.url_is_unreachable); | |
|
Charlie Reis
2017/05/18 22:41:46
Heh, I have some mixed feelings here.
We generall
nasko
2017/05/18 22:55:11
I wanted it mainly for discovering potential issue
| |
| 965 active_entry->SetURL(GURL(url::kAboutBlankURL)); | |
| 966 active_entry->SetVirtualURL(params.url); | |
| 967 if (frame_entry) | |
|
Charlie Reis
2017/05/18 22:41:46
nit: Needs braces.
nasko
2017/05/18 22:55:11
Done.
| |
| 968 frame_entry->SetPageState( | |
| 969 PageState::CreateFromURL(active_entry->GetURL())); | |
| 970 } | |
| 971 | |
| 936 // Use histogram to track memory impact of redirect chain because it's now | 972 // Use histogram to track memory impact of redirect chain because it's now |
| 937 // not cleared for committed entries. | 973 // not cleared for committed entries. |
| 938 size_t redirect_chain_size = 0; | 974 size_t redirect_chain_size = 0; |
| 939 for (size_t i = 0; i < params.redirects.size(); ++i) { | 975 for (size_t i = 0; i < params.redirects.size(); ++i) { |
| 940 redirect_chain_size += params.redirects[i].spec().length(); | 976 redirect_chain_size += params.redirects[i].spec().length(); |
| 941 } | 977 } |
| 942 UMA_HISTOGRAM_COUNTS("Navigation.RedirectChainSize", redirect_chain_size); | 978 UMA_HISTOGRAM_COUNTS("Navigation.RedirectChainSize", redirect_chain_size); |
| 943 | 979 |
| 944 // Once it is committed, we no longer need to track several pieces of state on | 980 // Once it is committed, we no longer need to track several pieces of state on |
| 945 // the entry. | 981 // the entry. |
| (...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2193 DCHECK(pending_entry_index_ == -1 || | 2229 DCHECK(pending_entry_index_ == -1 || |
| 2194 pending_entry_ == GetEntryAtIndex(pending_entry_index_)); | 2230 pending_entry_ == GetEntryAtIndex(pending_entry_index_)); |
| 2195 } | 2231 } |
| 2196 | 2232 |
| 2197 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 2233 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
| 2198 const base::Callback<base::Time()>& get_timestamp_callback) { | 2234 const base::Callback<base::Time()>& get_timestamp_callback) { |
| 2199 get_timestamp_callback_ = get_timestamp_callback; | 2235 get_timestamp_callback_ = get_timestamp_callback; |
| 2200 } | 2236 } |
| 2201 | 2237 |
| 2202 } // namespace content | 2238 } // namespace content |
| OLD | NEW |