| 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 // Returns true if the error code indicates an error condition that is not |
| 166 // recoverable or navigation is blocked. In such cases, session history |
| 167 // navigations to the same NavigationEntry should not attempt to load the |
| 168 // original URL. |
| 169 // TODO(nasko): Find a better way to distinguish blocked vs failed navigations, |
| 170 // as this is a very hacky way of accomplishing this. For now, a handful of |
| 171 // error codes are considered, which are more or less known to be cases of |
| 172 // blocked navigations. |
| 173 bool IsBlockedNavigation(net::Error error_code) { |
| 174 switch (error_code) { |
| 175 case net::ERR_BLOCKED_BY_CLIENT: |
| 176 case net::ERR_BLOCKED_BY_RESPONSE: |
| 177 case net::ERR_BLOCKED_BY_XSS_AUDITOR: |
| 178 case net::ERR_UNSAFE_REDIRECT: |
| 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 751 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 loading the blocked URL on back/forward navigations, |
| 958 // do not store it in the FrameNavigationEntry's URL or PageState. Instead, |
| 959 // make it visible to the user as the virtual URL. Store a safe URL |
| 960 // (about:blank) as the one to load if the entry is revisited. |
| 961 // TODO(nasko): Consider supporting similar behavior for subframe |
| 962 // navigations, including AUTO_SUBFRAME. |
| 963 if (!rfh->GetParent() && |
| 964 IsBlockedNavigation(navigation_handle->GetNetErrorCode())) { |
| 965 DCHECK(params.url_is_unreachable); |
| 966 active_entry->SetURL(GURL(url::kAboutBlankURL)); |
| 967 active_entry->SetVirtualURL(params.url); |
| 968 if (frame_entry) { |
| 969 frame_entry->SetPageState( |
| 970 PageState::CreateFromURL(active_entry->GetURL())); |
| 971 } |
| 972 } |
| 973 |
| 936 // Use histogram to track memory impact of redirect chain because it's now | 974 // Use histogram to track memory impact of redirect chain because it's now |
| 937 // not cleared for committed entries. | 975 // not cleared for committed entries. |
| 938 size_t redirect_chain_size = 0; | 976 size_t redirect_chain_size = 0; |
| 939 for (size_t i = 0; i < params.redirects.size(); ++i) { | 977 for (size_t i = 0; i < params.redirects.size(); ++i) { |
| 940 redirect_chain_size += params.redirects[i].spec().length(); | 978 redirect_chain_size += params.redirects[i].spec().length(); |
| 941 } | 979 } |
| 942 UMA_HISTOGRAM_COUNTS("Navigation.RedirectChainSize", redirect_chain_size); | 980 UMA_HISTOGRAM_COUNTS("Navigation.RedirectChainSize", redirect_chain_size); |
| 943 | 981 |
| 944 // Once it is committed, we no longer need to track several pieces of state on | 982 // Once it is committed, we no longer need to track several pieces of state on |
| 945 // the entry. | 983 // the entry. |
| (...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2193 DCHECK(pending_entry_index_ == -1 || | 2231 DCHECK(pending_entry_index_ == -1 || |
| 2194 pending_entry_ == GetEntryAtIndex(pending_entry_index_)); | 2232 pending_entry_ == GetEntryAtIndex(pending_entry_index_)); |
| 2195 } | 2233 } |
| 2196 | 2234 |
| 2197 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 2235 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
| 2198 const base::Callback<base::Time()>& get_timestamp_callback) { | 2236 const base::Callback<base::Time()>& get_timestamp_callback) { |
| 2199 get_timestamp_callback_ = get_timestamp_callback; | 2237 get_timestamp_callback_ = get_timestamp_callback; |
| 2200 } | 2238 } |
| 2201 | 2239 |
| 2202 } // namespace content | 2240 } // namespace content |
| OLD | NEW |