diff options
-rw-r--r-- | chrome/browser/tab_contents/interstitial_page.cc | 101 | ||||
-rw-r--r-- | chrome/browser/tab_contents/interstitial_page.h | 6 | ||||
-rw-r--r-- | chrome/browser/views/tab_contents_container_view.cc | 4 |
3 files changed, 109 insertions, 2 deletions
diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc index efd911a..cb9fe98 100644 --- a/chrome/browser/tab_contents/interstitial_page.cc +++ b/chrome/browser/tab_contents/interstitial_page.cc @@ -67,6 +67,38 @@ class ResourceRequestTask : public Task { } // namespace +class InterstitialPage::InterstitialPageRVHViewDelegate + : public RenderViewHostDelegate::View { + public: + explicit InterstitialPageRVHViewDelegate(InterstitialPage* page); + + // RenderViewHostDelegate::View implementation: + virtual void CreateNewWindow(int route_id, + base::WaitableEvent* modal_dialog_event); + virtual void CreateNewWidget(int route_id, bool activatable); + virtual void ShowCreatedWindow(int route_id, + WindowOpenDisposition disposition, + const gfx::Rect& initial_pos, + bool user_gesture); + virtual void ShowCreatedWidget(int route_id, + const gfx::Rect& initial_pos); + virtual void ShowContextMenu(const ContextMenuParams& params); + virtual void StartDragging(const WebDropData& drop_data); + virtual void UpdateDragCursor(bool is_drop_target); + virtual void TakeFocus(bool reverse); + virtual void HandleKeyboardEvent(const WebKeyboardEvent& event); + virtual void OnFindReply(int request_id, + int number_of_matches, + const gfx::Rect& selection_rect, + int active_match_ordinal, + bool final_update); + + private: + InterstitialPage* interstitial_page_; + + DISALLOW_COPY_AND_ASSIGN(InterstitialPageRVHViewDelegate); +}; + // static InterstitialPage::InterstitialPageMap* InterstitialPage::tab_to_interstitial_page_ = NULL; @@ -84,7 +116,8 @@ InterstitialPage::InterstitialPage(WebContents* tab, original_rvh_id_(tab->render_view_host()->routing_id()), should_revert_tab_title_(false), resource_dispatcher_host_notified_(false), - ui_loop_(MessageLoop::current()) { + ui_loop_(MessageLoop::current()), + rvh_view_delegate_(new InterstitialPageRVHViewDelegate(this)) { InitInterstitialPageMap(); // It would be inconsistent to create an interstitial with no new navigation // (which is the case when the interstitial was triggered by a sub-resource on @@ -297,7 +330,10 @@ void InterstitialPage::DontProceed() { void InterstitialPage::SetSize(const gfx::Size& size) { #if defined(OS_WIN) - render_view_host_->view()->SetSize(size); + // When a tab is closed, we might be resized after our view was NULLed + // (typically if there was an info-bar). + if (render_view_host_->view()) + render_view_host_->view()->SetSize(size); #else // TODO(port): do Mac or Linux need to SetSize? NOTIMPLEMENTED(); @@ -362,6 +398,10 @@ void InterstitialPage::UpdateTitle(RenderViewHost* render_view_host, tab_->NotifyNavigationStateChanged(TabContents::INVALIDATE_TITLE); } +RenderViewHostDelegate::View* InterstitialPage::GetViewDelegate() const { + return rvh_view_delegate_.get(); +} + void InterstitialPage::Disable() { enabled_ = false; } @@ -410,3 +450,60 @@ InterstitialPage* InterstitialPage::GetInterstitialPage( return iter->second; } +InterstitialPage::InterstitialPageRVHViewDelegate:: + InterstitialPageRVHViewDelegate(InterstitialPage* page) + : interstitial_page_(page) { +} + +void InterstitialPage::InterstitialPageRVHViewDelegate::CreateNewWindow( + int route_id, base::WaitableEvent* modal_dialog_event) { + NOTREACHED() << "InterstitialPage does not support showing popups yet."; +} + +void InterstitialPage::InterstitialPageRVHViewDelegate::CreateNewWidget( + int route_id, bool activatable) { + NOTREACHED() << "InterstitialPage does not support showing drop-downs yet."; +} + +void InterstitialPage::InterstitialPageRVHViewDelegate::ShowCreatedWindow( + int route_id, WindowOpenDisposition disposition, + const gfx::Rect& initial_pos, bool user_gesture) { + NOTREACHED() << "InterstitialPage does not support showing popups yet."; +} + +void InterstitialPage::InterstitialPageRVHViewDelegate::ShowCreatedWidget( + int route_id, const gfx::Rect& initial_pos) { + NOTREACHED() << "InterstitialPage does not support showing drop-downs yet."; +} + +void InterstitialPage::InterstitialPageRVHViewDelegate::ShowContextMenu( + const ContextMenuParams& params) { +} + +void InterstitialPage::InterstitialPageRVHViewDelegate::StartDragging( + const WebDropData& drop_data) { + NOTREACHED() << "InterstitialPage does not support dragging yet."; +} + +void InterstitialPage::InterstitialPageRVHViewDelegate::UpdateDragCursor( + bool is_drop_target) { + NOTREACHED() << "InterstitialPage does not support dragging yet."; +} + +void InterstitialPage::InterstitialPageRVHViewDelegate::TakeFocus( + bool reverse) { + if (interstitial_page_->tab() && interstitial_page_->tab()->GetViewDelegate()) + interstitial_page_->tab()->GetViewDelegate()->TakeFocus(reverse); +} + +void InterstitialPage::InterstitialPageRVHViewDelegate::HandleKeyboardEvent( + const WebKeyboardEvent& event) { + if (interstitial_page_->tab() && interstitial_page_->tab()->GetViewDelegate()) + interstitial_page_->tab()->GetViewDelegate()->HandleKeyboardEvent(event); +} + +void InterstitialPage::InterstitialPageRVHViewDelegate::OnFindReply( + int request_id, int number_of_matches, const gfx::Rect& selection_rect, + int active_match_ordinal, bool final_update) { +} + diff --git a/chrome/browser/tab_contents/interstitial_page.h b/chrome/browser/tab_contents/interstitial_page.h index 2fee13b..f6fe1ee 100644 --- a/chrome/browser/tab_contents/interstitial_page.h +++ b/chrome/browser/tab_contents/interstitial_page.h @@ -92,6 +92,7 @@ class InterstitialPage : public NotificationObserver, virtual void UpdateTitle(RenderViewHost* render_view_host, int32 page_id, const std::wstring& title); + virtual View* GetViewDelegate() const; // Invoked when the page sent a command through DOMAutomation. virtual void CommandReceived(const std::string& command) { } @@ -116,6 +117,8 @@ class InterstitialPage : public NotificationObserver, // user actions. friend class AutomationProvider; + class InterstitialPageRVHViewDelegate; + // Initializes tab_to_interstitial_page_ in a thread-safe manner. // Should be called before accessing tab_to_interstitial_page_. static void InitInterstitialPageMap(); @@ -170,6 +173,9 @@ class InterstitialPage : public NotificationObserver, MessageLoop* ui_loop_; + // Our RenderViewHostViewDelegate, necessary for accelerators to work. + scoped_ptr<InterstitialPageRVHViewDelegate> rvh_view_delegate_; + // We keep a map of the various blocking pages shown as the UI tests need to // be able to retrieve them. typedef std::map<WebContents*,InterstitialPage*> InterstitialPageMap; diff --git a/chrome/browser/views/tab_contents_container_view.cc b/chrome/browser/views/tab_contents_container_view.cc index 6c8e0c3..f8261704 100644 --- a/chrome/browser/views/tab_contents_container_view.cc +++ b/chrome/browser/views/tab_contents_container_view.cc @@ -178,6 +178,10 @@ bool TabContentsContainerView::GetAccessibleRole(VARIANT* role) { bool TabContentsContainerView::ShouldLookupAccelerators( const views::KeyEvent& e) { + // Don't look-up accelerators if we are showing a non-crashed WebContents. + // We'll first give the page a chance to process the key events. If it does + // not process them, they'll be returned to us and we'll treat them as + // accelerators then. if (tab_contents_ && !tab_contents_->is_crashed() && tab_contents_->AsWebContents()) return false; |