Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Side by Side Diff: chrome/browser/tab_contents/interstitial_page.cc

Issue 21298: Make accelerators work in interstitial pages (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/tab_contents/interstitial_page.h" 5 #include "chrome/browser/tab_contents/interstitial_page.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/thread.h" 8 #include "base/thread.h"
9 #include "chrome/browser/browser.h" 9 #include "chrome/browser/browser.h"
10 #include "chrome/browser/browser_list.h" 10 #include "chrome/browser/browser_list.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 ResourceRequestAction action_; 59 ResourceRequestAction action_;
60 int process_id_; 60 int process_id_;
61 int render_view_host_id_; 61 int render_view_host_id_;
62 ResourceDispatcherHost* resource_dispatcher_host_; 62 ResourceDispatcherHost* resource_dispatcher_host_;
63 63
64 DISALLOW_COPY_AND_ASSIGN(ResourceRequestTask); 64 DISALLOW_COPY_AND_ASSIGN(ResourceRequestTask);
65 }; 65 };
66 66
67 } // namespace 67 } // namespace
68 68
69 class InterstitialPage::InterstitialPageRVHViewDelegate
70 : public RenderViewHostDelegate::View {
71 public:
72 explicit InterstitialPageRVHViewDelegate(InterstitialPage* page);
73
74 // RenderViewHostDelegate::View implementation:
75 virtual void CreateNewWindow(int route_id,
76 base::WaitableEvent* modal_dialog_event);
77 virtual void CreateNewWidget(int route_id, bool activatable);
78 virtual void ShowCreatedWindow(int route_id,
79 WindowOpenDisposition disposition,
80 const gfx::Rect& initial_pos,
81 bool user_gesture);
82 virtual void ShowCreatedWidget(int route_id,
83 const gfx::Rect& initial_pos);
84 virtual void ShowContextMenu(const ContextMenuParams& params);
85 virtual void StartDragging(const WebDropData& drop_data);
86 virtual void UpdateDragCursor(bool is_drop_target);
87 virtual void TakeFocus(bool reverse);
88 virtual void HandleKeyboardEvent(const WebKeyboardEvent& event);
89 virtual void OnFindReply(int request_id,
90 int number_of_matches,
91 const gfx::Rect& selection_rect,
92 int active_match_ordinal,
93 bool final_update);
94
95 private:
96 InterstitialPage* interstitial_page_;
97
98 DISALLOW_COPY_AND_ASSIGN(InterstitialPageRVHViewDelegate);
99 };
100
69 // static 101 // static
70 InterstitialPage::InterstitialPageMap* 102 InterstitialPage::InterstitialPageMap*
71 InterstitialPage::tab_to_interstitial_page_ = NULL; 103 InterstitialPage::tab_to_interstitial_page_ = NULL;
72 104
73 InterstitialPage::InterstitialPage(WebContents* tab, 105 InterstitialPage::InterstitialPage(WebContents* tab,
74 bool new_navigation, 106 bool new_navigation,
75 const GURL& url) 107 const GURL& url)
76 : tab_(tab), 108 : tab_(tab),
77 url_(url), 109 url_(url),
78 action_taken_(false), 110 action_taken_(false),
79 enabled_(true), 111 enabled_(true),
80 new_navigation_(new_navigation), 112 new_navigation_(new_navigation),
81 original_rvh_process_id_(tab->render_view_host()->process()->host_id()), 113 original_rvh_process_id_(tab->render_view_host()->process()->host_id()),
82 original_rvh_id_(tab->render_view_host()->routing_id()), 114 original_rvh_id_(tab->render_view_host()->routing_id()),
83 render_view_host_(NULL), 115 render_view_host_(NULL),
84 resource_dispatcher_host_notified_(false), 116 resource_dispatcher_host_notified_(false),
85 should_revert_tab_title_(false), 117 should_revert_tab_title_(false),
86 ui_loop_(MessageLoop::current()) { 118 ui_loop_(MessageLoop::current()),
119 rvh_view_delegate_(new InterstitialPageRVHViewDelegate(this)) {
87 InitInterstitialPageMap(); 120 InitInterstitialPageMap();
88 // It would be inconsistent to create an interstitial with no new navigation 121 // It would be inconsistent to create an interstitial with no new navigation
89 // (which is the case when the interstitial was triggered by a sub-resource on 122 // (which is the case when the interstitial was triggered by a sub-resource on
90 // a page) when we have a pending entry (in the process of loading a new top 123 // a page) when we have a pending entry (in the process of loading a new top
91 // frame). 124 // frame).
92 DCHECK(new_navigation || !tab->controller()->GetPendingEntry()); 125 DCHECK(new_navigation || !tab->controller()->GetPendingEntry());
93 } 126 }
94 127
95 InterstitialPage::~InterstitialPage() { 128 InterstitialPage::~InterstitialPage() {
96 InterstitialPageMap::iterator iter = tab_to_interstitial_page_->find(tab_); 129 InterstitialPageMap::iterator iter = tab_to_interstitial_page_->find(tab_);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 // discard the pending entry, which is what we want, since the navigation is 313 // discard the pending entry, which is what we want, since the navigation is
281 // cancelled. 314 // cancelled.
282 tab_->controller()->DiscardNonCommittedEntries(); 315 tab_->controller()->DiscardNonCommittedEntries();
283 } 316 }
284 317
285 Hide(); 318 Hide();
286 // WARNING: we are now deleted! 319 // WARNING: we are now deleted!
287 } 320 }
288 321
289 void InterstitialPage::SetSize(const gfx::Size& size) { 322 void InterstitialPage::SetSize(const gfx::Size& size) {
290 render_view_host_->view()->SetSize(size); 323 // When a tab is closed, we might be resized after our view was NULLed
324 // (typically if there was an info-bar).
325 if (render_view_host_->view())
326 render_view_host_->view()->SetSize(size);
291 } 327 }
292 328
293 Profile* InterstitialPage::GetProfile() const { 329 Profile* InterstitialPage::GetProfile() const {
294 return tab_->profile(); 330 return tab_->profile();
295 } 331 }
296 332
297 void InterstitialPage::DidNavigate( 333 void InterstitialPage::DidNavigate(
298 RenderViewHost* render_view_host, 334 RenderViewHost* render_view_host,
299 const ViewHostMsg_FrameNavigate_Params& params) { 335 const ViewHostMsg_FrameNavigate_Params& params) {
300 // A fast user could have navigated away from the page that triggered the 336 // A fast user could have navigated away from the page that triggered the
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 // If this interstitial is shown on an existing navigation entry, we'll need 372 // If this interstitial is shown on an existing navigation entry, we'll need
337 // to remember its title so we can revert to it when hidden. 373 // to remember its title so we can revert to it when hidden.
338 if (!new_navigation_ && !should_revert_tab_title_) { 374 if (!new_navigation_ && !should_revert_tab_title_) {
339 original_tab_title_ = entry->title(); 375 original_tab_title_ = entry->title();
340 should_revert_tab_title_ = true; 376 should_revert_tab_title_ = true;
341 } 377 }
342 entry->set_title(title); 378 entry->set_title(title);
343 tab_->NotifyNavigationStateChanged(TabContents::INVALIDATE_TITLE); 379 tab_->NotifyNavigationStateChanged(TabContents::INVALIDATE_TITLE);
344 } 380 }
345 381
382 RenderViewHostDelegate::View* InterstitialPage::GetViewDelegate() const {
383 return rvh_view_delegate_.get();
384 }
385
346 void InterstitialPage::Disable() { 386 void InterstitialPage::Disable() {
347 enabled_ = false; 387 enabled_ = false;
348 } 388 }
349 389
350 void InterstitialPage::TakeActionOnResourceDispatcher( 390 void InterstitialPage::TakeActionOnResourceDispatcher(
351 ResourceRequestAction action) { 391 ResourceRequestAction action) {
352 DCHECK(MessageLoop::current() == ui_loop_) << 392 DCHECK(MessageLoop::current() == ui_loop_) <<
353 "TakeActionOnResourceDispatcher should be called on the main thread."; 393 "TakeActionOnResourceDispatcher should be called on the main thread.";
354 394
355 if (action == CANCEL || action == RESUME) { 395 if (action == CANCEL || action == RESUME) {
(...skipping 28 matching lines...) Expand all
384 WebContents* web_contents) { 424 WebContents* web_contents) {
385 InitInterstitialPageMap(); 425 InitInterstitialPageMap();
386 InterstitialPageMap::const_iterator iter = 426 InterstitialPageMap::const_iterator iter =
387 tab_to_interstitial_page_->find(web_contents); 427 tab_to_interstitial_page_->find(web_contents);
388 if (iter == tab_to_interstitial_page_->end()) 428 if (iter == tab_to_interstitial_page_->end())
389 return NULL; 429 return NULL;
390 430
391 return iter->second; 431 return iter->second;
392 } 432 }
393 433
434 InterstitialPage::InterstitialPageRVHViewDelegate::
435 InterstitialPageRVHViewDelegate(InterstitialPage* page)
436 : interstitial_page_(page) {
437 }
438
439 void InterstitialPage::InterstitialPageRVHViewDelegate::CreateNewWindow(
440 int route_id, base::WaitableEvent* modal_dialog_event) {
441 NOTREACHED() << "InterstitialPage does not support showing popups yet.";
442 }
443
444 void InterstitialPage::InterstitialPageRVHViewDelegate::CreateNewWidget(
445 int route_id, bool activatable) {
446 NOTREACHED() << "InterstitialPage does not support showing drop-downs yet.";
447 }
448
449 void InterstitialPage::InterstitialPageRVHViewDelegate::ShowCreatedWindow(
450 int route_id, WindowOpenDisposition disposition,
451 const gfx::Rect& initial_pos, bool user_gesture) {
452 NOTREACHED() << "InterstitialPage does not support showing popups yet.";
453 }
454
455 void InterstitialPage::InterstitialPageRVHViewDelegate::ShowCreatedWidget(
456 int route_id, const gfx::Rect& initial_pos) {
457 NOTREACHED() << "InterstitialPage does not support showing drop-downs yet.";
458 }
459
460 void InterstitialPage::InterstitialPageRVHViewDelegate::ShowContextMenu(
461 const ContextMenuParams& params) {
462 }
463
464 void InterstitialPage::InterstitialPageRVHViewDelegate::StartDragging(
465 const WebDropData& drop_data) {
466 NOTREACHED() << "InterstitialPage does not support dragging yet.";
467 }
468
469 void InterstitialPage::InterstitialPageRVHViewDelegate::UpdateDragCursor(
470 bool is_drop_target) {
471 NOTREACHED() << "InterstitialPage does not support dragging yet.";
472 }
473
474 void InterstitialPage::InterstitialPageRVHViewDelegate::TakeFocus(
475 bool reverse) {
476 if (interstitial_page_->tab() && interstitial_page_->tab()->GetViewDelegate())
477 interstitial_page_->tab()->GetViewDelegate()->TakeFocus(reverse);
478 }
479
480 void InterstitialPage::InterstitialPageRVHViewDelegate::HandleKeyboardEvent(
481 const WebKeyboardEvent& event) {
482 if (interstitial_page_->tab() && interstitial_page_->tab()->GetViewDelegate())
483 interstitial_page_->tab()->GetViewDelegate()->HandleKeyboardEvent(event);
484 }
485
486 void InterstitialPage::InterstitialPageRVHViewDelegate::OnFindReply(
487 int request_id, int number_of_matches, const gfx::Rect& selection_rect,
488 int active_match_ordinal, bool final_update) {
489 }
490
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/interstitial_page.h ('k') | chrome/browser/views/tab_contents_container_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698