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
3 // found in the LICENSE file.
5 #include "content/browser/frame_host/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/frame_host/interstitial_page_navigator_impl.h"
18 #include "content/browser/frame_host/navigation_controller_impl.h"
19 #include "content/browser/frame_host/navigation_entry_impl.h"
20 #include "content/browser/loader/resource_dispatcher_host_impl.h"
21 #include "content/browser/renderer_host/render_process_host_impl.h"
22 #include "content/browser/renderer_host/render_view_host_factory.h"
23 #include "content/browser/renderer_host/render_view_host_impl.h"
24 #include "content/browser/site_instance_impl.h"
25 #include "content/browser/web_contents/web_contents_impl.h"
26 #include "content/common/frame_messages.h"
27 #include "content/common/view_messages.h"
28 #include "content/port/browser/render_view_host_delegate_view.h"
29 #include "content/port/browser/render_widget_host_view_port.h"
30 #include "content/port/browser/web_contents_view_port.h"
31 #include "content/public/browser/browser_context.h"
32 #include "content/public/browser/browser_thread.h"
33 #include "content/public/browser/content_browser_client.h"
34 #include "content/public/browser/dom_operation_notification_details.h"
35 #include "content/public/browser/interstitial_page_delegate.h"
36 #include "content/public/browser/invalidate_type.h"
37 #include "content/public/browser/notification_service.h"
38 #include "content/public/browser/notification_source.h"
39 #include "content/public/browser/storage_partition.h"
40 #include "content/public/browser/web_contents_delegate.h"
41 #include "content/public/common/bindings_policy.h"
42 #include "content/public/common/page_transition_types.h"
43 #include "net/base/escape.h"
44 #include "net/url_request/url_request_context_getter.h"
46 using blink::WebDragOperation;
47 using blink::WebDragOperationsMask;
52 void ResourceRequestHelper(ResourceDispatcherHostImpl* rdh,
54 int render_view_host_id,
55 ResourceRequestAction action) {
58 rdh->BlockRequestsForRoute(process_id, render_view_host_id);
61 rdh->ResumeBlockedRequestsForRoute(process_id, render_view_host_id);
64 rdh->CancelBlockedRequestsForRoute(process_id, render_view_host_id);
73 class InterstitialPageImpl::InterstitialPageRVHDelegateView
74 : public RenderViewHostDelegateView {
76 explicit InterstitialPageRVHDelegateView(InterstitialPageImpl* page);
78 // RenderViewHostDelegateView implementation:
79 virtual void ShowPopupMenu(const gfx::Rect& bounds,
81 double item_font_size,
83 const std::vector<MenuItem>& items,
85 bool allow_multiple_selection) OVERRIDE;
86 virtual void StartDragging(const DropData& drop_data,
87 WebDragOperationsMask operations_allowed,
88 const gfx::ImageSkia& image,
89 const gfx::Vector2d& image_offset,
90 const DragEventSourceInfo& event_info) OVERRIDE;
91 virtual void UpdateDragCursor(WebDragOperation operation) OVERRIDE;
92 virtual void GotFocus() OVERRIDE;
93 virtual void TakeFocus(bool reverse) OVERRIDE;
94 virtual void OnFindReply(int request_id,
95 int number_of_matches,
96 const gfx::Rect& selection_rect,
97 int active_match_ordinal,
101 InterstitialPageImpl* interstitial_page_;
103 DISALLOW_COPY_AND_ASSIGN(InterstitialPageRVHDelegateView);
107 // We keep a map of the various blocking pages shown as the UI tests need to
108 // be able to retrieve them.
109 typedef std::map<WebContents*, InterstitialPageImpl*> InterstitialPageMap;
110 static InterstitialPageMap* g_web_contents_to_interstitial_page;
112 // Initializes g_web_contents_to_interstitial_page in a thread-safe manner.
113 // Should be called before accessing g_web_contents_to_interstitial_page.
114 static void InitInterstitialPageMap() {
115 if (!g_web_contents_to_interstitial_page)
116 g_web_contents_to_interstitial_page = new InterstitialPageMap;
119 InterstitialPage* InterstitialPage::Create(WebContents* web_contents,
122 InterstitialPageDelegate* delegate) {
123 return new InterstitialPageImpl(
125 static_cast<RenderWidgetHostDelegate*>(
126 static_cast<WebContentsImpl*>(web_contents)),
127 new_navigation, url, delegate);
130 InterstitialPage* InterstitialPage::GetInterstitialPage(
131 WebContents* web_contents) {
132 InitInterstitialPageMap();
133 InterstitialPageMap::const_iterator iter =
134 g_web_contents_to_interstitial_page->find(web_contents);
135 if (iter == g_web_contents_to_interstitial_page->end())
141 InterstitialPageImpl::InterstitialPageImpl(
142 WebContents* web_contents,
143 RenderWidgetHostDelegate* render_widget_host_delegate,
146 InterstitialPageDelegate* delegate)
147 : WebContentsObserver(web_contents),
148 web_contents_(web_contents),
149 controller_(static_cast<NavigationControllerImpl*>(
150 &web_contents->GetController())),
151 render_widget_host_delegate_(render_widget_host_delegate),
153 new_navigation_(new_navigation),
154 should_discard_pending_nav_entry_(new_navigation),
155 reload_on_dont_proceed_(false),
157 action_taken_(NO_ACTION),
158 render_view_host_(NULL),
159 // TODO(nasko): The InterstitialPageImpl will need to provide its own
160 // NavigationControllerImpl to the Navigator, which is separate from
161 // the WebContents one, so we can enforce no navigation policy here.
162 // While we get the code to a point to do this, pass NULL for it.
163 // TODO(creis): We will also need to pass delegates for the RVHM as we
165 frame_tree_(new InterstitialPageNavigatorImpl(this, controller_),
167 static_cast<WebContentsImpl*>(web_contents)),
168 original_child_id_(web_contents->GetRenderProcessHost()->GetID()),
169 original_rvh_id_(web_contents->GetRenderViewHost()->GetRoutingID()),
170 should_revert_web_contents_title_(false),
171 web_contents_was_loading_(false),
172 resource_dispatcher_host_notified_(false),
173 rvh_delegate_view_(new InterstitialPageRVHDelegateView(this)),
176 weak_ptr_factory_(this) {
177 InitInterstitialPageMap();
178 // It would be inconsistent to create an interstitial with no new navigation
179 // (which is the case when the interstitial was triggered by a sub-resource on
180 // a page) when we have a pending entry (in the process of loading a new top
182 DCHECK(new_navigation || !web_contents->GetController().GetPendingEntry());
185 InterstitialPageImpl::~InterstitialPageImpl() {
188 void InterstitialPageImpl::Show() {
192 // If an interstitial is already showing or about to be shown, close it before
193 // showing the new one.
194 // Be careful not to take an action on the old interstitial more than once.
195 InterstitialPageMap::const_iterator iter =
196 g_web_contents_to_interstitial_page->find(web_contents_);
197 if (iter != g_web_contents_to_interstitial_page->end()) {
198 InterstitialPageImpl* interstitial = iter->second;
199 if (interstitial->action_taken_ != NO_ACTION) {
200 interstitial->Hide();
202 // If we are currently showing an interstitial page for which we created
203 // a transient entry and a new interstitial is shown as the result of a
204 // new browser initiated navigation, then that transient entry has already
205 // been discarded and a new pending navigation entry created.
206 // So we should not discard that new pending navigation entry.
207 // See http://crbug.com/9791
208 if (new_navigation_ && interstitial->new_navigation_)
209 interstitial->should_discard_pending_nav_entry_= false;
210 interstitial->DontProceed();
214 // Block the resource requests for the render view host while it is hidden.
215 TakeActionOnResourceDispatcher(BLOCK);
216 // We need to be notified when the RenderViewHost is destroyed so we can
217 // cancel the blocked requests. We cannot do that on
218 // NOTIFY_WEB_CONTENTS_DESTROYED as at that point the RenderViewHost has
219 // already been destroyed.
220 notification_registrar_.Add(
221 this, NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
222 Source<RenderWidgetHost>(controller_->delegate()->GetRenderViewHost()));
224 // Update the g_web_contents_to_interstitial_page map.
225 iter = g_web_contents_to_interstitial_page->find(web_contents_);
226 DCHECK(iter == g_web_contents_to_interstitial_page->end());
227 (*g_web_contents_to_interstitial_page)[web_contents_] = this;
229 if (new_navigation_) {
230 NavigationEntryImpl* entry = new NavigationEntryImpl;
232 entry->SetVirtualURL(url_);
233 entry->set_page_type(PAGE_TYPE_INTERSTITIAL);
235 // Give delegates a chance to set some states on the navigation entry.
236 delegate_->OverrideEntry(entry);
238 controller_->SetTransientEntry(entry);
241 DCHECK(!render_view_host_);
242 render_view_host_ = static_cast<RenderViewHostImpl*>(CreateRenderViewHost());
243 render_view_host_->AttachToFrameTree();
244 CreateWebContentsView();
246 std::string data_url = "data:text/html;charset=utf-8," +
247 net::EscapePath(delegate_->GetHTMLContents());
248 render_view_host_->NavigateToURL(GURL(data_url));
250 notification_registrar_.Add(this, NOTIFICATION_NAV_ENTRY_PENDING,
251 Source<NavigationController>(controller_));
252 notification_registrar_.Add(
253 this, NOTIFICATION_DOM_OPERATION_RESPONSE,
254 Source<RenderViewHost>(render_view_host_));
257 void InterstitialPageImpl::Hide() {
258 // 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
261 if (!render_view_host_)
266 RenderWidgetHostView* old_view =
267 controller_->delegate()->GetRenderViewHost()->GetView();
268 if (controller_->delegate()->GetInterstitialPage() == this &&
270 !old_view->IsShowing() &&
271 !controller_->delegate()->IsHidden()) {
272 // Show the original RVH since we're going away. Note it might not exist if
273 // the renderer crashed while the interstitial was showing.
274 // Note that it is important that we don't call Show() if the view is
275 // already showing. That would result in bad things (unparented HWND on
276 // Windows for example) happening.
280 // If the focus was on the interstitial, let's keep it to the page.
281 // (Note that in unit-tests the RVH may not have a view).
282 if (render_view_host_->GetView() &&
283 render_view_host_->GetView()->HasFocus() &&
284 controller_->delegate()->GetRenderViewHost()->GetView()) {
285 RenderWidgetHostViewPort::FromRWHV(
286 controller_->delegate()->GetRenderViewHost()->GetView())->Focus();
289 // Delete this and call Shutdown on the RVH asynchronously, as we may have
290 // been called from a RVH delegate method, and we can't delete the RVH out
291 // from under itself.
292 base::MessageLoop::current()->PostNonNestableTask(
294 base::Bind(&InterstitialPageImpl::Shutdown,
295 weak_ptr_factory_.GetWeakPtr()));
296 render_view_host_ = NULL;
297 frame_tree_.ResetForMainFrameSwap();
298 controller_->delegate()->DetachInterstitialPage();
299 // Let's revert to the original title if necessary.
300 NavigationEntry* entry = controller_->GetVisibleEntry();
301 if (!new_navigation_ && should_revert_web_contents_title_) {
302 entry->SetTitle(original_web_contents_title_);
303 controller_->delegate()->NotifyNavigationStateChanged(
304 INVALIDATE_TYPE_TITLE);
307 InterstitialPageMap::iterator iter =
308 g_web_contents_to_interstitial_page->find(web_contents_);
309 DCHECK(iter != g_web_contents_to_interstitial_page->end());
310 if (iter != g_web_contents_to_interstitial_page->end())
311 g_web_contents_to_interstitial_page->erase(iter);
313 // Clear the WebContents pointer, because it may now be deleted.
314 // This signifies that we are in the process of shutting down.
315 web_contents_ = NULL;
318 void InterstitialPageImpl::Observe(
320 const NotificationSource& source,
321 const NotificationDetails& details) {
323 case NOTIFICATION_NAV_ENTRY_PENDING:
324 // We are navigating away from the interstitial (the user has typed a URL
325 // in the location bar or clicked a bookmark). Make sure clicking on the
326 // interstitial will have no effect. Also cancel any blocked requests
327 // on the ResourceDispatcherHost. Note that when we get this notification
328 // the RenderViewHost has not yet navigated so we'll unblock the
329 // RenderViewHost before the resource request for the new page we are
330 // navigating arrives in the ResourceDispatcherHost. This ensures that
331 // request won't be blocked if the same RenderViewHost was used for the
334 TakeActionOnResourceDispatcher(CANCEL);
336 case NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED:
337 if (action_taken_ == NO_ACTION) {
338 // The RenderViewHost is being destroyed (as part of the tab being
339 // closed); make sure we clear the blocked requests.
340 RenderViewHost* rvh = static_cast<RenderViewHost*>(
341 static_cast<RenderViewHostImpl*>(
342 RenderWidgetHostImpl::From(
343 Source<RenderWidgetHost>(source).ptr())));
344 DCHECK(rvh->GetProcess()->GetID() == original_child_id_ &&
345 rvh->GetRoutingID() == original_rvh_id_);
346 TakeActionOnResourceDispatcher(CANCEL);
349 case NOTIFICATION_DOM_OPERATION_RESPONSE:
351 Details<DomOperationNotificationDetails> dom_op_details(
353 delegate_->CommandReceived(dom_op_details->json);
361 void InterstitialPageImpl::NavigationEntryCommitted(
362 const LoadCommittedDetails& load_details) {
363 OnNavigatingAwayOrTabClosing();
366 void InterstitialPageImpl::WebContentsDestroyed(WebContents* web_contents) {
367 OnNavigatingAwayOrTabClosing();
370 void InterstitialPageImpl::RenderFrameCreated(
371 RenderFrameHost* render_frame_host) {
372 // Note this is only for subframes in the interstitial, the notification for
373 // the main frame happens in RenderViewCreated.
374 controller_->delegate()->RenderFrameForInterstitialPageCreated(
378 RenderViewHostDelegateView* InterstitialPageImpl::GetDelegateView() {
379 return rvh_delegate_view_.get();
382 const GURL& InterstitialPageImpl::GetURL() const {
386 void InterstitialPageImpl::RenderViewTerminated(
387 RenderViewHost* render_view_host,
388 base::TerminationStatus status,
390 // Our renderer died. This should not happen in normal cases.
391 // If we haven't already started shutdown, just dismiss the interstitial.
392 // We cannot check for enabled() here, because we may have called Disable
393 // without calling Hide.
394 if (render_view_host_)
398 void InterstitialPageImpl::DidNavigate(
399 RenderViewHost* render_view_host,
400 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
401 // A fast user could have navigated away from the page that triggered the
402 // interstitial while the interstitial was loading, that would have disabled
403 // us. In that case we can dismiss ourselves.
408 if (PageTransitionCoreTypeIs(params.transition,
409 PAGE_TRANSITION_AUTO_SUBFRAME)) {
410 // No need to handle navigate message from iframe in the interstitial page.
414 // The RenderViewHost has loaded its contents, we can show it now.
415 if (!controller_->delegate()->IsHidden())
416 render_view_host_->GetView()->Show();
417 controller_->delegate()->AttachInterstitialPage(this);
419 RenderWidgetHostView* rwh_view =
420 controller_->delegate()->GetRenderViewHost()->GetView();
422 // The RenderViewHost may already have crashed before we even get here.
424 // If the page has focus, focus the interstitial.
425 if (rwh_view->HasFocus())
428 // Hide the original RVH since we're showing the interstitial instead.
432 // Notify the tab we are not loading so the throbber is stopped. It also
433 // causes a WebContentsObserver::DidStopLoading callback that the
434 // AutomationProvider (used by the UI tests) expects to consider a navigation
435 // as complete. Without this, navigating in a UI test to a URL that triggers
436 // an interstitial would hang.
437 web_contents_was_loading_ = controller_->delegate()->IsLoading();
438 controller_->delegate()->SetIsLoading(
439 controller_->delegate()->GetRenderViewHost(), false, NULL);
442 void InterstitialPageImpl::UpdateTitle(
443 RenderViewHost* render_view_host,
445 const base::string16& title,
446 base::i18n::TextDirection title_direction) {
450 DCHECK(render_view_host == render_view_host_);
451 NavigationEntry* entry = controller_->GetVisibleEntry();
453 // Crash reports from the field indicate this can be NULL.
454 // This is unexpected as InterstitialPages constructed with the
455 // new_navigation flag set to true create a transient navigation entry
456 // (that is returned as the active entry). And the only case so far of
457 // interstitial created with that flag set to false is with the
458 // SafeBrowsingBlockingPage, when the resource triggering the interstitial
459 // is a sub-resource, meaning the main page has already been loaded and a
460 // navigation entry should have been created.
465 // If this interstitial is shown on an existing navigation entry, we'll need
466 // to remember its title so we can revert to it when hidden.
467 if (!new_navigation_ && !should_revert_web_contents_title_) {
468 original_web_contents_title_ = entry->GetTitle();
469 should_revert_web_contents_title_ = true;
471 // TODO(evan): make use of title_direction.
472 // http://code.google.com/p/chromium/issues/detail?id=27094
473 entry->SetTitle(title);
474 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_TITLE);
477 RendererPreferences InterstitialPageImpl::GetRendererPrefs(
478 BrowserContext* browser_context) const {
479 delegate_->OverrideRendererPrefs(&renderer_preferences_);
480 return renderer_preferences_;
483 WebPreferences InterstitialPageImpl::GetWebkitPrefs() {
485 return WebPreferences();
487 return render_view_host_->GetWebkitPrefs(url_);
490 void InterstitialPageImpl::RenderWidgetDeleted(
491 RenderWidgetHostImpl* render_widget_host) {
492 // TODO(creis): Remove this method once we verify the shutdown path is sane.
493 CHECK(!web_contents_);
496 bool InterstitialPageImpl::PreHandleKeyboardEvent(
497 const NativeWebKeyboardEvent& event,
498 bool* is_keyboard_shortcut) {
501 return render_widget_host_delegate_->PreHandleKeyboardEvent(
502 event, is_keyboard_shortcut);
505 void InterstitialPageImpl::HandleKeyboardEvent(
506 const NativeWebKeyboardEvent& event) {
508 render_widget_host_delegate_->HandleKeyboardEvent(event);
512 gfx::NativeViewAccessible
513 InterstitialPageImpl::GetParentNativeViewAccessible() {
514 return render_widget_host_delegate_->GetParentNativeViewAccessible();
518 WebContents* InterstitialPageImpl::web_contents() const {
519 return web_contents_;
522 RenderViewHost* InterstitialPageImpl::CreateRenderViewHost() {
526 // Interstitial pages don't want to share the session storage so we mint a
528 BrowserContext* browser_context = web_contents()->GetBrowserContext();
529 scoped_refptr<SiteInstance> site_instance =
530 SiteInstance::Create(browser_context);
531 DOMStorageContextWrapper* dom_storage_context =
532 static_cast<DOMStorageContextWrapper*>(
533 BrowserContext::GetStoragePartition(
534 browser_context, site_instance.get())->GetDOMStorageContext());
535 session_storage_namespace_ =
536 new SessionStorageNamespaceImpl(dom_storage_context);
538 // Use the RenderViewHost from our FrameTree.
539 frame_tree_.root()->render_manager()->Init(
540 browser_context, site_instance.get(), MSG_ROUTING_NONE, MSG_ROUTING_NONE);
541 return frame_tree_.root()->current_frame_host()->render_view_host();
544 WebContentsView* InterstitialPageImpl::CreateWebContentsView() {
545 if (!enabled() || !create_view_)
547 WebContentsView* web_contents_view = web_contents()->GetView();
548 WebContentsViewPort* web_contents_view_port =
549 static_cast<WebContentsViewPort*>(web_contents_view);
550 RenderWidgetHostView* view =
551 web_contents_view_port->CreateViewForWidget(render_view_host_);
552 render_view_host_->SetView(view);
553 render_view_host_->AllowBindings(BINDINGS_POLICY_DOM_AUTOMATION);
555 int32 max_page_id = web_contents()->
556 GetMaxPageIDForSiteInstance(render_view_host_->GetSiteInstance());
557 render_view_host_->CreateRenderView(base::string16(),
560 controller_->delegate()->RenderFrameForInterstitialPageCreated(
561 frame_tree_.root()->current_frame_host());
562 view->SetSize(web_contents_view->GetContainerSize());
563 // Don't show the interstitial until we have navigated to it.
565 return web_contents_view;
568 void InterstitialPageImpl::Proceed() {
569 // Don't repeat this if we are already shutting down. We cannot check for
570 // enabled() here, because we may have called Disable without calling Hide.
571 if (!render_view_host_)
574 if (action_taken_ != NO_ACTION) {
579 action_taken_ = PROCEED_ACTION;
581 // Resumes the throbber, if applicable.
582 if (web_contents_was_loading_)
583 controller_->delegate()->SetIsLoading(
584 controller_->delegate()->GetRenderViewHost(), true, NULL);
586 // If this is a new navigation, the old page is going away, so we cancel any
587 // blocked requests for it. If it is not a new navigation, then it means the
588 // interstitial was shown as a result of a resource loading in the page.
589 // Since the user wants to proceed, we'll let any blocked request go through.
591 TakeActionOnResourceDispatcher(CANCEL);
593 TakeActionOnResourceDispatcher(RESUME);
595 // No need to hide if we are a new navigation, we'll get hidden when the
596 // navigation is committed.
597 if (!new_navigation_) {
599 delegate_->OnProceed();
603 delegate_->OnProceed();
606 void InterstitialPageImpl::DontProceed() {
607 // Don't repeat this if we are already shutting down. We cannot check for
608 // enabled() here, because we may have called Disable without calling Hide.
609 if (!render_view_host_)
611 DCHECK(action_taken_ != DONT_PROCEED_ACTION);
614 action_taken_ = DONT_PROCEED_ACTION;
616 // If this is a new navigation, we are returning to the original page, so we
617 // resume blocked requests for it. If it is not a new navigation, then it
618 // means the interstitial was shown as a result of a resource loading in the
619 // page and we won't return to the original page, so we cancel blocked
620 // requests in that case.
622 TakeActionOnResourceDispatcher(RESUME);
624 TakeActionOnResourceDispatcher(CANCEL);
626 if (should_discard_pending_nav_entry_) {
627 // Since no navigation happens we have to discard the transient entry
628 // explicitely. Note that by calling DiscardNonCommittedEntries() we also
629 // discard the pending entry, which is what we want, since the navigation is
631 controller_->DiscardNonCommittedEntries();
634 if (reload_on_dont_proceed_)
635 controller_->Reload(true);
638 delegate_->OnDontProceed();
641 void InterstitialPageImpl::CancelForNavigation() {
642 // The user is trying to navigate away. We should unblock the renderer and
643 // disable the interstitial, but keep it visible until the navigation
646 // If this interstitial was shown for a new navigation, allow any navigations
647 // on the original page to resume (e.g., subresource requests, XHRs, etc).
648 // Otherwise, cancel the pending, possibly dangerous navigations.
650 TakeActionOnResourceDispatcher(RESUME);
652 TakeActionOnResourceDispatcher(CANCEL);
655 void InterstitialPageImpl::SetSize(const gfx::Size& size) {
658 #if !defined(OS_MACOSX)
659 // When a tab is closed, we might be resized after our view was NULLed
660 // (typically if there was an info-bar).
661 if (render_view_host_->GetView())
662 render_view_host_->GetView()->SetSize(size);
664 // TODO(port): Does Mac need to SetSize?
669 void InterstitialPageImpl::Focus() {
670 // Focus the native window.
673 RenderWidgetHostViewPort::FromRWHV(render_view_host_->GetView())->Focus();
676 void InterstitialPageImpl::FocusThroughTabTraversal(bool reverse) {
679 render_view_host_->SetInitialFocus(reverse);
682 RenderWidgetHostView* InterstitialPageImpl::GetView() {
683 return render_view_host_->GetView();
686 RenderViewHost* InterstitialPageImpl::GetRenderViewHostForTesting() const {
687 return render_view_host_;
690 #if defined(OS_ANDROID)
691 RenderViewHost* InterstitialPageImpl::GetRenderViewHost() const {
692 return render_view_host_;
696 InterstitialPageDelegate* InterstitialPageImpl::GetDelegateForTesting() {
697 return delegate_.get();
700 void InterstitialPageImpl::DontCreateViewForTesting() {
701 create_view_ = false;
704 gfx::Rect InterstitialPageImpl::GetRootWindowResizerRect() const {
708 void InterstitialPageImpl::CreateNewWindow(
709 int render_process_id,
711 int main_frame_route_id,
712 const ViewHostMsg_CreateWindow_Params& params,
713 SessionStorageNamespace* session_storage_namespace) {
714 NOTREACHED() << "InterstitialPage does not support showing popups yet.";
717 void InterstitialPageImpl::CreateNewWidget(int render_process_id,
719 blink::WebPopupType popup_type) {
720 NOTREACHED() << "InterstitialPage does not support showing drop-downs yet.";
723 void InterstitialPageImpl::CreateNewFullscreenWidget(int render_process_id,
726 << "InterstitialPage does not support showing full screen popups.";
729 void InterstitialPageImpl::ShowCreatedWindow(int route_id,
730 WindowOpenDisposition disposition,
731 const gfx::Rect& initial_pos,
733 NOTREACHED() << "InterstitialPage does not support showing popups yet.";
736 void InterstitialPageImpl::ShowCreatedWidget(int route_id,
737 const gfx::Rect& initial_pos) {
738 NOTREACHED() << "InterstitialPage does not support showing drop-downs yet.";
741 void InterstitialPageImpl::ShowCreatedFullscreenWidget(int route_id) {
743 << "InterstitialPage does not support showing full screen popups.";
746 SessionStorageNamespace* InterstitialPageImpl::GetSessionStorageNamespace(
747 SiteInstance* instance) {
748 return session_storage_namespace_.get();
751 FrameTree* InterstitialPageImpl::GetFrameTree() {
755 void InterstitialPageImpl::Disable() {
759 void InterstitialPageImpl::Shutdown() {
763 void InterstitialPageImpl::OnNavigatingAwayOrTabClosing() {
764 if (action_taken_ == NO_ACTION) {
765 // We are navigating away from the interstitial or closing a tab with an
766 // interstitial. Default to DontProceed(). We don't just call Hide as
767 // subclasses will almost certainly override DontProceed to do some work
768 // (ex: close pending connections).
771 // User decided to proceed and either the navigation was committed or
772 // the tab was closed before that.
777 void InterstitialPageImpl::TakeActionOnResourceDispatcher(
778 ResourceRequestAction action) {
779 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)) <<
780 "TakeActionOnResourceDispatcher should be called on the main thread.";
782 if (action == CANCEL || action == RESUME) {
783 if (resource_dispatcher_host_notified_)
785 resource_dispatcher_host_notified_ = true;
788 // The tab might not have a render_view_host if it was closed (in which case,
789 // we have taken care of the blocked requests when processing
790 // NOTIFY_RENDER_WIDGET_HOST_DESTROYED.
791 // Also we need to test there is a ResourceDispatcherHostImpl, as when unit-
792 // tests we don't have one.
793 RenderViewHostImpl* rvh = RenderViewHostImpl::FromID(original_child_id_,
795 if (!rvh || !ResourceDispatcherHostImpl::Get())
798 BrowserThread::PostTask(
802 &ResourceRequestHelper,
803 ResourceDispatcherHostImpl::Get(),
809 InterstitialPageImpl::InterstitialPageRVHDelegateView::
810 InterstitialPageRVHDelegateView(InterstitialPageImpl* page)
811 : interstitial_page_(page) {
814 void InterstitialPageImpl::InterstitialPageRVHDelegateView::ShowPopupMenu(
815 const gfx::Rect& bounds,
817 double item_font_size,
819 const std::vector<MenuItem>& items,
821 bool allow_multiple_selection) {
822 NOTREACHED() << "InterstitialPage does not support showing popup menus.";
825 void InterstitialPageImpl::InterstitialPageRVHDelegateView::StartDragging(
826 const DropData& drop_data,
827 WebDragOperationsMask allowed_operations,
828 const gfx::ImageSkia& image,
829 const gfx::Vector2d& image_offset,
830 const DragEventSourceInfo& event_info) {
831 NOTREACHED() << "InterstitialPage does not support dragging yet.";
834 void InterstitialPageImpl::InterstitialPageRVHDelegateView::UpdateDragCursor(
836 NOTREACHED() << "InterstitialPage does not support dragging yet.";
839 void InterstitialPageImpl::InterstitialPageRVHDelegateView::GotFocus() {
840 WebContents* web_contents = interstitial_page_->web_contents();
841 if (web_contents && web_contents->GetDelegate())
842 web_contents->GetDelegate()->WebContentsFocused(web_contents);
845 void InterstitialPageImpl::InterstitialPageRVHDelegateView::TakeFocus(
847 if (!interstitial_page_->web_contents())
849 WebContentsImpl* web_contents =
850 static_cast<WebContentsImpl*>(interstitial_page_->web_contents());
851 if (!web_contents->GetDelegateView())
854 web_contents->GetDelegateView()->TakeFocus(reverse);
857 void InterstitialPageImpl::InterstitialPageRVHDelegateView::OnFindReply(
858 int request_id, int number_of_matches, const gfx::Rect& selection_rect,
859 int active_match_ordinal, bool final_update) {
862 } // namespace content