1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/browser/web_contents/interstitial_page_impl.h"
10 #include "base/compiler_specific.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h"
14 #include "base/threading/thread.h"
15 #include "content/browser/dom_storage/dom_storage_context_wrapper.h"
16 #include "content/browser/dom_storage/session_storage_namespace_impl.h"
17 #include "content/browser/loader/resource_dispatcher_host_impl.h"
18 #include "content/browser/renderer_host/render_process_host_impl.h"
19 #include "content/browser/renderer_host/render_view_host_impl.h"
20 #include "content/browser/site_instance_impl.h"
21 #include "content/browser/web_contents/navigation_controller_impl.h"
22 #include "content/browser/web_contents/navigation_entry_impl.h"
23 #include "content/browser/web_contents/web_contents_impl.h"
24 #include "content/common/view_messages.h"
25 #include "content/port/browser/render_view_host_delegate_view.h"
26 #include "content/port/browser/render_widget_host_view_port.h"
27 #include "content/port/browser/web_contents_view_port.h"
28 #include "content/public/browser/browser_context.h"
29 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/content_browser_client.h"
31 #include "content/public/browser/dom_operation_notification_details.h"
32 #include "content/public/browser/interstitial_page_delegate.h"
33 #include "content/public/browser/invalidate_type.h"
34 #include "content/public/browser/notification_service.h"
35 #include "content/public/browser/notification_source.h"
36 #include "content/public/browser/storage_partition.h"
37 #include "content/public/browser/web_contents_delegate.h"
38 #include "content/public/common/bindings_policy.h"
39 #include "content/public/common/page_transition_types.h"
40 #include "net/base/escape.h"
41 #include "net/url_request/url_request_context_getter.h"
43 using WebKit::WebDragOperation
;
44 using WebKit::WebDragOperationsMask
;
49 void ResourceRequestHelper(ResourceDispatcherHostImpl
* rdh
,
51 int render_view_host_id
,
52 ResourceRequestAction action
) {
55 rdh
->BlockRequestsForRoute(process_id
, render_view_host_id
);
58 rdh
->ResumeBlockedRequestsForRoute(process_id
, render_view_host_id
);
61 rdh
->CancelBlockedRequestsForRoute(process_id
, render_view_host_id
);
70 class InterstitialPageImpl::InterstitialPageRVHDelegateView
71 : public RenderViewHostDelegateView
{
73 explicit InterstitialPageRVHDelegateView(InterstitialPageImpl
* page
);
75 // RenderViewHostDelegateView implementation:
76 virtual void ShowPopupMenu(const gfx::Rect
& bounds
,
78 double item_font_size
,
80 const std::vector
<MenuItem
>& items
,
82 bool allow_multiple_selection
) OVERRIDE
;
83 virtual void StartDragging(const DropData
& drop_data
,
84 WebDragOperationsMask operations_allowed
,
85 const gfx::ImageSkia
& image
,
86 const gfx::Vector2d
& image_offset
,
87 const DragEventSourceInfo
& event_info
) OVERRIDE
;
88 virtual void UpdateDragCursor(WebDragOperation operation
) OVERRIDE
;
89 virtual void GotFocus() OVERRIDE
;
90 virtual void TakeFocus(bool reverse
) OVERRIDE
;
91 virtual void OnFindReply(int request_id
,
92 int number_of_matches
,
93 const gfx::Rect
& selection_rect
,
94 int active_match_ordinal
,
98 InterstitialPageImpl
* interstitial_page_
;
100 DISALLOW_COPY_AND_ASSIGN(InterstitialPageRVHDelegateView
);
104 // We keep a map of the various blocking pages shown as the UI tests need to
105 // be able to retrieve them.
106 typedef std::map
<WebContents
*, InterstitialPageImpl
*> InterstitialPageMap
;
107 static InterstitialPageMap
* g_web_contents_to_interstitial_page
;
109 // Initializes g_web_contents_to_interstitial_page in a thread-safe manner.
110 // Should be called before accessing g_web_contents_to_interstitial_page.
111 static void InitInterstitialPageMap() {
112 if (!g_web_contents_to_interstitial_page
)
113 g_web_contents_to_interstitial_page
= new InterstitialPageMap
;
116 InterstitialPage
* InterstitialPage::Create(WebContents
* web_contents
,
119 InterstitialPageDelegate
* delegate
) {
120 return new InterstitialPageImpl(web_contents
, new_navigation
, url
, delegate
);
123 InterstitialPage
* InterstitialPage::GetInterstitialPage(
124 WebContents
* web_contents
) {
125 InitInterstitialPageMap();
126 InterstitialPageMap::const_iterator iter
=
127 g_web_contents_to_interstitial_page
->find(web_contents
);
128 if (iter
== g_web_contents_to_interstitial_page
->end())
134 InterstitialPageImpl::InterstitialPageImpl(WebContents
* web_contents
,
137 InterstitialPageDelegate
* delegate
)
138 : WebContentsObserver(web_contents
),
139 web_contents_(static_cast<WebContentsImpl
*>(web_contents
)),
141 new_navigation_(new_navigation
),
142 should_discard_pending_nav_entry_(new_navigation
),
143 reload_on_dont_proceed_(false),
145 action_taken_(NO_ACTION
),
146 render_view_host_(NULL
),
147 original_child_id_(web_contents
->GetRenderProcessHost()->GetID()),
148 original_rvh_id_(web_contents
->GetRenderViewHost()->GetRoutingID()),
149 should_revert_web_contents_title_(false),
150 web_contents_was_loading_(false),
151 resource_dispatcher_host_notified_(false),
152 rvh_delegate_view_(new InterstitialPageRVHDelegateView(this)),
155 weak_ptr_factory_(this) {
156 InitInterstitialPageMap();
157 // It would be inconsistent to create an interstitial with no new navigation
158 // (which is the case when the interstitial was triggered by a sub-resource on
159 // a page) when we have a pending entry (in the process of loading a new top
161 DCHECK(new_navigation
|| !web_contents
->GetController().GetPendingEntry());
164 InterstitialPageImpl::~InterstitialPageImpl() {
167 void InterstitialPageImpl::Show() {
171 // If an interstitial is already showing or about to be shown, close it before
172 // showing the new one.
173 // Be careful not to take an action on the old interstitial more than once.
174 InterstitialPageMap::const_iterator iter
=
175 g_web_contents_to_interstitial_page
->find(web_contents_
);
176 if (iter
!= g_web_contents_to_interstitial_page
->end()) {
177 InterstitialPageImpl
* interstitial
= iter
->second
;
178 if (interstitial
->action_taken_
!= NO_ACTION
) {
179 interstitial
->Hide();
181 // If we are currently showing an interstitial page for which we created
182 // a transient entry and a new interstitial is shown as the result of a
183 // new browser initiated navigation, then that transient entry has already
184 // been discarded and a new pending navigation entry created.
185 // So we should not discard that new pending navigation entry.
186 // See http://crbug.com/9791
187 if (new_navigation_
&& interstitial
->new_navigation_
)
188 interstitial
->should_discard_pending_nav_entry_
= false;
189 interstitial
->DontProceed();
193 // Block the resource requests for the render view host while it is hidden.
194 TakeActionOnResourceDispatcher(BLOCK
);
195 // We need to be notified when the RenderViewHost is destroyed so we can
196 // cancel the blocked requests. We cannot do that on
197 // NOTIFY_WEB_CONTENTS_DESTROYED as at that point the RenderViewHost has
198 // already been destroyed.
199 notification_registrar_
.Add(
200 this, NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED
,
201 Source
<RenderWidgetHost
>(web_contents_
->GetRenderViewHost()));
203 // Update the g_web_contents_to_interstitial_page map.
204 iter
= g_web_contents_to_interstitial_page
->find(web_contents_
);
205 DCHECK(iter
== g_web_contents_to_interstitial_page
->end());
206 (*g_web_contents_to_interstitial_page
)[web_contents_
] = this;
208 if (new_navigation_
) {
209 NavigationEntryImpl
* entry
= new NavigationEntryImpl
;
211 entry
->SetVirtualURL(url_
);
212 entry
->set_page_type(PAGE_TYPE_INTERSTITIAL
);
214 // Give delegates a chance to set some states on the navigation entry.
215 delegate_
->OverrideEntry(entry
);
217 web_contents_
->GetController().SetTransientEntry(entry
);
220 DCHECK(!render_view_host_
);
221 render_view_host_
= static_cast<RenderViewHostImpl
*>(CreateRenderViewHost());
222 CreateWebContentsView();
224 std::string data_url
= "data:text/html;charset=utf-8," +
225 net::EscapePath(delegate_
->GetHTMLContents());
226 render_view_host_
->NavigateToURL(GURL(data_url
));
228 notification_registrar_
.Add(this, NOTIFICATION_NAV_ENTRY_PENDING
,
229 Source
<NavigationController
>(&web_contents_
->GetController()));
230 notification_registrar_
.Add(
231 this, NOTIFICATION_DOM_OPERATION_RESPONSE
,
232 Source
<RenderViewHost
>(render_view_host_
));
235 void InterstitialPageImpl::Hide() {
236 // We may have already been hidden, and are just waiting to be deleted.
237 // We can't check for enabled() here, because some callers have already
239 if (!render_view_host_
)
244 RenderWidgetHostView
* old_view
=
245 web_contents_
->GetRenderViewHost()->GetView();
246 if (web_contents_
->GetInterstitialPage() == this &&
247 old_view
&& !old_view
->IsShowing()) {
248 // Show the original RVH since we're going away. Note it might not exist if
249 // the renderer crashed while the interstitial was showing.
250 // Note that it is important that we don't call Show() if the view is
251 // already showing. That would result in bad things (unparented HWND on
252 // Windows for example) happening.
256 // If the focus was on the interstitial, let's keep it to the page.
257 // (Note that in unit-tests the RVH may not have a view).
258 if (render_view_host_
->GetView() &&
259 render_view_host_
->GetView()->HasFocus() &&
260 web_contents_
->GetRenderViewHost()->GetView()) {
261 RenderWidgetHostViewPort::FromRWHV(
262 web_contents_
->GetRenderViewHost()->GetView())->Focus();
265 // Shutdown the RVH asynchronously, as we may have been called from a RVH
266 // delegate method, and we can't delete the RVH out from under itself.
267 base::MessageLoop::current()->PostNonNestableTask(
269 base::Bind(&InterstitialPageImpl::Shutdown
,
270 weak_ptr_factory_
.GetWeakPtr(),
272 render_view_host_
= NULL
;
273 web_contents_
->DetachInterstitialPage();
274 // Let's revert to the original title if necessary.
275 NavigationEntry
* entry
= web_contents_
->GetController().GetActiveEntry();
276 if (!new_navigation_
&& should_revert_web_contents_title_
) {
277 entry
->SetTitle(original_web_contents_title_
);
278 web_contents_
->NotifyNavigationStateChanged(INVALIDATE_TYPE_TITLE
);
281 InterstitialPageMap::iterator iter
=
282 g_web_contents_to_interstitial_page
->find(web_contents_
);
283 DCHECK(iter
!= g_web_contents_to_interstitial_page
->end());
284 if (iter
!= g_web_contents_to_interstitial_page
->end())
285 g_web_contents_to_interstitial_page
->erase(iter
);
287 // Clear the WebContents pointer, because it may now be deleted.
288 // This signifies that we are in the process of shutting down.
289 web_contents_
= NULL
;
292 void InterstitialPageImpl::Observe(
294 const NotificationSource
& source
,
295 const NotificationDetails
& details
) {
297 case NOTIFICATION_NAV_ENTRY_PENDING
:
298 // We are navigating away from the interstitial (the user has typed a URL
299 // in the location bar or clicked a bookmark). Make sure clicking on the
300 // interstitial will have no effect. Also cancel any blocked requests
301 // on the ResourceDispatcherHost. Note that when we get this notification
302 // the RenderViewHost has not yet navigated so we'll unblock the
303 // RenderViewHost before the resource request for the new page we are
304 // navigating arrives in the ResourceDispatcherHost. This ensures that
305 // request won't be blocked if the same RenderViewHost was used for the
308 TakeActionOnResourceDispatcher(CANCEL
);
310 case NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED
:
311 if (action_taken_
== NO_ACTION
) {
312 // The RenderViewHost is being destroyed (as part of the tab being
313 // closed); make sure we clear the blocked requests.
314 RenderViewHost
* rvh
= static_cast<RenderViewHost
*>(
315 static_cast<RenderViewHostImpl
*>(
316 RenderWidgetHostImpl::From(
317 Source
<RenderWidgetHost
>(source
).ptr())));
318 DCHECK(rvh
->GetProcess()->GetID() == original_child_id_
&&
319 rvh
->GetRoutingID() == original_rvh_id_
);
320 TakeActionOnResourceDispatcher(CANCEL
);
323 case NOTIFICATION_DOM_OPERATION_RESPONSE
:
325 Details
<DomOperationNotificationDetails
> dom_op_details(
327 delegate_
->CommandReceived(dom_op_details
->json
);
335 void InterstitialPageImpl::NavigationEntryCommitted(
336 const LoadCommittedDetails
& load_details
) {
337 OnNavigatingAwayOrTabClosing();
340 void InterstitialPageImpl::WebContentsDestroyed(WebContents
* web_contents
) {
341 OnNavigatingAwayOrTabClosing();
344 RenderViewHostDelegateView
* InterstitialPageImpl::GetDelegateView() {
345 return rvh_delegate_view_
.get();
348 const GURL
& InterstitialPageImpl::GetURL() const {
352 void InterstitialPageImpl::RenderViewTerminated(
353 RenderViewHost
* render_view_host
,
354 base::TerminationStatus status
,
356 // Our renderer died. This should not happen in normal cases.
357 // If we haven't already started shutdown, just dismiss the interstitial.
358 // We cannot check for enabled() here, because we may have called Disable
359 // without calling Hide.
360 if (render_view_host_
)
364 void InterstitialPageImpl::DidNavigate(
365 RenderViewHost
* render_view_host
,
366 const ViewHostMsg_FrameNavigate_Params
& params
) {
367 // A fast user could have navigated away from the page that triggered the
368 // interstitial while the interstitial was loading, that would have disabled
369 // us. In that case we can dismiss ourselves.
374 if (PageTransitionCoreTypeIs(params
.transition
,
375 PAGE_TRANSITION_AUTO_SUBFRAME
)) {
376 // No need to handle navigate message from iframe in the interstitial page.
380 // The RenderViewHost has loaded its contents, we can show it now.
381 render_view_host_
->GetView()->Show();
382 web_contents_
->AttachInterstitialPage(this);
384 RenderWidgetHostView
* rwh_view
=
385 web_contents_
->GetRenderViewHost()->GetView();
387 // The RenderViewHost may already have crashed before we even get here.
389 // If the page has focus, focus the interstitial.
390 if (rwh_view
->HasFocus())
393 // Hide the original RVH since we're showing the interstitial instead.
397 // Notify the tab we are not loading so the throbber is stopped. It also
398 // causes a NOTIFY_LOAD_STOP notification, that the AutomationProvider (used
399 // by the UI tests) expects to consider a navigation as complete. Without
400 // this, navigating in a UI test to a URL that triggers an interstitial would
402 web_contents_was_loading_
= web_contents_
->IsLoading();
403 web_contents_
->SetIsLoading(false, NULL
);
406 void InterstitialPageImpl::UpdateTitle(
407 RenderViewHost
* render_view_host
,
409 const string16
& title
,
410 base::i18n::TextDirection title_direction
) {
414 DCHECK(render_view_host
== render_view_host_
);
415 NavigationEntry
* entry
= web_contents_
->GetController().GetActiveEntry();
417 // Crash reports from the field indicate this can be NULL.
418 // This is unexpected as InterstitialPages constructed with the
419 // new_navigation flag set to true create a transient navigation entry
420 // (that is returned as the active entry). And the only case so far of
421 // interstitial created with that flag set to false is with the
422 // SafeBrowsingBlockingPage, when the resource triggering the interstitial
423 // is a sub-resource, meaning the main page has already been loaded and a
424 // navigation entry should have been created.
429 // If this interstitial is shown on an existing navigation entry, we'll need
430 // to remember its title so we can revert to it when hidden.
431 if (!new_navigation_
&& !should_revert_web_contents_title_
) {
432 original_web_contents_title_
= entry
->GetTitle();
433 should_revert_web_contents_title_
= true;
435 // TODO(evan): make use of title_direction.
436 // http://code.google.com/p/chromium/issues/detail?id=27094
437 entry
->SetTitle(title
);
438 web_contents_
->NotifyNavigationStateChanged(INVALIDATE_TYPE_TITLE
);
441 RendererPreferences
InterstitialPageImpl::GetRendererPrefs(
442 BrowserContext
* browser_context
) const {
443 delegate_
->OverrideRendererPrefs(&renderer_preferences_
);
444 return renderer_preferences_
;
447 WebPreferences
InterstitialPageImpl::GetWebkitPrefs() {
449 return WebPreferences();
451 return WebContentsImpl::GetWebkitPrefs(render_view_host_
, url_
);
454 void InterstitialPageImpl::RenderWidgetDeleted(
455 RenderWidgetHostImpl
* render_widget_host
) {
459 bool InterstitialPageImpl::PreHandleKeyboardEvent(
460 const NativeWebKeyboardEvent
& event
,
461 bool* is_keyboard_shortcut
) {
464 return web_contents_
->PreHandleKeyboardEvent(event
, is_keyboard_shortcut
);
467 void InterstitialPageImpl::HandleKeyboardEvent(
468 const NativeWebKeyboardEvent
& event
) {
470 web_contents_
->HandleKeyboardEvent(event
);
473 #if defined(OS_WIN) && defined(USE_AURA)
474 gfx::NativeViewAccessible
475 InterstitialPageImpl::GetParentNativeViewAccessible() {
476 return web_contents_
->GetParentNativeViewAccessible();
480 WebContents
* InterstitialPageImpl::web_contents() const {
481 return web_contents_
;
484 RenderViewHost
* InterstitialPageImpl::CreateRenderViewHost() {
488 // Interstitial pages don't want to share the session storage so we mint a
490 BrowserContext
* browser_context
= web_contents()->GetBrowserContext();
491 scoped_refptr
<SiteInstance
> site_instance
=
492 SiteInstance::Create(browser_context
);
493 DOMStorageContextWrapper
* dom_storage_context
=
494 static_cast<DOMStorageContextWrapper
*>(
495 BrowserContext::GetStoragePartition(
496 browser_context
, site_instance
.get())->GetDOMStorageContext());
497 session_storage_namespace_
=
498 new SessionStorageNamespaceImpl(dom_storage_context
);
500 RenderViewHostImpl
* render_view_host
=
501 new RenderViewHostImpl(site_instance
.get(),
508 web_contents_
->RenderViewForInterstitialPageCreated(render_view_host
);
509 return render_view_host
;
512 WebContentsView
* InterstitialPageImpl::CreateWebContentsView() {
513 if (!enabled() || !create_view_
)
515 WebContentsView
* web_contents_view
= web_contents()->GetView();
516 WebContentsViewPort
* web_contents_view_port
=
517 static_cast<WebContentsViewPort
*>(web_contents_view
);
518 RenderWidgetHostView
* view
=
519 web_contents_view_port
->CreateViewForWidget(render_view_host_
);
520 render_view_host_
->SetView(view
);
521 render_view_host_
->AllowBindings(BINDINGS_POLICY_DOM_AUTOMATION
);
523 int32 max_page_id
= web_contents()->
524 GetMaxPageIDForSiteInstance(render_view_host_
->GetSiteInstance());
525 render_view_host_
->CreateRenderView(string16(),
528 view
->SetSize(web_contents_view
->GetContainerSize());
529 // Don't show the interstitial until we have navigated to it.
531 return web_contents_view
;
534 void InterstitialPageImpl::Proceed() {
535 // Don't repeat this if we are already shutting down. We cannot check for
536 // enabled() here, because we may have called Disable without calling Hide.
537 if (!render_view_host_
)
540 if (action_taken_
!= NO_ACTION
) {
545 action_taken_
= PROCEED_ACTION
;
547 // Resumes the throbber, if applicable.
548 if (web_contents_was_loading_
)
549 web_contents_
->SetIsLoading(true, NULL
);
551 // If this is a new navigation, the old page is going away, so we cancel any
552 // blocked requests for it. If it is not a new navigation, then it means the
553 // interstitial was shown as a result of a resource loading in the page.
554 // Since the user wants to proceed, we'll let any blocked request go through.
556 TakeActionOnResourceDispatcher(CANCEL
);
558 TakeActionOnResourceDispatcher(RESUME
);
560 // No need to hide if we are a new navigation, we'll get hidden when the
561 // navigation is committed.
562 if (!new_navigation_
) {
564 delegate_
->OnProceed();
568 delegate_
->OnProceed();
571 void InterstitialPageImpl::DontProceed() {
572 // Don't repeat this if we are already shutting down. We cannot check for
573 // enabled() here, because we may have called Disable without calling Hide.
574 if (!render_view_host_
)
576 DCHECK(action_taken_
!= DONT_PROCEED_ACTION
);
579 action_taken_
= DONT_PROCEED_ACTION
;
581 // If this is a new navigation, we are returning to the original page, so we
582 // resume blocked requests for it. If it is not a new navigation, then it
583 // means the interstitial was shown as a result of a resource loading in the
584 // page and we won't return to the original page, so we cancel blocked
585 // requests in that case.
587 TakeActionOnResourceDispatcher(RESUME
);
589 TakeActionOnResourceDispatcher(CANCEL
);
591 if (should_discard_pending_nav_entry_
) {
592 // Since no navigation happens we have to discard the transient entry
593 // explicitely. Note that by calling DiscardNonCommittedEntries() we also
594 // discard the pending entry, which is what we want, since the navigation is
596 web_contents_
->GetController().DiscardNonCommittedEntries();
599 if (reload_on_dont_proceed_
)
600 web_contents_
->GetController().Reload(true);
603 delegate_
->OnDontProceed();
606 void InterstitialPageImpl::CancelForNavigation() {
607 // The user is trying to navigate away. We should unblock the renderer and
608 // disable the interstitial, but keep it visible until the navigation
611 // If this interstitial was shown for a new navigation, allow any navigations
612 // on the original page to resume (e.g., subresource requests, XHRs, etc).
613 // Otherwise, cancel the pending, possibly dangerous navigations.
615 TakeActionOnResourceDispatcher(RESUME
);
617 TakeActionOnResourceDispatcher(CANCEL
);
620 void InterstitialPageImpl::SetSize(const gfx::Size
& size
) {
623 #if !defined(OS_MACOSX)
624 // When a tab is closed, we might be resized after our view was NULLed
625 // (typically if there was an info-bar).
626 if (render_view_host_
->GetView())
627 render_view_host_
->GetView()->SetSize(size
);
629 // TODO(port): Does Mac need to SetSize?
634 void InterstitialPageImpl::Focus() {
635 // Focus the native window.
638 RenderWidgetHostViewPort::FromRWHV(render_view_host_
->GetView())->Focus();
641 void InterstitialPageImpl::FocusThroughTabTraversal(bool reverse
) {
644 render_view_host_
->SetInitialFocus(reverse
);
647 RenderWidgetHostView
* InterstitialPageImpl::GetView() {
648 return render_view_host_
->GetView();
651 RenderViewHost
* InterstitialPageImpl::GetRenderViewHostForTesting() const {
652 return render_view_host_
;
655 #if defined(OS_ANDROID)
656 RenderViewHost
* InterstitialPageImpl::GetRenderViewHost() const {
657 return render_view_host_
;
661 InterstitialPageDelegate
* InterstitialPageImpl::GetDelegateForTesting() {
662 return delegate_
.get();
665 void InterstitialPageImpl::DontCreateViewForTesting() {
666 create_view_
= false;
669 gfx::Rect
InterstitialPageImpl::GetRootWindowResizerRect() const {
673 void InterstitialPageImpl::CreateNewWindow(
675 int main_frame_route_id
,
676 const ViewHostMsg_CreateWindow_Params
& params
,
677 SessionStorageNamespace
* session_storage_namespace
) {
678 NOTREACHED() << "InterstitialPage does not support showing popups yet.";
681 void InterstitialPageImpl::CreateNewWidget(int route_id
,
682 WebKit::WebPopupType popup_type
) {
683 NOTREACHED() << "InterstitialPage does not support showing drop-downs yet.";
686 void InterstitialPageImpl::CreateNewFullscreenWidget(int route_id
) {
688 << "InterstitialPage does not support showing full screen popups.";
691 void InterstitialPageImpl::ShowCreatedWindow(int route_id
,
692 WindowOpenDisposition disposition
,
693 const gfx::Rect
& initial_pos
,
695 NOTREACHED() << "InterstitialPage does not support showing popups yet.";
698 void InterstitialPageImpl::ShowCreatedWidget(int route_id
,
699 const gfx::Rect
& initial_pos
) {
700 NOTREACHED() << "InterstitialPage does not support showing drop-downs yet.";
703 void InterstitialPageImpl::ShowCreatedFullscreenWidget(int route_id
) {
705 << "InterstitialPage does not support showing full screen popups.";
708 SessionStorageNamespace
* InterstitialPageImpl::GetSessionStorageNamespace(
709 SiteInstance
* instance
) {
710 return session_storage_namespace_
.get();
713 void InterstitialPageImpl::Disable() {
717 void InterstitialPageImpl::Shutdown(RenderViewHostImpl
* render_view_host
) {
718 render_view_host
->Shutdown();
719 // We are deleted now.
722 void InterstitialPageImpl::OnNavigatingAwayOrTabClosing() {
723 if (action_taken_
== NO_ACTION
) {
724 // We are navigating away from the interstitial or closing a tab with an
725 // interstitial. Default to DontProceed(). We don't just call Hide as
726 // subclasses will almost certainly override DontProceed to do some work
727 // (ex: close pending connections).
730 // User decided to proceed and either the navigation was committed or
731 // the tab was closed before that.
736 void InterstitialPageImpl::TakeActionOnResourceDispatcher(
737 ResourceRequestAction action
) {
738 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI
)) <<
739 "TakeActionOnResourceDispatcher should be called on the main thread.";
741 if (action
== CANCEL
|| action
== RESUME
) {
742 if (resource_dispatcher_host_notified_
)
744 resource_dispatcher_host_notified_
= true;
747 // The tab might not have a render_view_host if it was closed (in which case,
748 // we have taken care of the blocked requests when processing
749 // NOTIFY_RENDER_WIDGET_HOST_DESTROYED.
750 // Also we need to test there is a ResourceDispatcherHostImpl, as when unit-
751 // tests we don't have one.
752 RenderViewHostImpl
* rvh
= RenderViewHostImpl::FromID(original_child_id_
,
754 if (!rvh
|| !ResourceDispatcherHostImpl::Get())
757 BrowserThread::PostTask(
761 &ResourceRequestHelper
,
762 ResourceDispatcherHostImpl::Get(),
768 InterstitialPageImpl::InterstitialPageRVHDelegateView::
769 InterstitialPageRVHDelegateView(InterstitialPageImpl
* page
)
770 : interstitial_page_(page
) {
773 void InterstitialPageImpl::InterstitialPageRVHDelegateView::ShowPopupMenu(
774 const gfx::Rect
& bounds
,
776 double item_font_size
,
778 const std::vector
<MenuItem
>& items
,
780 bool allow_multiple_selection
) {
781 NOTREACHED() << "InterstitialPage does not support showing popup menus.";
784 void InterstitialPageImpl::InterstitialPageRVHDelegateView::StartDragging(
785 const DropData
& drop_data
,
786 WebDragOperationsMask allowed_operations
,
787 const gfx::ImageSkia
& image
,
788 const gfx::Vector2d
& image_offset
,
789 const DragEventSourceInfo
& event_info
) {
790 NOTREACHED() << "InterstitialPage does not support dragging yet.";
793 void InterstitialPageImpl::InterstitialPageRVHDelegateView::UpdateDragCursor(
795 NOTREACHED() << "InterstitialPage does not support dragging yet.";
798 void InterstitialPageImpl::InterstitialPageRVHDelegateView::GotFocus() {
799 WebContents
* web_contents
= interstitial_page_
->web_contents();
800 if (web_contents
&& web_contents
->GetDelegate())
801 web_contents
->GetDelegate()->WebContentsFocused(web_contents
);
804 void InterstitialPageImpl::InterstitialPageRVHDelegateView::TakeFocus(
806 if (!interstitial_page_
->web_contents())
808 WebContentsImpl
* web_contents
=
809 static_cast<WebContentsImpl
*>(interstitial_page_
->web_contents());
810 if (!web_contents
->GetDelegateView())
813 web_contents
->GetDelegateView()->TakeFocus(reverse
);
816 void InterstitialPageImpl::InterstitialPageRVHDelegateView::OnFindReply(
817 int request_id
, int number_of_matches
, const gfx::Rect
& selection_rect
,
818 int active_match_ordinal
, bool final_update
) {
821 } // namespace content