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 #include "content/browser/frame_host/navigator_impl.h" | 5 #include "content/browser/frame_host/navigator_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 if (reload_type == ReloadType::ORIGINAL_REQUEST_URL && | 295 if (reload_type == ReloadType::ORIGINAL_REQUEST_URL && |
296 entry.GetOriginalRequestURL().is_valid() && !entry.GetHasPostData()) { | 296 entry.GetOriginalRequestURL().is_valid() && !entry.GetHasPostData()) { |
297 // We may have been redirected when navigating to the current URL. | 297 // We may have been redirected when navigating to the current URL. |
298 // Use the URL the user originally intended to visit, if it's valid and if a | 298 // Use the URL the user originally intended to visit, if it's valid and if a |
299 // POST wasn't involved; the latter case avoids issues with sending data to | 299 // POST wasn't involved; the latter case avoids issues with sending data to |
300 // the wrong page. | 300 // the wrong page. |
301 dest_url = entry.GetOriginalRequestURL(); | 301 dest_url = entry.GetOriginalRequestURL(); |
302 dest_referrer = Referrer(); | 302 dest_referrer = Referrer(); |
303 } | 303 } |
304 | 304 |
305 // Don't attempt to navigate if the virtual URL is non-empty and invalid. | |
306 if (frame_tree_node->IsMainFrame()) { | |
307 GURL virtual_url = entry.GetVirtualURL(); | |
Charlie Reis
2016/10/26 23:07:09
const ref?
nasko
2016/10/26 23:37:47
Done.
| |
308 if (!virtual_url.is_valid() && !virtual_url.is_empty()) { | |
309 LOG(WARNING) << "Refusing to load for invalid virtual URL: " | |
310 << virtual_url.possibly_invalid_spec(); | |
311 return false; | |
312 } | |
313 } | |
314 | |
305 // Don't attempt to navigate to non-empty invalid URLs. | 315 // Don't attempt to navigate to non-empty invalid URLs. |
306 if (!dest_url.is_valid() && !dest_url.is_empty()) { | 316 if (!dest_url.is_valid() && !dest_url.is_empty()) { |
307 LOG(WARNING) << "Refusing to load invalid URL: " | 317 LOG(WARNING) << "Refusing to load invalid URL: " |
308 << dest_url.possibly_invalid_spec(); | 318 << dest_url.possibly_invalid_spec(); |
309 return false; | 319 return false; |
310 } | 320 } |
311 | 321 |
312 // The renderer will reject IPC messages with URLs longer than | 322 // The renderer will reject IPC messages with URLs longer than |
313 // this limit, so don't attempt to navigate with a longer URL. | 323 // this limit, so don't attempt to navigate with a longer URL. |
314 if (dest_url.spec().size() > url::kMaxURLChars) { | 324 if (dest_url.spec().size() > url::kMaxURLChars) { |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1223 // in deleting it, which leads to inconsistent state. | 1233 // in deleting it, which leads to inconsistent state. |
1224 bool has_transient_entry = !!controller_->GetTransientEntry(); | 1234 bool has_transient_entry = !!controller_->GetTransientEntry(); |
1225 | 1235 |
1226 if (!has_browser_initiated_pending_entry && !has_transient_entry) { | 1236 if (!has_browser_initiated_pending_entry && !has_transient_entry) { |
1227 std::unique_ptr<NavigationEntryImpl> entry = | 1237 std::unique_ptr<NavigationEntryImpl> entry = |
1228 NavigationEntryImpl::FromNavigationEntry( | 1238 NavigationEntryImpl::FromNavigationEntry( |
1229 controller_->CreateNavigationEntry( | 1239 controller_->CreateNavigationEntry( |
1230 url, content::Referrer(), ui::PAGE_TRANSITION_LINK, | 1240 url, content::Referrer(), ui::PAGE_TRANSITION_LINK, |
1231 true /* is_renderer_initiated */, std::string(), | 1241 true /* is_renderer_initiated */, std::string(), |
1232 controller_->GetBrowserContext())); | 1242 controller_->GetBrowserContext())); |
1243 | |
1244 // If the creation of NavigationEntry failed, just return early and | |
1245 // don't set a pending entry. | |
1246 if (!entry.get()) | |
Charlie Reis
2016/10/26 23:07:09
Is this stale? I don't see any changes to CreateN
nasko
2016/10/26 23:37:47
Oops, indeed. This is leftover from my previous tr
| |
1247 return; | |
1248 | |
1233 entry->set_site_instance(site_instance); | 1249 entry->set_site_instance(site_instance); |
1234 // TODO(creis): If there's a pending entry already, find a safe way to | 1250 // TODO(creis): If there's a pending entry already, find a safe way to |
1235 // update it instead of replacing it and copying over things like this. | 1251 // update it instead of replacing it and copying over things like this. |
1236 // That will allow us to skip the NavigationHandle update below as well. | 1252 // That will allow us to skip the NavigationHandle update below as well. |
1237 if (pending_entry) { | 1253 if (pending_entry) { |
1238 entry->set_transferred_global_request_id( | 1254 entry->set_transferred_global_request_id( |
1239 pending_entry->transferred_global_request_id()); | 1255 pending_entry->transferred_global_request_id()); |
1240 entry->set_should_replace_entry(pending_entry->should_replace_entry()); | 1256 entry->set_should_replace_entry(pending_entry->should_replace_entry()); |
1241 entry->SetRedirectChain(pending_entry->GetRedirectChain()); | 1257 entry->SetRedirectChain(pending_entry->GetRedirectChain()); |
1242 } | 1258 } |
1243 | 1259 |
1244 // If there's a current NavigationHandle, update its pending NavEntry ID. | 1260 // If there's a current NavigationHandle, update its pending NavEntry ID. |
1245 // This is necessary for transfer navigations. The handle may be null in | 1261 // This is necessary for transfer navigations. The handle may be null in |
1246 // PlzNavigate. | 1262 // PlzNavigate. |
1247 if (navigation_handle) | 1263 if (navigation_handle) |
1248 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); | 1264 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); |
1249 | 1265 |
1250 controller_->SetPendingEntry(std::move(entry)); | 1266 controller_->SetPendingEntry(std::move(entry)); |
1251 if (delegate_) | 1267 if (delegate_) |
1252 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 1268 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
1253 } | 1269 } |
1254 } | 1270 } |
1255 | 1271 |
1256 } // namespace content | 1272 } // namespace content |
OLD | NEW |