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) { | |
|
Charlie Reis
2017/05/24 16:42:11
Can we include a comment here with some context?
nasko
2017/05/24 20:46:29
Done.
| |
| 166 switch (error_code) { | |
| 167 case net::ERR_BLOCKED_BY_CLIENT: | |
| 168 case net::ERR_BLOCKED_BY_RESPONSE: | |
| 169 case net::ERR_BLOCKED_BY_XSS_AUDITOR: | |
| 170 case net::ERR_UNSAFE_REDIRECT: | |
| 171 return true; | |
| 172 default: | |
| 173 return false; | |
| 174 } | |
| 175 } | |
| 176 | |
| 165 } // namespace | 177 } // namespace |
| 166 | 178 |
| 167 // NavigationControllerImpl ---------------------------------------------------- | 179 // NavigationControllerImpl ---------------------------------------------------- |
| 168 | 180 |
| 169 const size_t kMaxEntryCountForTestingNotSet = static_cast<size_t>(-1); | 181 const size_t kMaxEntryCountForTestingNotSet = static_cast<size_t>(-1); |
| 170 | 182 |
| 171 // static | 183 // static |
| 172 size_t NavigationControllerImpl::max_entry_count_for_testing_ = | 184 size_t NavigationControllerImpl::max_entry_count_for_testing_ = |
| 173 kMaxEntryCountForTestingNotSet; | 185 kMaxEntryCountForTestingNotSet; |
| 174 | 186 |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 926 FrameNavigationEntry* frame_entry = | 938 FrameNavigationEntry* frame_entry = |
| 927 active_entry->GetFrameEntry(rfh->frame_tree_node()); | 939 active_entry->GetFrameEntry(rfh->frame_tree_node()); |
| 928 // Update the frame-specific PageState and RedirectChain | 940 // Update the frame-specific PageState and RedirectChain |
| 929 // We may not find a frame_entry in some cases; ignore the PageState if so. | 941 // 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. | 942 // TODO(creis): Remove the "if" once https://crbug.com/522193 is fixed. |
| 931 if (frame_entry) { | 943 if (frame_entry) { |
| 932 frame_entry->SetPageState(params.page_state); | 944 frame_entry->SetPageState(params.page_state); |
| 933 frame_entry->set_redirect_chain(params.redirects); | 945 frame_entry->set_redirect_chain(params.redirects); |
| 934 } | 946 } |
| 935 | 947 |
| 948 // When a navigation in the main frame is blocked, it will display an error | |
| 949 // page. To avoid loading the blocked URL on back/forward/reload navigations, | |
| 950 // do not store it in the FrameNavigationEntry's URL or PageState. Instead, | |
| 951 // make it visible to the user as the virtual URL. Store a safe URL | |
| 952 // (about:blank) as the one to load if the entry is revisited. | |
| 953 // TODO(nasko): Consider supporting similar behavior for subframe | |
| 954 // navigatios, including AUTO_SUBFRAME. | |
|
Charlie Reis
2017/05/24 16:42:11
nit: navigations
| |
| 955 if (!rfh->GetParent() && | |
| 956 IsBlockedNavigation(navigation_handle->GetNetErrorCode())) { | |
| 957 DCHECK(params.url_is_unreachable); | |
| 958 active_entry->SetURL(GURL(url::kAboutBlankURL)); | |
| 959 active_entry->SetVirtualURL(params.url); | |
| 960 if (frame_entry) { | |
| 961 frame_entry->SetPageState( | |
| 962 PageState::CreateFromURL(active_entry->GetURL())); | |
| 963 } | |
| 964 } | |
| 965 | |
| 936 // Use histogram to track memory impact of redirect chain because it's now | 966 // Use histogram to track memory impact of redirect chain because it's now |
| 937 // not cleared for committed entries. | 967 // not cleared for committed entries. |
| 938 size_t redirect_chain_size = 0; | 968 size_t redirect_chain_size = 0; |
| 939 for (size_t i = 0; i < params.redirects.size(); ++i) { | 969 for (size_t i = 0; i < params.redirects.size(); ++i) { |
| 940 redirect_chain_size += params.redirects[i].spec().length(); | 970 redirect_chain_size += params.redirects[i].spec().length(); |
| 941 } | 971 } |
| 942 UMA_HISTOGRAM_COUNTS("Navigation.RedirectChainSize", redirect_chain_size); | 972 UMA_HISTOGRAM_COUNTS("Navigation.RedirectChainSize", redirect_chain_size); |
| 943 | 973 |
| 944 // Once it is committed, we no longer need to track several pieces of state on | 974 // Once it is committed, we no longer need to track several pieces of state on |
| 945 // the entry. | 975 // the entry. |
| (...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2193 DCHECK(pending_entry_index_ == -1 || | 2223 DCHECK(pending_entry_index_ == -1 || |
| 2194 pending_entry_ == GetEntryAtIndex(pending_entry_index_)); | 2224 pending_entry_ == GetEntryAtIndex(pending_entry_index_)); |
| 2195 } | 2225 } |
| 2196 | 2226 |
| 2197 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 2227 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
| 2198 const base::Callback<base::Time()>& get_timestamp_callback) { | 2228 const base::Callback<base::Time()>& get_timestamp_callback) { |
| 2199 get_timestamp_callback_ = get_timestamp_callback; | 2229 get_timestamp_callback_ = get_timestamp_callback; |
| 2200 } | 2230 } |
| 2201 | 2231 |
| 2202 } // namespace content | 2232 } // namespace content |
| OLD | NEW |