| 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 <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "content/public/browser/web_contents_delegate.h" | 46 #include "content/public/browser/web_contents_delegate.h" |
| 47 #include "content/public/common/bindings_policy.h" | 47 #include "content/public/common/bindings_policy.h" |
| 48 #include "net/base/escape.h" | 48 #include "net/base/escape.h" |
| 49 #include "net/url_request/url_request_context_getter.h" | 49 #include "net/url_request/url_request_context_getter.h" |
| 50 #include "ui/base/page_transition_types.h" | 50 #include "ui/base/page_transition_types.h" |
| 51 | 51 |
| 52 using blink::WebDragOperation; | 52 using blink::WebDragOperation; |
| 53 using blink::WebDragOperationsMask; | 53 using blink::WebDragOperationsMask; |
| 54 | 54 |
| 55 namespace content { | 55 namespace content { |
| 56 namespace { | |
| 57 | |
| 58 void ResourceRequestHelper(ResourceDispatcherHostImpl* rdh, | |
| 59 int process_id, | |
| 60 int render_view_host_id, | |
| 61 ResourceRequestAction action) { | |
| 62 switch (action) { | |
| 63 case BLOCK: | |
| 64 rdh->BlockRequestsForRoute(process_id, render_view_host_id); | |
| 65 break; | |
| 66 case RESUME: | |
| 67 rdh->ResumeBlockedRequestsForRoute(process_id, render_view_host_id); | |
| 68 break; | |
| 69 case CANCEL: | |
| 70 rdh->CancelBlockedRequestsForRoute(process_id, render_view_host_id); | |
| 71 break; | |
| 72 default: | |
| 73 NOTREACHED(); | |
| 74 } | |
| 75 } | |
| 76 | |
| 77 } // namespace | |
| 78 | 56 |
| 79 class InterstitialPageImpl::InterstitialPageRVHDelegateView | 57 class InterstitialPageImpl::InterstitialPageRVHDelegateView |
| 80 : public RenderViewHostDelegateView { | 58 : public RenderViewHostDelegateView { |
| 81 public: | 59 public: |
| 82 explicit InterstitialPageRVHDelegateView(InterstitialPageImpl* page); | 60 explicit InterstitialPageRVHDelegateView(InterstitialPageImpl* page); |
| 83 | 61 |
| 84 // RenderViewHostDelegateView implementation: | 62 // RenderViewHostDelegateView implementation: |
| 85 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 63 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
| 86 void ShowPopupMenu(RenderFrameHost* render_frame_host, | 64 void ShowPopupMenu(RenderFrameHost* render_frame_host, |
| 87 const gfx::Rect& bounds, | 65 const gfx::Rect& bounds, |
| (...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 | 810 |
| 833 if (action == CANCEL || action == RESUME) { | 811 if (action == CANCEL || action == RESUME) { |
| 834 if (resource_dispatcher_host_notified_) | 812 if (resource_dispatcher_host_notified_) |
| 835 return; | 813 return; |
| 836 resource_dispatcher_host_notified_ = true; | 814 resource_dispatcher_host_notified_ = true; |
| 837 } | 815 } |
| 838 | 816 |
| 839 // The tab might not have a render_view_host if it was closed (in which case, | 817 // The tab might not have a render_view_host if it was closed (in which case, |
| 840 // we have taken care of the blocked requests when processing | 818 // we have taken care of the blocked requests when processing |
| 841 // NOTIFY_RENDER_WIDGET_HOST_DESTROYED. | 819 // NOTIFY_RENDER_WIDGET_HOST_DESTROYED. |
| 842 // Also we need to test there is a ResourceDispatcherHostImpl, as when unit- | 820 // ResourceDispatcherHostImpl tests its own existence, as unit-tests don't |
| 843 // tests we don't have one. | 821 // have one. |
| 844 RenderViewHostImpl* rvh = RenderViewHostImpl::FromID(original_child_id_, | 822 RenderViewHostImpl* rvh = RenderViewHostImpl::FromID(original_child_id_, |
| 845 original_rvh_id_); | 823 original_rvh_id_); |
| 846 if (!rvh || !ResourceDispatcherHostImpl::Get()) | 824 if (!rvh) |
| 847 return; | 825 return; |
| 848 | 826 |
| 849 BrowserThread::PostTask( | 827 base::Callback<void(ResourceDispatcherHostImpl*, const GlobalFrameRoutingId&)> |
| 850 BrowserThread::IO, | 828 frame_callback = base::Bind([](ResourceRequestAction action) { |
| 851 FROM_HERE, | 829 switch (action) { |
| 852 base::Bind( | 830 case BLOCK: |
| 853 &ResourceRequestHelper, | 831 return &ResourceDispatcherHostImpl::BlockRequestsForRoute; |
| 854 ResourceDispatcherHostImpl::Get(), | 832 case RESUME: |
| 855 original_child_id_, | 833 return &ResourceDispatcherHostImpl::ResumeBlockedRequestsForRoute; |
| 856 original_rvh_id_, | 834 default: |
| 857 action)); | 835 DCHECK_EQ(action, CANCEL); |
| 836 return &ResourceDispatcherHostImpl::CancelBlockedRequestsForRoute; |
| 837 } |
| 838 }(action)); |
| 839 ResourceDispatcherHostImpl::NotifyForEachFrame( |
| 840 rvh->GetDelegate()->GetFrameTree(), frame_callback); |
| 858 } | 841 } |
| 859 | 842 |
| 860 void InterstitialPageImpl::OnDomOperationResponse( | 843 void InterstitialPageImpl::OnDomOperationResponse( |
| 861 const std::string& json_string) { | 844 const std::string& json_string) { |
| 862 std::string json = json_string; | 845 std::string json = json_string; |
| 863 // Needed by test code. | 846 // Needed by test code. |
| 864 NotificationService::current()->Notify(NOTIFICATION_DOM_OPERATION_RESPONSE, | 847 NotificationService::current()->Notify(NOTIFICATION_DOM_OPERATION_RESPONSE, |
| 865 Source<WebContents>(web_contents()), | 848 Source<WebContents>(web_contents()), |
| 866 Details<std::string>(&json)); | 849 Details<std::string>(&json)); |
| 867 | 850 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 void InterstitialPageImpl::UnderlyingContentObserver::NavigationEntryCommitted( | 924 void InterstitialPageImpl::UnderlyingContentObserver::NavigationEntryCommitted( |
| 942 const LoadCommittedDetails& load_details) { | 925 const LoadCommittedDetails& load_details) { |
| 943 interstitial_->OnNavigatingAwayOrTabClosing(); | 926 interstitial_->OnNavigatingAwayOrTabClosing(); |
| 944 } | 927 } |
| 945 | 928 |
| 946 void InterstitialPageImpl::UnderlyingContentObserver::WebContentsDestroyed() { | 929 void InterstitialPageImpl::UnderlyingContentObserver::WebContentsDestroyed() { |
| 947 interstitial_->OnNavigatingAwayOrTabClosing(); | 930 interstitial_->OnNavigatingAwayOrTabClosing(); |
| 948 } | 931 } |
| 949 | 932 |
| 950 } // namespace content | 933 } // namespace content |
| OLD | NEW |