summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-25 00:33:08 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-25 00:33:08 +0000
commit594840002d3d0d4052408a7db36574cb0512ede7 (patch)
tree3a61afea75a021e6410ce8113638c88cfebe490b /chrome/browser/tab_contents
parent29d8897984da1d8948471e68c3b6514ede4f21c8 (diff)
downloadchromium_src-594840002d3d0d4052408a7db36574cb0512ede7.zip
chromium_src-594840002d3d0d4052408a7db36574cb0512ede7.tar.gz
chromium_src-594840002d3d0d4052408a7db36574cb0512ede7.tar.bz2
This make accelerators work in interstitial pages.
Interstitial pages are RVH whose view is shown on top of the actual tab. Some more work is required to make find in page work. BUG=7056 TEST=Open an page that triggers an interstitial (ex: https://ebay.com), press CTRL-T, a new tab should be opened. Review URL: http://codereview.chromium.org/21298 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10316 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r--chrome/browser/tab_contents/interstitial_page.cc101
-rw-r--r--chrome/browser/tab_contents/interstitial_page.h6
2 files changed, 105 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;