| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/navigation_handle_impl.h" | 5 #include "content/browser/frame_host/navigation_handle_impl.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "content/browser/appcache/appcache_navigation_handle.h" | 10 #include "content/browser/appcache/appcache_navigation_handle.h" |
| (...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 // about: URLs should be exempted since they are reserved for other purposes | 968 // about: URLs should be exempted since they are reserved for other purposes |
| 969 // and cannot be the source of infinite recursion. See | 969 // and cannot be the source of infinite recursion. See |
| 970 // https://crbug.com/341858 . | 970 // https://crbug.com/341858 . |
| 971 if (url_.SchemeIs("about")) | 971 if (url_.SchemeIs("about")) |
| 972 return false; | 972 return false; |
| 973 | 973 |
| 974 // Browser-triggered navigations should be exempted. | 974 // Browser-triggered navigations should be exempted. |
| 975 if (!is_renderer_initiated_) | 975 if (!is_renderer_initiated_) |
| 976 return false; | 976 return false; |
| 977 | 977 |
| 978 // Only enforce this for initial navigations in frames. This handles |
| 979 // the common cases of developers shooting themselves in the foot, but allows |
| 980 // frames to deliberately navigate themselves to a self-referential URL |
| 981 // after being created. For example, some sites construct frame hierarchies |
| 982 // with frames that navigate to the same URL via POSTs. See |
| 983 // https://crbug.com/710008. |
| 984 if (frame_tree_node_->has_committed_real_load()) |
| 985 return false; |
| 986 |
| 978 // We allow one level of self-reference because some sites depend on that, | 987 // We allow one level of self-reference because some sites depend on that, |
| 979 // but we don't allow more than one. | 988 // but we don't allow more than one. |
| 980 bool found_self_reference = false; | 989 bool found_self_reference = false; |
| 981 for (const FrameTreeNode* node = frame_tree_node_->parent(); node; | 990 for (const FrameTreeNode* node = frame_tree_node_->parent(); node; |
| 982 node = node->parent()) { | 991 node = node->parent()) { |
| 983 if (node->current_url().EqualsIgnoringRef(url_)) { | 992 if (node->current_url().EqualsIgnoringRef(url_)) { |
| 984 if (found_self_reference) | 993 if (found_self_reference) |
| 985 return true; | 994 return true; |
| 986 found_self_reference = true; | 995 found_self_reference = true; |
| 987 } | 996 } |
| 988 } | 997 } |
| 989 return false; | 998 return false; |
| 990 } | 999 } |
| 991 | 1000 |
| 992 } // namespace content | 1001 } // namespace content |
| OLD | NEW |