| 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/interstitial_page_impl.h" | 5 #include "content/browser/frame_host/interstitial_page_impl.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
| 16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
| 17 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" | 17 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" |
| 18 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 18 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
| 19 #include "content/browser/frame_host/interstitial_page_navigator_impl.h" | 19 #include "content/browser/frame_host/interstitial_page_navigator_impl.h" |
| 20 #include "content/browser/frame_host/navigation_controller_impl.h" | 20 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 21 #include "content/browser/frame_host/navigation_entry_impl.h" | 21 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 22 #include "content/browser/loader/loader_io_thread_notifier.h" |
| 22 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 23 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 23 #include "content/browser/renderer_host/render_process_host_impl.h" | 24 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 24 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 25 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
| 25 #include "content/browser/renderer_host/render_view_host_factory.h" | 26 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 26 #include "content/browser/renderer_host/render_view_host_impl.h" | 27 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 27 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 28 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 28 #include "content/browser/site_instance_impl.h" | 29 #include "content/browser/site_instance_impl.h" |
| 29 #include "content/browser/web_contents/web_contents_impl.h" | 30 #include "content/browser/web_contents/web_contents_impl.h" |
| 30 #include "content/browser/web_contents/web_contents_view.h" | 31 #include "content/browser/web_contents/web_contents_view.h" |
| 31 #include "content/common/frame_messages.h" | 32 #include "content/common/frame_messages.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 45 #include "net/base/escape.h" | 46 #include "net/base/escape.h" |
| 46 #include "net/url_request/url_request_context_getter.h" | 47 #include "net/url_request/url_request_context_getter.h" |
| 47 #include "ui/base/page_transition_types.h" | 48 #include "ui/base/page_transition_types.h" |
| 48 | 49 |
| 49 using blink::WebDragOperation; | 50 using blink::WebDragOperation; |
| 50 using blink::WebDragOperationsMask; | 51 using blink::WebDragOperationsMask; |
| 51 | 52 |
| 52 namespace content { | 53 namespace content { |
| 53 namespace { | 54 namespace { |
| 54 | 55 |
| 55 void ResourceRequestHelper(ResourceDispatcherHostImpl* rdh, | 56 void ResourceRequestHelper( |
| 56 int process_id, | 57 ResourceRequestAction action, |
| 57 int render_view_host_id, | 58 ResourceDispatcherHostImpl* rdh, |
| 58 ResourceRequestAction action) { | 59 int child_id, |
| 60 int route_id) { |
| 59 switch (action) { | 61 switch (action) { |
| 60 case BLOCK: | 62 case BLOCK: |
| 61 rdh->BlockRequestsForRoute(process_id, render_view_host_id); | 63 rdh->BlockRequestsForFrame(child_id, route_id); |
| 62 break; | 64 break; |
| 63 case RESUME: | 65 case RESUME: |
| 64 rdh->ResumeBlockedRequestsForRoute(process_id, render_view_host_id); | 66 rdh->ResumeBlockedRequestsForFrame(child_id, route_id); |
| 65 break; | 67 break; |
| 66 case CANCEL: | 68 case CANCEL: |
| 67 rdh->CancelBlockedRequestsForRoute(process_id, render_view_host_id); | 69 rdh->CancelBlockedRequestsForFrame(child_id, route_id); |
| 68 break; | 70 break; |
| 69 default: | 71 default: |
| 70 NOTREACHED(); | 72 NOTREACHED(); |
| 71 } | 73 } |
| 72 } | 74 } |
| 73 | 75 |
| 74 } // namespace | 76 } // namespace |
| 75 | 77 |
| 76 class InterstitialPageImpl::InterstitialPageRVHDelegateView | 78 class InterstitialPageImpl::InterstitialPageRVHDelegateView |
| 77 : public RenderViewHostDelegateView { | 79 : public RenderViewHostDelegateView { |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 | 831 |
| 830 if (action == CANCEL || action == RESUME) { | 832 if (action == CANCEL || action == RESUME) { |
| 831 if (resource_dispatcher_host_notified_) | 833 if (resource_dispatcher_host_notified_) |
| 832 return; | 834 return; |
| 833 resource_dispatcher_host_notified_ = true; | 835 resource_dispatcher_host_notified_ = true; |
| 834 } | 836 } |
| 835 | 837 |
| 836 // The tab might not have a render_view_host if it was closed (in which case, | 838 // The tab might not have a render_view_host if it was closed (in which case, |
| 837 // we have taken care of the blocked requests when processing | 839 // we have taken care of the blocked requests when processing |
| 838 // NOTIFY_RENDER_WIDGET_HOST_DESTROYED. | 840 // NOTIFY_RENDER_WIDGET_HOST_DESTROYED. |
| 839 // Also we need to test there is a ResourceDispatcherHostImpl, as when unit- | 841 // LoaderIOThreadNotifier tests if there is a ResourceDispatcherHostImpl, as |
| 840 // tests we don't have one. | 842 // unit-tests don't have one. |
| 841 RenderViewHostImpl* rvh = RenderViewHostImpl::FromID(original_child_id_, | 843 RenderViewHostImpl* rvh = RenderViewHostImpl::FromID(original_child_id_, |
| 842 original_rvh_id_); | 844 original_rvh_id_); |
| 843 if (!rvh || !ResourceDispatcherHostImpl::Get()) | 845 if (!rvh) |
| 844 return; | 846 return; |
| 845 | 847 |
| 846 BrowserThread::PostTask( | 848 LoaderIOThreadNotifer::NotifyForEachFrameOnIO( |
| 847 BrowserThread::IO, | 849 rvh->GetDelegate()->GetFrameTree(), |
| 848 FROM_HERE, | 850 base::Bind(&ResourceRequestHelper, action)); |
| 849 base::Bind( | |
| 850 &ResourceRequestHelper, | |
| 851 ResourceDispatcherHostImpl::Get(), | |
| 852 original_child_id_, | |
| 853 original_rvh_id_, | |
| 854 action)); | |
| 855 } | 851 } |
| 856 | 852 |
| 857 void InterstitialPageImpl::OnDomOperationResponse( | 853 void InterstitialPageImpl::OnDomOperationResponse( |
| 858 const std::string& json_string) { | 854 const std::string& json_string) { |
| 859 std::string json = json_string; | 855 std::string json = json_string; |
| 860 // Needed by test code. | 856 // Needed by test code. |
| 861 NotificationService::current()->Notify(NOTIFICATION_DOM_OPERATION_RESPONSE, | 857 NotificationService::current()->Notify(NOTIFICATION_DOM_OPERATION_RESPONSE, |
| 862 Source<WebContents>(web_contents()), | 858 Source<WebContents>(web_contents()), |
| 863 Details<std::string>(&json)); | 859 Details<std::string>(&json)); |
| 864 | 860 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 void InterstitialPageImpl::UnderlyingContentObserver::NavigationEntryCommitted( | 934 void InterstitialPageImpl::UnderlyingContentObserver::NavigationEntryCommitted( |
| 939 const LoadCommittedDetails& load_details) { | 935 const LoadCommittedDetails& load_details) { |
| 940 interstitial_->OnNavigatingAwayOrTabClosing(); | 936 interstitial_->OnNavigatingAwayOrTabClosing(); |
| 941 } | 937 } |
| 942 | 938 |
| 943 void InterstitialPageImpl::UnderlyingContentObserver::WebContentsDestroyed() { | 939 void InterstitialPageImpl::UnderlyingContentObserver::WebContentsDestroyed() { |
| 944 interstitial_->OnNavigatingAwayOrTabClosing(); | 940 interstitial_->OnNavigatingAwayOrTabClosing(); |
| 945 } | 941 } |
| 946 | 942 |
| 947 } // namespace content | 943 } // namespace content |
| OLD | NEW |