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" |
(...skipping 19 matching lines...) Expand all Loading... | |
30 #include "content/port/browser/web_contents_view_port.h" | 30 #include "content/port/browser/web_contents_view_port.h" |
31 #include "content/public/browser/browser_context.h" | 31 #include "content/public/browser/browser_context.h" |
32 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
33 #include "content/public/browser/content_browser_client.h" | 33 #include "content/public/browser/content_browser_client.h" |
34 #include "content/public/browser/dom_operation_notification_details.h" | 34 #include "content/public/browser/dom_operation_notification_details.h" |
35 #include "content/public/browser/interstitial_page_delegate.h" | 35 #include "content/public/browser/interstitial_page_delegate.h" |
36 #include "content/public/browser/invalidate_type.h" | 36 #include "content/public/browser/invalidate_type.h" |
37 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
38 #include "content/public/browser/notification_source.h" | 38 #include "content/public/browser/notification_source.h" |
39 #include "content/public/browser/storage_partition.h" | 39 #include "content/public/browser/storage_partition.h" |
40 #include "content/public/browser/user_metrics.h" | |
40 #include "content/public/browser/web_contents_delegate.h" | 41 #include "content/public/browser/web_contents_delegate.h" |
41 #include "content/public/common/bindings_policy.h" | 42 #include "content/public/common/bindings_policy.h" |
42 #include "content/public/common/page_transition_types.h" | 43 #include "content/public/common/page_transition_types.h" |
43 #include "net/base/escape.h" | 44 #include "net/base/escape.h" |
44 #include "net/url_request/url_request_context_getter.h" | 45 #include "net/url_request/url_request_context_getter.h" |
45 | 46 |
46 using blink::WebDragOperation; | 47 using blink::WebDragOperation; |
47 using blink::WebDragOperationsMask; | 48 using blink::WebDragOperationsMask; |
48 | 49 |
49 namespace content { | 50 namespace content { |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 render_view_host_ = static_cast<RenderViewHostImpl*>(CreateRenderViewHost()); | 243 render_view_host_ = static_cast<RenderViewHostImpl*>(CreateRenderViewHost()); |
243 render_view_host_->AttachToFrameTree(); | 244 render_view_host_->AttachToFrameTree(); |
244 CreateWebContentsView(); | 245 CreateWebContentsView(); |
245 | 246 |
246 std::string data_url = "data:text/html;charset=utf-8," + | 247 std::string data_url = "data:text/html;charset=utf-8," + |
247 net::EscapePath(delegate_->GetHTMLContents()); | 248 net::EscapePath(delegate_->GetHTMLContents()); |
248 render_view_host_->NavigateToURL(GURL(data_url)); | 249 render_view_host_->NavigateToURL(GURL(data_url)); |
249 | 250 |
250 notification_registrar_.Add(this, NOTIFICATION_NAV_ENTRY_PENDING, | 251 notification_registrar_.Add(this, NOTIFICATION_NAV_ENTRY_PENDING, |
251 Source<NavigationController>(controller_)); | 252 Source<NavigationController>(controller_)); |
252 notification_registrar_.Add( | |
253 this, NOTIFICATION_DOM_OPERATION_RESPONSE, | |
254 Source<RenderViewHost>(render_view_host_)); | |
255 } | 253 } |
256 | 254 |
257 void InterstitialPageImpl::Hide() { | 255 void InterstitialPageImpl::Hide() { |
258 // We may have already been hidden, and are just waiting to be deleted. | 256 // We may have already been hidden, and are just waiting to be deleted. |
259 // We can't check for enabled() here, because some callers have already | 257 // We can't check for enabled() here, because some callers have already |
260 // called Disable. | 258 // called Disable. |
261 if (!render_view_host_) | 259 if (!render_view_host_) |
262 return; | 260 return; |
263 | 261 |
264 Disable(); | 262 Disable(); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 // closed); make sure we clear the blocked requests. | 337 // closed); make sure we clear the blocked requests. |
340 RenderViewHost* rvh = static_cast<RenderViewHost*>( | 338 RenderViewHost* rvh = static_cast<RenderViewHost*>( |
341 static_cast<RenderViewHostImpl*>( | 339 static_cast<RenderViewHostImpl*>( |
342 RenderWidgetHostImpl::From( | 340 RenderWidgetHostImpl::From( |
343 Source<RenderWidgetHost>(source).ptr()))); | 341 Source<RenderWidgetHost>(source).ptr()))); |
344 DCHECK(rvh->GetProcess()->GetID() == original_child_id_ && | 342 DCHECK(rvh->GetProcess()->GetID() == original_child_id_ && |
345 rvh->GetRoutingID() == original_rvh_id_); | 343 rvh->GetRoutingID() == original_rvh_id_); |
346 TakeActionOnResourceDispatcher(CANCEL); | 344 TakeActionOnResourceDispatcher(CANCEL); |
347 } | 345 } |
348 break; | 346 break; |
349 case NOTIFICATION_DOM_OPERATION_RESPONSE: | |
350 if (enabled()) { | |
351 Details<DomOperationNotificationDetails> dom_op_details( | |
352 details); | |
353 delegate_->CommandReceived(dom_op_details->json); | |
354 } | |
355 break; | |
356 default: | 347 default: |
357 NOTREACHED(); | 348 NOTREACHED(); |
358 } | 349 } |
359 } | 350 } |
360 | 351 |
361 void InterstitialPageImpl::NavigationEntryCommitted( | 352 void InterstitialPageImpl::NavigationEntryCommitted( |
362 const LoadCommittedDetails& load_details) { | 353 const LoadCommittedDetails& load_details) { |
363 OnNavigatingAwayOrTabClosing(); | 354 OnNavigatingAwayOrTabClosing(); |
364 } | 355 } |
365 | 356 |
366 void InterstitialPageImpl::WebContentsDestroyed(WebContents* web_contents) { | 357 void InterstitialPageImpl::WebContentsDestroyed(WebContents* web_contents) { |
367 OnNavigatingAwayOrTabClosing(); | 358 OnNavigatingAwayOrTabClosing(); |
368 } | 359 } |
369 | 360 |
361 bool InterstitialPageImpl::OnMessageReceived(RenderFrameHost* render_frame_host, | |
362 const IPC::Message& message) { | |
363 return OnMessageReceived(message); | |
364 } | |
365 | |
366 bool InterstitialPageImpl::OnMessageReceived(RenderViewHost* render_view_host, | |
Charlie Reis
2014/02/18 18:06:15
This isn't used for anything, is it? Maybe it's b
mkosiba (inactive)
2014/02/18 19:10:04
This is the only sane-looking way I found to work
Charlie Reis
2014/02/18 19:38:55
Ah, fun. I don't have a better idea for that, so
| |
367 const IPC::Message& message) { | |
368 return OnMessageReceived(message); | |
369 } | |
370 | |
371 bool InterstitialPageImpl::OnMessageReceived(const IPC::Message& message) { | |
372 | |
373 bool handled = true; | |
374 bool message_is_ok = true; | |
375 IPC_BEGIN_MESSAGE_MAP_EX(InterstitialPageImpl, message, message_is_ok) | |
376 IPC_MESSAGE_HANDLER(FrameHostMsg_DomOperationResponse, | |
377 OnDomOperationResponse) | |
378 IPC_MESSAGE_UNHANDLED(handled = false) | |
379 IPC_END_MESSAGE_MAP_EX() | |
380 | |
381 if (!message_is_ok) { | |
382 RecordAction(base::UserMetricsAction("BadMessageTerminate_RVD")); | |
383 web_contents()->GetRenderProcessHost()->ReceivedBadMessage(); | |
384 } | |
385 | |
386 return handled; | |
387 } | |
388 | |
370 void InterstitialPageImpl::RenderFrameCreated( | 389 void InterstitialPageImpl::RenderFrameCreated( |
371 RenderFrameHost* render_frame_host) { | 390 RenderFrameHost* render_frame_host) { |
372 // Note this is only for subframes in the interstitial, the notification for | 391 // Note this is only for subframes in the interstitial, the notification for |
373 // the main frame happens in RenderViewCreated. | 392 // the main frame happens in RenderViewCreated. |
374 controller_->delegate()->RenderFrameForInterstitialPageCreated( | 393 controller_->delegate()->RenderFrameForInterstitialPageCreated( |
375 render_frame_host); | 394 render_frame_host); |
376 } | 395 } |
377 | 396 |
378 RenderViewHostDelegateView* InterstitialPageImpl::GetDelegateView() { | 397 RenderViewHostDelegateView* InterstitialPageImpl::GetDelegateView() { |
379 return rvh_delegate_view_.get(); | 398 return rvh_delegate_view_.get(); |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
799 BrowserThread::IO, | 818 BrowserThread::IO, |
800 FROM_HERE, | 819 FROM_HERE, |
801 base::Bind( | 820 base::Bind( |
802 &ResourceRequestHelper, | 821 &ResourceRequestHelper, |
803 ResourceDispatcherHostImpl::Get(), | 822 ResourceDispatcherHostImpl::Get(), |
804 original_child_id_, | 823 original_child_id_, |
805 original_rvh_id_, | 824 original_rvh_id_, |
806 action)); | 825 action)); |
807 } | 826 } |
808 | 827 |
828 void InterstitialPageImpl::OnDomOperationResponse( | |
829 const std::string& json_string, | |
830 int automation_id) { | |
831 // Needed by test code. | |
832 DomOperationNotificationDetails details(json_string, automation_id); | |
833 NotificationService::current()->Notify( | |
834 NOTIFICATION_DOM_OPERATION_RESPONSE, | |
835 Source<WebContents>(web_contents()), | |
836 Details<DomOperationNotificationDetails>(&details)); | |
837 | |
838 if (!enabled()) | |
839 return; | |
840 delegate_->CommandReceived(details.json); | |
841 } | |
842 | |
843 | |
809 InterstitialPageImpl::InterstitialPageRVHDelegateView:: | 844 InterstitialPageImpl::InterstitialPageRVHDelegateView:: |
810 InterstitialPageRVHDelegateView(InterstitialPageImpl* page) | 845 InterstitialPageRVHDelegateView(InterstitialPageImpl* page) |
811 : interstitial_page_(page) { | 846 : interstitial_page_(page) { |
812 } | 847 } |
813 | 848 |
814 void InterstitialPageImpl::InterstitialPageRVHDelegateView::ShowPopupMenu( | 849 void InterstitialPageImpl::InterstitialPageRVHDelegateView::ShowPopupMenu( |
815 const gfx::Rect& bounds, | 850 const gfx::Rect& bounds, |
816 int item_height, | 851 int item_height, |
817 double item_font_size, | 852 double item_font_size, |
818 int selected_item, | 853 int selected_item, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
853 | 888 |
854 web_contents->GetDelegateView()->TakeFocus(reverse); | 889 web_contents->GetDelegateView()->TakeFocus(reverse); |
855 } | 890 } |
856 | 891 |
857 void InterstitialPageImpl::InterstitialPageRVHDelegateView::OnFindReply( | 892 void InterstitialPageImpl::InterstitialPageRVHDelegateView::OnFindReply( |
858 int request_id, int number_of_matches, const gfx::Rect& selection_rect, | 893 int request_id, int number_of_matches, const gfx::Rect& selection_rect, |
859 int active_match_ordinal, bool final_update) { | 894 int active_match_ordinal, bool final_update) { |
860 } | 895 } |
861 | 896 |
862 } // namespace content | 897 } // namespace content |
OLD | NEW |