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" |
11 #include "content/browser/appcache/appcache_service_impl.h" | 11 #include "content/browser/appcache/appcache_service_impl.h" |
12 #include "content/browser/browsing_data/clear_site_data_throttle.h" | 12 #include "content/browser/browsing_data/clear_site_data_throttle.h" |
13 #include "content/browser/child_process_security_policy_impl.h" | 13 #include "content/browser/child_process_security_policy_impl.h" |
14 #include "content/browser/devtools/render_frame_devtools_agent_host.h" | 14 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
15 #include "content/browser/frame_host/ancestor_throttle.h" | 15 #include "content/browser/frame_host/ancestor_throttle.h" |
| 16 #include "content/browser/frame_host/data_url_navigation_throttle.h" |
16 #include "content/browser/frame_host/debug_urls.h" | 17 #include "content/browser/frame_host/debug_urls.h" |
17 #include "content/browser/frame_host/form_submission_throttle.h" | 18 #include "content/browser/frame_host/form_submission_throttle.h" |
18 #include "content/browser/frame_host/frame_tree_node.h" | 19 #include "content/browser/frame_host/frame_tree_node.h" |
19 #include "content/browser/frame_host/mixed_content_navigation_throttle.h" | 20 #include "content/browser/frame_host/mixed_content_navigation_throttle.h" |
20 #include "content/browser/frame_host/navigation_controller_impl.h" | 21 #include "content/browser/frame_host/navigation_controller_impl.h" |
21 #include "content/browser/frame_host/navigation_entry_impl.h" | 22 #include "content/browser/frame_host/navigation_entry_impl.h" |
22 #include "content/browser/frame_host/navigator.h" | 23 #include "content/browser/frame_host/navigator.h" |
23 #include "content/browser/frame_host/navigator_delegate.h" | 24 #include "content/browser/frame_host/navigator_delegate.h" |
24 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 25 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
25 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 26 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 subframe_entry_committed_ = navigation_entry_committed; | 675 subframe_entry_committed_ = navigation_entry_committed; |
675 | 676 |
676 // If an error page reloads, net_error_code might be 200 but we still want to | 677 // If an error page reloads, net_error_code might be 200 but we still want to |
677 // count it as an error page. | 678 // count it as an error page. |
678 if (params.base_url.spec() == kUnreachableWebDataURL || | 679 if (params.base_url.spec() == kUnreachableWebDataURL || |
679 net_error_code_ != net::OK) { | 680 net_error_code_ != net::OK) { |
680 state_ = DID_COMMIT_ERROR_PAGE; | 681 state_ = DID_COMMIT_ERROR_PAGE; |
681 } else { | 682 } else { |
682 state_ = DID_COMMIT; | 683 state_ = DID_COMMIT; |
683 } | 684 } |
684 | |
685 if (url_.SchemeIs(url::kDataScheme) && IsInMainFrame() && | |
686 IsRendererInitiated()) { | |
687 GetRenderFrameHost()->AddMessageToConsole( | |
688 CONSOLE_MESSAGE_LEVEL_WARNING, | |
689 "Upcoming versions will block content-initiated top frame navigations " | |
690 "to data: URLs. For more information, see https://goo.gl/BaZAea."); | |
691 } | |
692 } | 685 } |
693 | 686 |
694 void NavigationHandleImpl::Transfer() { | 687 void NavigationHandleImpl::Transfer() { |
695 DCHECK(!IsBrowserSideNavigationEnabled()); | 688 DCHECK(!IsBrowserSideNavigationEnabled()); |
696 // This is an actual transfer. Inform the NavigationResourceThrottle. This | 689 // This is an actual transfer. Inform the NavigationResourceThrottle. This |
697 // will allow to mark the URLRequest as transferring. When it is marked as | 690 // will allow to mark the URLRequest as transferring. When it is marked as |
698 // transferring, the URLRequest can no longer be cancelled by its original | 691 // transferring, the URLRequest can no longer be cancelled by its original |
699 // RenderFrame. Instead it will persist until being picked up by the transfer | 692 // RenderFrame. Instead it will persist until being picked up by the transfer |
700 // RenderFrame, even if the original RenderFrame is destroyed. | 693 // RenderFrame, even if the original RenderFrame is destroyed. |
701 // Note: |transfer_callback_| can be null in unit tests. | 694 // Note: |transfer_callback_| can be null in unit tests. |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 // Register the navigation throttles. The vector returned by | 916 // Register the navigation throttles. The vector returned by |
924 // CreateThrottlesForNavigation is not assigned to throttles_ directly because | 917 // CreateThrottlesForNavigation is not assigned to throttles_ directly because |
925 // it would overwrite any throttles previously added with | 918 // it would overwrite any throttles previously added with |
926 // RegisterThrottleForTesting. | 919 // RegisterThrottleForTesting. |
927 // TODO(carlosk, arthursonzogni): should simplify this to either use | 920 // TODO(carlosk, arthursonzogni): should simplify this to either use |
928 // |throttles_| directly (except for the case described above) or | 921 // |throttles_| directly (except for the case described above) or |
929 // |throttles_to_register| for registering all throttles. | 922 // |throttles_to_register| for registering all throttles. |
930 std::vector<std::unique_ptr<NavigationThrottle>> throttles_to_register = | 923 std::vector<std::unique_ptr<NavigationThrottle>> throttles_to_register = |
931 GetDelegate()->CreateThrottlesForNavigation(this); | 924 GetDelegate()->CreateThrottlesForNavigation(this); |
932 | 925 |
| 926 // Check for renderer-inititated main frame navigations to data URLs. This is |
| 927 // done first as it may block the main frame navigation altogether. |
| 928 std::unique_ptr<NavigationThrottle> data_url_navigation_throttle = |
| 929 DataUrlNavigationThrottle::CreateThrottleForNavigation(this); |
| 930 if (data_url_navigation_throttle) |
| 931 throttles_to_register.push_back(std::move(data_url_navigation_throttle)); |
| 932 |
933 std::unique_ptr<content::NavigationThrottle> ancestor_throttle = | 933 std::unique_ptr<content::NavigationThrottle> ancestor_throttle = |
934 content::AncestorThrottle::MaybeCreateThrottleFor(this); | 934 content::AncestorThrottle::MaybeCreateThrottleFor(this); |
935 if (ancestor_throttle) | 935 if (ancestor_throttle) |
936 throttles_.push_back(std::move(ancestor_throttle)); | 936 throttles_.push_back(std::move(ancestor_throttle)); |
937 | 937 |
938 std::unique_ptr<content::NavigationThrottle> form_submission_throttle = | 938 std::unique_ptr<content::NavigationThrottle> form_submission_throttle = |
939 content::FormSubmissionThrottle::MaybeCreateThrottleFor(this); | 939 content::FormSubmissionThrottle::MaybeCreateThrottleFor(this); |
940 if (form_submission_throttle) | 940 if (form_submission_throttle) |
941 throttles_.push_back(std::move(form_submission_throttle)); | 941 throttles_.push_back(std::move(form_submission_throttle)); |
942 | 942 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 if (node->current_url().EqualsIgnoringRef(url_)) { | 989 if (node->current_url().EqualsIgnoringRef(url_)) { |
990 if (found_self_reference) | 990 if (found_self_reference) |
991 return true; | 991 return true; |
992 found_self_reference = true; | 992 found_self_reference = true; |
993 } | 993 } |
994 } | 994 } |
995 return false; | 995 return false; |
996 } | 996 } |
997 | 997 |
998 } // namespace content | 998 } // namespace content |
OLD | NEW |