11e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 51e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "content/browser/frame_host/interstitial_page_impl.h" 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector> 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/bind.h" 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/compiler_specific.h" 119ab5563a3196760eb381d102cbb2bc0f7abc6a50Ben Murdoch#include "base/message_loop/message_loop.h" 12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/string_util.h" 13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/utf_string_conversions.h" 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/threading/thread.h" 15bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch#include "content/browser/dom_storage/dom_storage_context_wrapper.h" 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/browser/dom_storage/session_storage_namespace_impl.h" 17a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "content/browser/frame_host/interstitial_page_navigator_impl.h" 181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "content/browser/frame_host/navigation_controller_impl.h" 191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "content/browser/frame_host/navigation_entry_impl.h" 202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/browser/loader/resource_dispatcher_host_impl.h" 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/browser/renderer_host/render_process_host_impl.h" 22010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "content/browser/renderer_host/render_view_host_delegate_view.h" 234e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include "content/browser/renderer_host/render_view_host_factory.h" 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/browser/renderer_host/render_view_host_impl.h" 25010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "content/browser/renderer_host/render_widget_host_view_base.h" 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/browser/site_instance_impl.h" 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/browser/web_contents/web_contents_impl.h" 28010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include "content/browser/web_contents/web_contents_view.h" 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "content/common/frame_messages.h" 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/view_messages.h" 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/browser_context.h" 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/browser_thread.h" 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/content_browser_client.h" 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/dom_operation_notification_details.h" 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/interstitial_page_delegate.h" 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/invalidate_type.h" 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_service.h" 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_source.h" 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/storage_partition.h" 40a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "content/public/browser/user_metrics.h" 41c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "content/public/browser/web_contents_delegate.h" 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/common/bindings_policy.h" 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/base/escape.h" 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/url_request/url_request_context_getter.h" 451320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "ui/base/page_transition_types.h" 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 47f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)using blink::WebDragOperation; 48f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)using blink::WebDragOperationsMask; 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content { 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace { 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void ResourceRequestHelper(ResourceDispatcherHostImpl* rdh, 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int process_id, 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int render_view_host_id, 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ResourceRequestAction action) { 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) switch (action) { 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) case BLOCK: 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rdh->BlockRequestsForRoute(process_id, render_view_host_id); 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) break; 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) case RESUME: 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rdh->ResumeBlockedRequestsForRoute(process_id, render_view_host_id); 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) break; 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) case CANCEL: 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rdh->CancelBlockedRequestsForRoute(process_id, render_view_host_id); 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) break; 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) default: 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NOTREACHED(); 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class InterstitialPageImpl::InterstitialPageRVHDelegateView 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) : public RenderViewHostDelegateView { 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) explicit InterstitialPageRVHDelegateView(InterstitialPageImpl* page); 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // RenderViewHostDelegateView implementation: 80effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#if defined(OS_MACOSX) || defined(OS_ANDROID) 811320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual void ShowPopupMenu(RenderFrameHost* render_frame_host, 821320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci const gfx::Rect& bounds, 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int item_height, 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) double item_font_size, 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int selected_item, 867dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch const std::vector<MenuItem>& items, 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool right_aligned, 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool allow_multiple_selection) OVERRIDE; 89effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch virtual void HidePopupMenu() OVERRIDE; 90effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#endif 91eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch virtual void StartDragging(const DropData& drop_data, 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WebDragOperationsMask operations_allowed, 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::ImageSkia& image, 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Vector2d& image_offset, 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const DragEventSourceInfo& event_info) OVERRIDE; 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void UpdateDragCursor(WebDragOperation operation) OVERRIDE; 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void GotFocus() OVERRIDE; 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void TakeFocus(bool reverse) OVERRIDE; 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnFindReply(int request_id, 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int number_of_matches, 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Rect& selection_rect, 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int active_match_ordinal, 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool final_update); 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) InterstitialPageImpl* interstitial_page_; 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(InterstitialPageRVHDelegateView); 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// We keep a map of the various blocking pages shown as the UI tests need to 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// be able to retrieve them. 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef std::map<WebContents*, InterstitialPageImpl*> InterstitialPageMap; 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)static InterstitialPageMap* g_web_contents_to_interstitial_page; 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Initializes g_web_contents_to_interstitial_page in a thread-safe manner. 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Should be called before accessing g_web_contents_to_interstitial_page. 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)static void InitInterstitialPageMap() { 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!g_web_contents_to_interstitial_page) 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) g_web_contents_to_interstitial_page = new InterstitialPageMap; 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)InterstitialPage* InterstitialPage::Create(WebContents* web_contents, 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool new_navigation, 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const GURL& url, 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) InterstitialPageDelegate* delegate) { 1281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return new InterstitialPageImpl( 1291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) web_contents, 1301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) static_cast<RenderWidgetHostDelegate*>( 1311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) static_cast<WebContentsImpl*>(web_contents)), 1321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) new_navigation, url, delegate); 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)InterstitialPage* InterstitialPage::GetInterstitialPage( 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WebContents* web_contents) { 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) InitInterstitialPageMap(); 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) InterstitialPageMap::const_iterator iter = 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) g_web_contents_to_interstitial_page->find(web_contents); 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (iter == g_web_contents_to_interstitial_page->end()) 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return NULL; 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return iter->second; 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)InterstitialPageImpl::InterstitialPageImpl( 1471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) WebContents* web_contents, 1481e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) RenderWidgetHostDelegate* render_widget_host_delegate, 1491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) bool new_navigation, 1501e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) const GURL& url, 1511e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) InterstitialPageDelegate* delegate) 15290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) : WebContentsObserver(web_contents), 1531e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) web_contents_(web_contents), 1541e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) controller_(static_cast<NavigationControllerImpl*>( 1551e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) &web_contents->GetController())), 1561e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) render_widget_host_delegate_(render_widget_host_delegate), 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) url_(url), 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) new_navigation_(new_navigation), 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) should_discard_pending_nav_entry_(new_navigation), 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) reload_on_dont_proceed_(false), 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) enabled_(true), 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) action_taken_(NO_ACTION), 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) render_view_host_(NULL), 164f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // TODO(nasko): The InterstitialPageImpl will need to provide its own 165f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // NavigationControllerImpl to the Navigator, which is separate from 166f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // the WebContents one, so we can enforce no navigation policy here. 167f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // While we get the code to a point to do this, pass NULL for it. 168f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // TODO(creis): We will also need to pass delegates for the RVHM as we 169f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // start to use it. 170a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) frame_tree_(new InterstitialPageNavigatorImpl(this, controller_), 1715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) this, this, this, 1725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) static_cast<WebContentsImpl*>(web_contents)), 1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) original_child_id_(web_contents->GetRenderProcessHost()->GetID()), 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) original_rvh_id_(web_contents->GetRenderViewHost()->GetRoutingID()), 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) should_revert_web_contents_title_(false), 1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) web_contents_was_loading_(false), 1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) resource_dispatcher_host_notified_(false), 178c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) rvh_delegate_view_(new InterstitialPageRVHDelegateView(this)), 1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) create_view_(true), 1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) delegate_(delegate), 181c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) weak_ptr_factory_(this) { 1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) InitInterstitialPageMap(); 1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // It would be inconsistent to create an interstitial with no new navigation 1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // (which is the case when the interstitial was triggered by a sub-resource on 1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // a page) when we have a pending entry (in the process of loading a new top 1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // frame). 1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DCHECK(new_navigation || !web_contents->GetController().GetPendingEntry()); 1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)InterstitialPageImpl::~InterstitialPageImpl() { 1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::Show() { 1942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (!enabled()) 1952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return; 1962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If an interstitial is already showing or about to be shown, close it before 1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // showing the new one. 1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Be careful not to take an action on the old interstitial more than once. 2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) InterstitialPageMap::const_iterator iter = 2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) g_web_contents_to_interstitial_page->find(web_contents_); 2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (iter != g_web_contents_to_interstitial_page->end()) { 2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) InterstitialPageImpl* interstitial = iter->second; 2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (interstitial->action_taken_ != NO_ACTION) { 2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) interstitial->Hide(); 2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } else { 2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If we are currently showing an interstitial page for which we created 2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // a transient entry and a new interstitial is shown as the result of a 2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // new browser initiated navigation, then that transient entry has already 2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // been discarded and a new pending navigation entry created. 2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // So we should not discard that new pending navigation entry. 2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // See http://crbug.com/9791 2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (new_navigation_ && interstitial->new_navigation_) 2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) interstitial->should_discard_pending_nav_entry_= false; 2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) interstitial->DontProceed(); 2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Block the resource requests for the render view host while it is hidden. 2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TakeActionOnResourceDispatcher(BLOCK); 2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // We need to be notified when the RenderViewHost is destroyed so we can 2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // cancel the blocked requests. We cannot do that on 2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // NOTIFY_WEB_CONTENTS_DESTROYED as at that point the RenderViewHost has 2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // already been destroyed. 2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) notification_registrar_.Add( 2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) this, NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, 2271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) Source<RenderWidgetHost>(controller_->delegate()->GetRenderViewHost())); 2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Update the g_web_contents_to_interstitial_page map. 2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) iter = g_web_contents_to_interstitial_page->find(web_contents_); 2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DCHECK(iter == g_web_contents_to_interstitial_page->end()); 2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) (*g_web_contents_to_interstitial_page)[web_contents_] = this; 2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (new_navigation_) { 2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NavigationEntryImpl* entry = new NavigationEntryImpl; 2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) entry->SetURL(url_); 2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) entry->SetVirtualURL(url_); 2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) entry->set_page_type(PAGE_TYPE_INTERSTITIAL); 2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Give delegates a chance to set some states on the navigation entry. 2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) delegate_->OverrideEntry(entry); 2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2431e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) controller_->SetTransientEntry(entry); 2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DCHECK(!render_view_host_); 2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) render_view_host_ = static_cast<RenderViewHostImpl*>(CreateRenderViewHost()); 2484e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) render_view_host_->AttachToFrameTree(); 2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CreateWebContentsView(); 2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string data_url = "data:text/html;charset=utf-8," + 2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) net::EscapePath(delegate_->GetHTMLContents()); 2531320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci frame_tree_.root()->current_frame_host()->NavigateToURL(GURL(data_url)); 2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) notification_registrar_.Add(this, NOTIFICATION_NAV_ENTRY_PENDING, 2561e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) Source<NavigationController>(controller_)); 2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::Hide() { 2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // We may have already been hidden, and are just waiting to be deleted. 2612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // We can't check for enabled() here, because some callers have already 2622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // called Disable. 2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!render_view_host_) 2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return; 2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Disable(); 2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) RenderWidgetHostView* old_view = 2691e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) controller_->delegate()->GetRenderViewHost()->GetView(); 2701e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (controller_->delegate()->GetInterstitialPage() == this && 2711e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) old_view && 2721e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) !old_view->IsShowing() && 2731e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) !controller_->delegate()->IsHidden()) { 2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Show the original RVH since we're going away. Note it might not exist if 2755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the renderer crashed while the interstitial was showing. 2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Note that it is important that we don't call Show() if the view is 2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // already showing. That would result in bad things (unparented HWND on 2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Windows for example) happening. 2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) old_view->Show(); 2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If the focus was on the interstitial, let's keep it to the page. 2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // (Note that in unit-tests the RVH may not have a view). 2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (render_view_host_->GetView() && 2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) render_view_host_->GetView()->HasFocus() && 2861e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) controller_->delegate()->GetRenderViewHost()->GetView()) { 287010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) controller_->delegate()->GetRenderViewHost()->GetView()->Focus(); 2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Delete this and call Shutdown on the RVH asynchronously, as we may have 2915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // been called from a RVH delegate method, and we can't delete the RVH out 2925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // from under itself. 293c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) base::MessageLoop::current()->PostNonNestableTask( 294c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) FROM_HERE, 2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::Bind(&InterstitialPageImpl::Shutdown, 2965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) weak_ptr_factory_.GetWeakPtr())); 2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) render_view_host_ = NULL; 2985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) frame_tree_.ResetForMainFrameSwap(); 2991e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) controller_->delegate()->DetachInterstitialPage(); 3005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Let's revert to the original title if necessary. 3011e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) NavigationEntry* entry = controller_->GetVisibleEntry(); 3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!new_navigation_ && should_revert_web_contents_title_) { 3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) entry->SetTitle(original_web_contents_title_); 3041e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) controller_->delegate()->NotifyNavigationStateChanged( 3051e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) INVALIDATE_TYPE_TITLE); 3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) InterstitialPageMap::iterator iter = 3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) g_web_contents_to_interstitial_page->find(web_contents_); 3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DCHECK(iter != g_web_contents_to_interstitial_page->end()); 3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (iter != g_web_contents_to_interstitial_page->end()) 3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) g_web_contents_to_interstitial_page->erase(iter); 3132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 3142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Clear the WebContents pointer, because it may now be deleted. 3152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // This signifies that we are in the process of shutting down. 3162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) web_contents_ = NULL; 3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::Observe( 3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int type, 3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const NotificationSource& source, 3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const NotificationDetails& details) { 3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) switch (type) { 3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) case NOTIFICATION_NAV_ENTRY_PENDING: 3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // We are navigating away from the interstitial (the user has typed a URL 3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // in the location bar or clicked a bookmark). Make sure clicking on the 3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // interstitial will have no effect. Also cancel any blocked requests 3285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // on the ResourceDispatcherHost. Note that when we get this notification 3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the RenderViewHost has not yet navigated so we'll unblock the 3305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // RenderViewHost before the resource request for the new page we are 3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // navigating arrives in the ResourceDispatcherHost. This ensures that 3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // request won't be blocked if the same RenderViewHost was used for the 3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // new navigation. 3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Disable(); 3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TakeActionOnResourceDispatcher(CANCEL); 3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) break; 3375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) case NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED: 3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (action_taken_ == NO_ACTION) { 3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The RenderViewHost is being destroyed (as part of the tab being 3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // closed); make sure we clear the blocked requests. 3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) RenderViewHost* rvh = static_cast<RenderViewHost*>( 3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static_cast<RenderViewHostImpl*>( 3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) RenderWidgetHostImpl::From( 3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Source<RenderWidgetHost>(source).ptr()))); 3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DCHECK(rvh->GetProcess()->GetID() == original_child_id_ && 3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rvh->GetRoutingID() == original_rvh_id_); 3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TakeActionOnResourceDispatcher(CANCEL); 3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) break; 3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) default: 3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NOTREACHED(); 3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 355868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)void InterstitialPageImpl::NavigationEntryCommitted( 356868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const LoadCommittedDetails& load_details) { 357868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) OnNavigatingAwayOrTabClosing(); 358868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} 359868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 360010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)void InterstitialPageImpl::WebContentsDestroyed() { 36190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) OnNavigatingAwayOrTabClosing(); 36290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 36390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 364cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)bool InterstitialPageImpl::OnMessageReceived( 365cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const IPC::Message& message, 366cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) RenderFrameHost* render_frame_host) { 367cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) return OnMessageReceived(message); 368cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)} 369cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 370a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool InterstitialPageImpl::OnMessageReceived(RenderFrameHost* render_frame_host, 371a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const IPC::Message& message) { 372a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return OnMessageReceived(message); 373a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 374a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 375a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool InterstitialPageImpl::OnMessageReceived(RenderViewHost* render_view_host, 376a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const IPC::Message& message) { 377a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return OnMessageReceived(message); 378a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 379a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 380a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool InterstitialPageImpl::OnMessageReceived(const IPC::Message& message) { 381a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 382a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool handled = true; 383cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) IPC_BEGIN_MESSAGE_MAP(InterstitialPageImpl, message) 384a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) IPC_MESSAGE_HANDLER(FrameHostMsg_DomOperationResponse, 385a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) OnDomOperationResponse) 386a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) IPC_MESSAGE_UNHANDLED(handled = false) 387cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) IPC_END_MESSAGE_MAP() 388a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 389a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return handled; 390a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 391a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 3925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void InterstitialPageImpl::RenderFrameCreated( 3935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) RenderFrameHost* render_frame_host) { 3945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Note this is only for subframes in the interstitial, the notification for 3955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // the main frame happens in RenderViewCreated. 3965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) controller_->delegate()->RenderFrameForInterstitialPageCreated( 3975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) render_frame_host); 3985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 3995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 400cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)void InterstitialPageImpl::UpdateTitle( 401cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) RenderFrameHost* render_frame_host, 402cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) int32 page_id, 403cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) const base::string16& title, 404cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) base::i18n::TextDirection title_direction) { 405cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) if (!enabled()) 406cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) return; 407cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 408cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) RenderViewHost* render_view_host = render_frame_host->GetRenderViewHost(); 409cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) DCHECK(render_view_host == render_view_host_); 410cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) NavigationEntry* entry = controller_->GetVisibleEntry(); 411cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) if (!entry) { 412cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // Crash reports from the field indicate this can be NULL. 413cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // This is unexpected as InterstitialPages constructed with the 414cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // new_navigation flag set to true create a transient navigation entry 415cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // (that is returned as the active entry). And the only case so far of 416cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // interstitial created with that flag set to false is with the 417cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // SafeBrowsingBlockingPage, when the resource triggering the interstitial 418cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // is a sub-resource, meaning the main page has already been loaded and a 419cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // navigation entry should have been created. 420cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) NOTREACHED(); 421cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) return; 422cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) } 423cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 424cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // If this interstitial is shown on an existing navigation entry, we'll need 425cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // to remember its title so we can revert to it when hidden. 426cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) if (!new_navigation_ && !should_revert_web_contents_title_) { 427cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) original_web_contents_title_ = entry->GetTitle(); 428cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) should_revert_web_contents_title_ = true; 429cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) } 430cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // TODO(evan): make use of title_direction. 431cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) // http://code.google.com/p/chromium/issues/detail?id=27094 432cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) entry->SetTitle(title); 433cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_TITLE); 434cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)} 435cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 436116680a4aac90f2aa7413d9095a592090648e557Ben MurdochAccessibilityMode InterstitialPageImpl::GetAccessibilityMode() const { 437116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch if (web_contents_) 438116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch return static_cast<WebContentsImpl*>(web_contents_)->GetAccessibilityMode(); 439116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch else 440116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch return AccessibilityModeOff; 441116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch} 442116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 4435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)RenderViewHostDelegateView* InterstitialPageImpl::GetDelegateView() { 4445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return rvh_delegate_view_.get(); 4455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 447c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdochconst GURL& InterstitialPageImpl::GetMainFrameLastCommittedURL() const { 4485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return url_; 4495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 451c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)void InterstitialPageImpl::RenderViewTerminated( 452c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) RenderViewHost* render_view_host, 453c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) base::TerminationStatus status, 454c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) int error_code) { 4555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Our renderer died. This should not happen in normal cases. 4562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // If we haven't already started shutdown, just dismiss the interstitial. 4572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // We cannot check for enabled() here, because we may have called Disable 4582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // without calling Hide. 4592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (render_view_host_) 4602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) DontProceed(); 4615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::DidNavigate( 4645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) RenderViewHost* render_view_host, 4655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { 4665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // A fast user could have navigated away from the page that triggered the 4675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // interstitial while the interstitial was loading, that would have disabled 4685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // us. In that case we can dismiss ourselves. 4692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (!enabled()) { 4705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DontProceed(); 4715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return; 4725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4731320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (ui::PageTransitionCoreTypeIs(params.transition, 4741320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci ui::PAGE_TRANSITION_AUTO_SUBFRAME)) { 4755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // No need to handle navigate message from iframe in the interstitial page. 4765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return; 4775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The RenderViewHost has loaded its contents, we can show it now. 4801e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) if (!controller_->delegate()->IsHidden()) 4818bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) render_view_host_->GetView()->Show(); 4821e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) controller_->delegate()->AttachInterstitialPage(this); 4835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) RenderWidgetHostView* rwh_view = 4851e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) controller_->delegate()->GetRenderViewHost()->GetView(); 4865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The RenderViewHost may already have crashed before we even get here. 4885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (rwh_view) { 4895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If the page has focus, focus the interstitial. 4905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (rwh_view->HasFocus()) 4915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Focus(); 4925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Hide the original RVH since we're showing the interstitial instead. 4945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) rwh_view->Hide(); 4955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Notify the tab we are not loading so the throbber is stopped. It also 4984e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // causes a WebContentsObserver::DidStopLoading callback that the 4994e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // AutomationProvider (used by the UI tests) expects to consider a navigation 5004e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // as complete. Without this, navigating in a UI test to a URL that triggers 5014e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // an interstitial would hang. 5021e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) web_contents_was_loading_ = controller_->delegate()->IsLoading(); 5031e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) controller_->delegate()->SetIsLoading( 504effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch controller_->delegate()->GetRenderViewHost(), false, true, NULL); 5055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)RendererPreferences InterstitialPageImpl::GetRendererPrefs( 5085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BrowserContext* browser_context) const { 5095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) delegate_->OverrideRendererPrefs(&renderer_preferences_); 5105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return renderer_preferences_; 5115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5136e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)WebPreferences InterstitialPageImpl::ComputeWebkitPrefs() { 5145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!enabled()) 515c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) return WebPreferences(); 5165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5176e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) return render_view_host_->ComputeWebkitPrefs(url_); 5185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::RenderWidgetDeleted( 5215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) RenderWidgetHostImpl* render_widget_host) { 5225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // TODO(creis): Remove this method once we verify the shutdown path is sane. 5235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CHECK(!web_contents_); 5245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool InterstitialPageImpl::PreHandleKeyboardEvent( 5275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const NativeWebKeyboardEvent& event, 5285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool* is_keyboard_shortcut) { 5292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (!enabled()) 5302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return false; 5311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) return render_widget_host_delegate_->PreHandleKeyboardEvent( 5321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) event, is_keyboard_shortcut); 5335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::HandleKeyboardEvent( 5365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const NativeWebKeyboardEvent& event) { 5372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (enabled()) 5381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) render_widget_host_delegate_->HandleKeyboardEvent(event); 5395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#if defined(OS_WIN) 542c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)gfx::NativeViewAccessible 543c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)InterstitialPageImpl::GetParentNativeViewAccessible() { 544116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch if (web_contents_) { 545116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch WebContentsImpl* wci = static_cast<WebContentsImpl*>(web_contents_); 546116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch return wci->GetParentNativeViewAccessible(); 547116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch } 548116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch return NULL; 549c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 550c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#endif 551c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) 5525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)WebContents* InterstitialPageImpl::web_contents() const { 5535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return web_contents_; 5545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)RenderViewHost* InterstitialPageImpl::CreateRenderViewHost() { 5572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (!enabled()) 5582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return NULL; 5592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 5605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Interstitial pages don't want to share the session storage so we mint a 5615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // new one. 5625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BrowserContext* browser_context = web_contents()->GetBrowserContext(); 5635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) scoped_refptr<SiteInstance> site_instance = 5645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SiteInstance::Create(browser_context); 565bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch DOMStorageContextWrapper* dom_storage_context = 566bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch static_cast<DOMStorageContextWrapper*>( 567bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch BrowserContext::GetStoragePartition( 568bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch browser_context, site_instance.get())->GetDOMStorageContext()); 569a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch session_storage_namespace_ = 5705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) new SessionStorageNamespaceImpl(dom_storage_context); 5715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Use the RenderViewHost from our FrameTree. 5735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) frame_tree_.root()->render_manager()->Init( 5745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) browser_context, site_instance.get(), MSG_ROUTING_NONE, MSG_ROUTING_NONE); 5755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return frame_tree_.root()->current_frame_host()->render_view_host(); 5765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)WebContentsView* InterstitialPageImpl::CreateWebContentsView() { 5795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!enabled() || !create_view_) 5805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return NULL; 581010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) WebContentsView* wcv = 582010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) static_cast<WebContentsImpl*>(web_contents())->GetView(); 583010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) RenderWidgetHostViewBase* view = 584010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) wcv->CreateViewForWidget(render_view_host_); 5855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) render_view_host_->SetView(view); 5865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) render_view_host_->AllowBindings(BINDINGS_POLICY_DOM_AUTOMATION); 5875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int32 max_page_id = web_contents()-> 5895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GetMaxPageIDForSiteInstance(render_view_host_->GetSiteInstance()); 590a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) render_view_host_->CreateRenderView(base::string16(), 5915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) MSG_ROUTING_NONE, 592cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) MSG_ROUTING_NONE, 5930529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch max_page_id, 5940529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch false); 5955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) controller_->delegate()->RenderFrameForInterstitialPageCreated( 5965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) frame_tree_.root()->current_frame_host()); 597010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) view->SetSize(web_contents()->GetContainerBounds().size()); 5985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Don't show the interstitial until we have navigated to it. 5995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) view->Hide(); 600010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) return wcv; 6015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::Proceed() { 6042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Don't repeat this if we are already shutting down. We cannot check for 6052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // enabled() here, because we may have called Disable without calling Hide. 6062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (!render_view_host_) 6072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return; 6082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (action_taken_ != NO_ACTION) { 6105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NOTREACHED(); 6115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return; 6125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 6135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Disable(); 6145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) action_taken_ = PROCEED_ACTION; 6155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Resumes the throbber, if applicable. 6175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (web_contents_was_loading_) 6181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) controller_->delegate()->SetIsLoading( 619effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch controller_->delegate()->GetRenderViewHost(), true, true, NULL); 6205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If this is a new navigation, the old page is going away, so we cancel any 6225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // blocked requests for it. If it is not a new navigation, then it means the 6235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // interstitial was shown as a result of a resource loading in the page. 6245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Since the user wants to proceed, we'll let any blocked request go through. 6255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (new_navigation_) 6265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TakeActionOnResourceDispatcher(CANCEL); 6275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) else 6285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TakeActionOnResourceDispatcher(RESUME); 6295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // No need to hide if we are a new navigation, we'll get hidden when the 6315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // navigation is committed. 6325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!new_navigation_) { 6335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Hide(); 6345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) delegate_->OnProceed(); 6355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return; 6365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 6375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) delegate_->OnProceed(); 6395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::DontProceed() { 6422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Don't repeat this if we are already shutting down. We cannot check for 6432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // enabled() here, because we may have called Disable without calling Hide. 6442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (!render_view_host_) 6452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return; 6465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DCHECK(action_taken_ != DONT_PROCEED_ACTION); 6475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Disable(); 6495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) action_taken_ = DONT_PROCEED_ACTION; 6505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If this is a new navigation, we are returning to the original page, so we 6525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // resume blocked requests for it. If it is not a new navigation, then it 6535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // means the interstitial was shown as a result of a resource loading in the 6545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // page and we won't return to the original page, so we cancel blocked 6555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // requests in that case. 6565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (new_navigation_) 6575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TakeActionOnResourceDispatcher(RESUME); 6585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) else 6595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TakeActionOnResourceDispatcher(CANCEL); 6605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (should_discard_pending_nav_entry_) { 6625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Since no navigation happens we have to discard the transient entry 6635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // explicitely. Note that by calling DiscardNonCommittedEntries() we also 6645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // discard the pending entry, which is what we want, since the navigation is 6655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // cancelled. 6661e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) controller_->DiscardNonCommittedEntries(); 6675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 6685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (reload_on_dont_proceed_) 6701e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) controller_->Reload(true); 6715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Hide(); 6735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) delegate_->OnDontProceed(); 6745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::CancelForNavigation() { 6775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The user is trying to navigate away. We should unblock the renderer and 6785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // disable the interstitial, but keep it visible until the navigation 6795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // completes. 6805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Disable(); 6815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If this interstitial was shown for a new navigation, allow any navigations 6825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // on the original page to resume (e.g., subresource requests, XHRs, etc). 6835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Otherwise, cancel the pending, possibly dangerous navigations. 6845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (new_navigation_) 6855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TakeActionOnResourceDispatcher(RESUME); 6865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) else 6875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TakeActionOnResourceDispatcher(CANCEL); 6885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::SetSize(const gfx::Size& size) { 6915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!enabled()) 6925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return; 6935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if !defined(OS_MACOSX) 6945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // When a tab is closed, we might be resized after our view was NULLed 6955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // (typically if there was an info-bar). 6965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (render_view_host_->GetView()) 6975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) render_view_host_->GetView()->SetSize(size); 6985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else 6995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(port): Does Mac need to SetSize? 7005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NOTIMPLEMENTED(); 7015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 7025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::Focus() { 7055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Focus the native window. 7065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!enabled()) 7075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return; 708010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) render_view_host_->GetView()->Focus(); 7095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::FocusThroughTabTraversal(bool reverse) { 7125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!enabled()) 7135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return; 7145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) render_view_host_->SetInitialFocus(reverse); 7155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)RenderWidgetHostView* InterstitialPageImpl::GetView() { 7182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return render_view_host_->GetView(); 7192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 7202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 7215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)RenderViewHost* InterstitialPageImpl::GetRenderViewHostForTesting() const { 7225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return render_view_host_; 7235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_ANDROID) 7265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)RenderViewHost* InterstitialPageImpl::GetRenderViewHost() const { 7275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return render_view_host_; 7285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 7305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)InterstitialPageDelegate* InterstitialPageImpl::GetDelegateForTesting() { 7325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return delegate_.get(); 7335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::DontCreateViewForTesting() { 7365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) create_view_ = false; 7375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)gfx::Rect InterstitialPageImpl::GetRootWindowResizerRect() const { 7405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return gfx::Rect(); 7415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::CreateNewWindow( 744a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) int render_process_id, 7455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int route_id, 746868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int main_frame_route_id, 7475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const ViewHostMsg_CreateWindow_Params& params, 7485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SessionStorageNamespace* session_storage_namespace) { 7495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NOTREACHED() << "InterstitialPage does not support showing popups yet."; 7505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 752a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)void InterstitialPageImpl::CreateNewWidget(int render_process_id, 753a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) int route_id, 754f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) blink::WebPopupType popup_type) { 7555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NOTREACHED() << "InterstitialPage does not support showing drop-downs yet."; 7565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 758a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)void InterstitialPageImpl::CreateNewFullscreenWidget(int render_process_id, 759a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) int route_id) { 7605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NOTREACHED() 7615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) << "InterstitialPage does not support showing full screen popups."; 7625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::ShowCreatedWindow(int route_id, 7655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WindowOpenDisposition disposition, 7665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Rect& initial_pos, 7675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool user_gesture) { 7685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NOTREACHED() << "InterstitialPage does not support showing popups yet."; 7695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::ShowCreatedWidget(int route_id, 7725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Rect& initial_pos) { 7735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NOTREACHED() << "InterstitialPage does not support showing drop-downs yet."; 7745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::ShowCreatedFullscreenWidget(int route_id) { 7775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NOTREACHED() 7785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) << "InterstitialPage does not support showing full screen popups."; 7795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 781a3f7b4e666c476898878fa745f637129375cd889Ben MurdochSessionStorageNamespace* InterstitialPageImpl::GetSessionStorageNamespace( 782a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch SiteInstance* instance) { 783a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch return session_storage_namespace_.get(); 784a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch} 785a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch 7864e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)FrameTree* InterstitialPageImpl::GetFrameTree() { 7874e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) return &frame_tree_; 7884e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)} 7894e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 7905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::Disable() { 7915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) enabled_ = false; 7925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void InterstitialPageImpl::Shutdown() { 7955d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) delete this; 7965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 79890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)void InterstitialPageImpl::OnNavigatingAwayOrTabClosing() { 79990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) if (action_taken_ == NO_ACTION) { 80090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // We are navigating away from the interstitial or closing a tab with an 80190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // interstitial. Default to DontProceed(). We don't just call Hide as 80290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // subclasses will almost certainly override DontProceed to do some work 80390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // (ex: close pending connections). 80490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) DontProceed(); 80590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } else { 80690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // User decided to proceed and either the navigation was committed or 80790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // the tab was closed before that. 80890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) Hide(); 80990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) } 81090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)} 81190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 8125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::TakeActionOnResourceDispatcher( 8135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ResourceRequestAction action) { 8145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)) << 8155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "TakeActionOnResourceDispatcher should be called on the main thread."; 8165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (action == CANCEL || action == RESUME) { 8185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (resource_dispatcher_host_notified_) 8195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return; 8205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) resource_dispatcher_host_notified_ = true; 8215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 8225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The tab might not have a render_view_host if it was closed (in which case, 8245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // we have taken care of the blocked requests when processing 8255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // NOTIFY_RENDER_WIDGET_HOST_DESTROYED. 8265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Also we need to test there is a ResourceDispatcherHostImpl, as when unit- 8275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // tests we don't have one. 8285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) RenderViewHostImpl* rvh = RenderViewHostImpl::FromID(original_child_id_, 8295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) original_rvh_id_); 8305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!rvh || !ResourceDispatcherHostImpl::Get()) 8315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return; 8325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BrowserThread::PostTask( 8345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BrowserThread::IO, 8355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) FROM_HERE, 8365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::Bind( 8375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) &ResourceRequestHelper, 8385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ResourceDispatcherHostImpl::Get(), 8395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) original_child_id_, 8405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) original_rvh_id_, 8415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) action)); 8425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 8435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 844a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void InterstitialPageImpl::OnDomOperationResponse( 845a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const std::string& json_string, 846a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) int automation_id) { 847a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Needed by test code. 848a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) DomOperationNotificationDetails details(json_string, automation_id); 849a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) NotificationService::current()->Notify( 850a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) NOTIFICATION_DOM_OPERATION_RESPONSE, 851a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) Source<WebContents>(web_contents()), 852a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) Details<DomOperationNotificationDetails>(&details)); 853a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 854a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (!enabled()) 855a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return; 856a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) delegate_->CommandReceived(details.json); 857a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 858a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 859a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 8605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)InterstitialPageImpl::InterstitialPageRVHDelegateView:: 8615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) InterstitialPageRVHDelegateView(InterstitialPageImpl* page) 8625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) : interstitial_page_(page) { 8635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 8645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 865effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#if defined(OS_MACOSX) || defined(OS_ANDROID) 8665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::InterstitialPageRVHDelegateView::ShowPopupMenu( 8671320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci RenderFrameHost* render_frame_host, 8685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Rect& bounds, 8695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int item_height, 8705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) double item_font_size, 8715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int selected_item, 8727dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch const std::vector<MenuItem>& items, 8735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool right_aligned, 8745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool allow_multiple_selection) { 8755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NOTREACHED() << "InterstitialPage does not support showing popup menus."; 8765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 8775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 878effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochvoid InterstitialPageImpl::InterstitialPageRVHDelegateView::HidePopupMenu() { 879effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch NOTREACHED() << "InterstitialPage does not support showing popup menus."; 880effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch} 881effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#endif 882effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch 8835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::InterstitialPageRVHDelegateView::StartDragging( 884eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch const DropData& drop_data, 8855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WebDragOperationsMask allowed_operations, 8865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::ImageSkia& image, 8875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Vector2d& image_offset, 8885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const DragEventSourceInfo& event_info) { 8895c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu interstitial_page_->render_view_host_->DragSourceSystemDragEnded(); 8905c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu DVLOG(1) << "InterstitialPage does not support dragging yet."; 8915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 8925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::InterstitialPageRVHDelegateView::UpdateDragCursor( 8945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WebDragOperation) { 8955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NOTREACHED() << "InterstitialPage does not support dragging yet."; 8965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 8975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::InterstitialPageRVHDelegateView::GotFocus() { 899c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) WebContents* web_contents = interstitial_page_->web_contents(); 900c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) if (web_contents && web_contents->GetDelegate()) 901c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) web_contents->GetDelegate()->WebContentsFocused(web_contents); 9025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 9035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::InterstitialPageRVHDelegateView::TakeFocus( 9055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool reverse) { 9065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!interstitial_page_->web_contents()) 9075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return; 9085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WebContentsImpl* web_contents = 9095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static_cast<WebContentsImpl*>(interstitial_page_->web_contents()); 9105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!web_contents->GetDelegateView()) 9115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return; 9125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) web_contents->GetDelegateView()->TakeFocus(reverse); 9145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 9155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void InterstitialPageImpl::InterstitialPageRVHDelegateView::OnFindReply( 9175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int request_id, int number_of_matches, const gfx::Rect& selection_rect, 9185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int active_match_ordinal, bool final_update) { 9195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 9205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace content 922