OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 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 "content/browser/frame_host/interstitial_page_impl.h" | 5 #include "content/browser/frame_host/interstitial_page_impl.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 enabled_(true), | 155 enabled_(true), |
156 action_taken_(NO_ACTION), | 156 action_taken_(NO_ACTION), |
157 render_view_host_(NULL), | 157 render_view_host_(NULL), |
158 // TODO(nasko): The InterstitialPageImpl will need to provide its own | 158 // TODO(nasko): The InterstitialPageImpl will need to provide its own |
159 // NavigationControllerImpl to the Navigator, which is separate from | 159 // NavigationControllerImpl to the Navigator, which is separate from |
160 // the WebContents one, so we can enforce no navigation policy here. | 160 // the WebContents one, so we can enforce no navigation policy here. |
161 // While we get the code to a point to do this, pass NULL for it. | 161 // While we get the code to a point to do this, pass NULL for it. |
162 // TODO(creis): We will also need to pass delegates for the RVHM as we | 162 // TODO(creis): We will also need to pass delegates for the RVHM as we |
163 // start to use it. | 163 // start to use it. |
164 frame_tree_(new InterstitialPageNavigatorImpl(this, controller_), | 164 frame_tree_(new InterstitialPageNavigatorImpl(this, controller_), |
165 this, this, this, NULL), | 165 NULL, NULL, NULL, NULL), |
166 original_child_id_(web_contents->GetRenderProcessHost()->GetID()), | 166 original_child_id_(web_contents->GetRenderProcessHost()->GetID()), |
167 original_rvh_id_(web_contents->GetRenderViewHost()->GetRoutingID()), | 167 original_rvh_id_(web_contents->GetRenderViewHost()->GetRoutingID()), |
168 should_revert_web_contents_title_(false), | 168 should_revert_web_contents_title_(false), |
169 web_contents_was_loading_(false), | 169 web_contents_was_loading_(false), |
170 resource_dispatcher_host_notified_(false), | 170 resource_dispatcher_host_notified_(false), |
171 rvh_delegate_view_(new InterstitialPageRVHDelegateView(this)), | 171 rvh_delegate_view_(new InterstitialPageRVHDelegateView(this)), |
172 create_view_(true), | 172 create_view_(true), |
173 delegate_(delegate), | 173 delegate_(delegate), |
174 weak_ptr_factory_(this) { | 174 weak_ptr_factory_(this) { |
175 InitInterstitialPageMap(); | 175 InitInterstitialPageMap(); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 277 |
278 // If the focus was on the interstitial, let's keep it to the page. | 278 // If the focus was on the interstitial, let's keep it to the page. |
279 // (Note that in unit-tests the RVH may not have a view). | 279 // (Note that in unit-tests the RVH may not have a view). |
280 if (render_view_host_->GetView() && | 280 if (render_view_host_->GetView() && |
281 render_view_host_->GetView()->HasFocus() && | 281 render_view_host_->GetView()->HasFocus() && |
282 controller_->delegate()->GetRenderViewHost()->GetView()) { | 282 controller_->delegate()->GetRenderViewHost()->GetView()) { |
283 RenderWidgetHostViewPort::FromRWHV( | 283 RenderWidgetHostViewPort::FromRWHV( |
284 controller_->delegate()->GetRenderViewHost()->GetView())->Focus(); | 284 controller_->delegate()->GetRenderViewHost()->GetView())->Focus(); |
285 } | 285 } |
286 | 286 |
287 // Delete this and call Shutdown on the RVH asynchronously, as we may have | 287 // Shutdown the RVH asynchronously, as we may have been called from a RVH |
288 // been called from a RVH delegate method, and we can't delete the RVH out | 288 // delegate method, and we can't delete the RVH out from under itself. |
289 // from under itself. | |
290 base::MessageLoop::current()->PostNonNestableTask( | 289 base::MessageLoop::current()->PostNonNestableTask( |
291 FROM_HERE, | 290 FROM_HERE, |
292 base::Bind(&InterstitialPageImpl::Shutdown, | 291 base::Bind(&InterstitialPageImpl::Shutdown, |
293 weak_ptr_factory_.GetWeakPtr())); | 292 weak_ptr_factory_.GetWeakPtr(), |
| 293 render_view_host_)); |
294 render_view_host_ = NULL; | 294 render_view_host_ = NULL; |
295 frame_tree_.ResetForMainFrameSwap(); | 295 frame_tree_.SwapMainFrame(NULL); |
296 controller_->delegate()->DetachInterstitialPage(); | 296 controller_->delegate()->DetachInterstitialPage(); |
297 // Let's revert to the original title if necessary. | 297 // Let's revert to the original title if necessary. |
298 NavigationEntry* entry = controller_->GetVisibleEntry(); | 298 NavigationEntry* entry = controller_->GetVisibleEntry(); |
299 if (!new_navigation_ && should_revert_web_contents_title_) { | 299 if (!new_navigation_ && should_revert_web_contents_title_) { |
300 entry->SetTitle(original_web_contents_title_); | 300 entry->SetTitle(original_web_contents_title_); |
301 controller_->delegate()->NotifyNavigationStateChanged( | 301 controller_->delegate()->NotifyNavigationStateChanged( |
302 INVALIDATE_TYPE_TITLE); | 302 INVALIDATE_TYPE_TITLE); |
303 } | 303 } |
304 | 304 |
305 InterstitialPageMap::iterator iter = | 305 InterstitialPageMap::iterator iter = |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 | 472 |
473 WebPreferences InterstitialPageImpl::GetWebkitPrefs() { | 473 WebPreferences InterstitialPageImpl::GetWebkitPrefs() { |
474 if (!enabled()) | 474 if (!enabled()) |
475 return WebPreferences(); | 475 return WebPreferences(); |
476 | 476 |
477 return render_view_host_->GetWebkitPrefs(url_); | 477 return render_view_host_->GetWebkitPrefs(url_); |
478 } | 478 } |
479 | 479 |
480 void InterstitialPageImpl::RenderWidgetDeleted( | 480 void InterstitialPageImpl::RenderWidgetDeleted( |
481 RenderWidgetHostImpl* render_widget_host) { | 481 RenderWidgetHostImpl* render_widget_host) { |
482 // TODO(creis): Remove this method once we verify the shutdown path is sane. | 482 delete this; |
483 CHECK(!web_contents_); | |
484 } | 483 } |
485 | 484 |
486 bool InterstitialPageImpl::PreHandleKeyboardEvent( | 485 bool InterstitialPageImpl::PreHandleKeyboardEvent( |
487 const NativeWebKeyboardEvent& event, | 486 const NativeWebKeyboardEvent& event, |
488 bool* is_keyboard_shortcut) { | 487 bool* is_keyboard_shortcut) { |
489 if (!enabled()) | 488 if (!enabled()) |
490 return false; | 489 return false; |
491 return render_widget_host_delegate_->PreHandleKeyboardEvent( | 490 return render_widget_host_delegate_->PreHandleKeyboardEvent( |
492 event, is_keyboard_shortcut); | 491 event, is_keyboard_shortcut); |
493 } | 492 } |
(...skipping 24 matching lines...) Expand all Loading... |
518 BrowserContext* browser_context = web_contents()->GetBrowserContext(); | 517 BrowserContext* browser_context = web_contents()->GetBrowserContext(); |
519 scoped_refptr<SiteInstance> site_instance = | 518 scoped_refptr<SiteInstance> site_instance = |
520 SiteInstance::Create(browser_context); | 519 SiteInstance::Create(browser_context); |
521 DOMStorageContextWrapper* dom_storage_context = | 520 DOMStorageContextWrapper* dom_storage_context = |
522 static_cast<DOMStorageContextWrapper*>( | 521 static_cast<DOMStorageContextWrapper*>( |
523 BrowserContext::GetStoragePartition( | 522 BrowserContext::GetStoragePartition( |
524 browser_context, site_instance.get())->GetDOMStorageContext()); | 523 browser_context, site_instance.get())->GetDOMStorageContext()); |
525 session_storage_namespace_ = | 524 session_storage_namespace_ = |
526 new SessionStorageNamespaceImpl(dom_storage_context); | 525 new SessionStorageNamespaceImpl(dom_storage_context); |
527 | 526 |
528 // Use the RenderViewHost from our FrameTree. | 527 return RenderViewHostFactory::Create(site_instance.get(), |
529 frame_tree_.root()->render_manager()->Init( | 528 this, |
530 browser_context, site_instance.get(), MSG_ROUTING_NONE, MSG_ROUTING_NONE); | 529 this, |
531 return frame_tree_.root()->current_frame_host()->render_view_host(); | 530 this, |
| 531 MSG_ROUTING_NONE, |
| 532 MSG_ROUTING_NONE, |
| 533 false, |
| 534 false); |
532 } | 535 } |
533 | 536 |
534 WebContentsView* InterstitialPageImpl::CreateWebContentsView() { | 537 WebContentsView* InterstitialPageImpl::CreateWebContentsView() { |
535 if (!enabled() || !create_view_) | 538 if (!enabled() || !create_view_) |
536 return NULL; | 539 return NULL; |
537 WebContentsView* web_contents_view = web_contents()->GetView(); | 540 WebContentsView* web_contents_view = web_contents()->GetView(); |
538 WebContentsViewPort* web_contents_view_port = | 541 WebContentsViewPort* web_contents_view_port = |
539 static_cast<WebContentsViewPort*>(web_contents_view); | 542 static_cast<WebContentsViewPort*>(web_contents_view); |
540 RenderWidgetHostView* view = | 543 RenderWidgetHostView* view = |
541 web_contents_view_port->CreateViewForWidget(render_view_host_); | 544 web_contents_view_port->CreateViewForWidget(render_view_host_); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 } | 742 } |
740 | 743 |
741 FrameTree* InterstitialPageImpl::GetFrameTree() { | 744 FrameTree* InterstitialPageImpl::GetFrameTree() { |
742 return &frame_tree_; | 745 return &frame_tree_; |
743 } | 746 } |
744 | 747 |
745 void InterstitialPageImpl::Disable() { | 748 void InterstitialPageImpl::Disable() { |
746 enabled_ = false; | 749 enabled_ = false; |
747 } | 750 } |
748 | 751 |
749 void InterstitialPageImpl::Shutdown() { | 752 void InterstitialPageImpl::Shutdown(RenderViewHostImpl* render_view_host) { |
750 delete this; | 753 render_view_host->Shutdown(); |
| 754 // We are deleted now. |
751 } | 755 } |
752 | 756 |
753 void InterstitialPageImpl::OnNavigatingAwayOrTabClosing() { | 757 void InterstitialPageImpl::OnNavigatingAwayOrTabClosing() { |
754 if (action_taken_ == NO_ACTION) { | 758 if (action_taken_ == NO_ACTION) { |
755 // We are navigating away from the interstitial or closing a tab with an | 759 // We are navigating away from the interstitial or closing a tab with an |
756 // interstitial. Default to DontProceed(). We don't just call Hide as | 760 // interstitial. Default to DontProceed(). We don't just call Hide as |
757 // subclasses will almost certainly override DontProceed to do some work | 761 // subclasses will almost certainly override DontProceed to do some work |
758 // (ex: close pending connections). | 762 // (ex: close pending connections). |
759 DontProceed(); | 763 DontProceed(); |
760 } else { | 764 } else { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 | 847 |
844 web_contents->GetDelegateView()->TakeFocus(reverse); | 848 web_contents->GetDelegateView()->TakeFocus(reverse); |
845 } | 849 } |
846 | 850 |
847 void InterstitialPageImpl::InterstitialPageRVHDelegateView::OnFindReply( | 851 void InterstitialPageImpl::InterstitialPageRVHDelegateView::OnFindReply( |
848 int request_id, int number_of_matches, const gfx::Rect& selection_rect, | 852 int request_id, int number_of_matches, const gfx::Rect& selection_rect, |
849 int active_match_ordinal, bool final_update) { | 853 int active_match_ordinal, bool final_update) { |
850 } | 854 } |
851 | 855 |
852 } // namespace content | 856 } // namespace content |
OLD | NEW |