| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/web_contents/interstitial_page_impl.h" | 5 #include "content/browser/web_contents/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" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 15 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" | 15 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" |
| 16 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 16 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
| 17 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 17 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 18 #include "content/browser/renderer_host/render_process_host_impl.h" | 18 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 19 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 19 #include "content/browser/renderer_host/render_view_host_impl.h" | 20 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 20 #include "content/browser/site_instance_impl.h" | 21 #include "content/browser/site_instance_impl.h" |
| 21 #include "content/browser/web_contents/navigation_controller_impl.h" | 22 #include "content/browser/web_contents/navigation_controller_impl.h" |
| 22 #include "content/browser/web_contents/navigation_entry_impl.h" | 23 #include "content/browser/web_contents/navigation_entry_impl.h" |
| 23 #include "content/browser/web_contents/web_contents_impl.h" | 24 #include "content/browser/web_contents/web_contents_impl.h" |
| 24 #include "content/common/view_messages.h" | 25 #include "content/common/view_messages.h" |
| 25 #include "content/port/browser/render_view_host_delegate_view.h" | 26 #include "content/port/browser/render_view_host_delegate_view.h" |
| 26 #include "content/port/browser/render_widget_host_view_port.h" | 27 #include "content/port/browser/render_widget_host_view_port.h" |
| 27 #include "content/port/browser/web_contents_view_port.h" | 28 #include "content/port/browser/web_contents_view_port.h" |
| 28 #include "content/public/browser/browser_context.h" | 29 #include "content/public/browser/browser_context.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 entry->set_page_type(PAGE_TYPE_INTERSTITIAL); | 213 entry->set_page_type(PAGE_TYPE_INTERSTITIAL); |
| 213 | 214 |
| 214 // Give delegates a chance to set some states on the navigation entry. | 215 // Give delegates a chance to set some states on the navigation entry. |
| 215 delegate_->OverrideEntry(entry); | 216 delegate_->OverrideEntry(entry); |
| 216 | 217 |
| 217 web_contents_->GetController().SetTransientEntry(entry); | 218 web_contents_->GetController().SetTransientEntry(entry); |
| 218 } | 219 } |
| 219 | 220 |
| 220 DCHECK(!render_view_host_); | 221 DCHECK(!render_view_host_); |
| 221 render_view_host_ = static_cast<RenderViewHostImpl*>(CreateRenderViewHost()); | 222 render_view_host_ = static_cast<RenderViewHostImpl*>(CreateRenderViewHost()); |
| 223 render_view_host_->AttachToFrameTree(); |
| 222 CreateWebContentsView(); | 224 CreateWebContentsView(); |
| 223 | 225 |
| 224 std::string data_url = "data:text/html;charset=utf-8," + | 226 std::string data_url = "data:text/html;charset=utf-8," + |
| 225 net::EscapePath(delegate_->GetHTMLContents()); | 227 net::EscapePath(delegate_->GetHTMLContents()); |
| 226 render_view_host_->NavigateToURL(GURL(data_url)); | 228 render_view_host_->NavigateToURL(GURL(data_url)); |
| 227 | 229 |
| 228 notification_registrar_.Add(this, NOTIFICATION_NAV_ENTRY_PENDING, | 230 notification_registrar_.Add(this, NOTIFICATION_NAV_ENTRY_PENDING, |
| 229 Source<NavigationController>(&web_contents_->GetController())); | 231 Source<NavigationController>(&web_contents_->GetController())); |
| 230 notification_registrar_.Add( | 232 notification_registrar_.Add( |
| 231 this, NOTIFICATION_DOM_OPERATION_RESPONSE, | 233 this, NOTIFICATION_DOM_OPERATION_RESPONSE, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 } | 265 } |
| 264 | 266 |
| 265 // Shutdown the RVH asynchronously, as we may have been called from a RVH | 267 // Shutdown the RVH asynchronously, as we may have been called from a RVH |
| 266 // delegate method, and we can't delete the RVH out from under itself. | 268 // delegate method, and we can't delete the RVH out from under itself. |
| 267 base::MessageLoop::current()->PostNonNestableTask( | 269 base::MessageLoop::current()->PostNonNestableTask( |
| 268 FROM_HERE, | 270 FROM_HERE, |
| 269 base::Bind(&InterstitialPageImpl::Shutdown, | 271 base::Bind(&InterstitialPageImpl::Shutdown, |
| 270 weak_ptr_factory_.GetWeakPtr(), | 272 weak_ptr_factory_.GetWeakPtr(), |
| 271 render_view_host_)); | 273 render_view_host_)); |
| 272 render_view_host_ = NULL; | 274 render_view_host_ = NULL; |
| 275 frame_tree_.SwapMainFrame(NULL); |
| 273 web_contents_->DetachInterstitialPage(); | 276 web_contents_->DetachInterstitialPage(); |
| 274 // Let's revert to the original title if necessary. | 277 // Let's revert to the original title if necessary. |
| 275 NavigationEntry* entry = web_contents_->GetController().GetActiveEntry(); | 278 NavigationEntry* entry = web_contents_->GetController().GetActiveEntry(); |
| 276 if (!new_navigation_ && should_revert_web_contents_title_) { | 279 if (!new_navigation_ && should_revert_web_contents_title_) { |
| 277 entry->SetTitle(original_web_contents_title_); | 280 entry->SetTitle(original_web_contents_title_); |
| 278 web_contents_->NotifyNavigationStateChanged(INVALIDATE_TYPE_TITLE); | 281 web_contents_->NotifyNavigationStateChanged(INVALIDATE_TYPE_TITLE); |
| 279 } | 282 } |
| 280 | 283 |
| 281 InterstitialPageMap::iterator iter = | 284 InterstitialPageMap::iterator iter = |
| 282 g_web_contents_to_interstitial_page->find(web_contents_); | 285 g_web_contents_to_interstitial_page->find(web_contents_); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 BrowserContext* browser_context = web_contents()->GetBrowserContext(); | 493 BrowserContext* browser_context = web_contents()->GetBrowserContext(); |
| 491 scoped_refptr<SiteInstance> site_instance = | 494 scoped_refptr<SiteInstance> site_instance = |
| 492 SiteInstance::Create(browser_context); | 495 SiteInstance::Create(browser_context); |
| 493 DOMStorageContextWrapper* dom_storage_context = | 496 DOMStorageContextWrapper* dom_storage_context = |
| 494 static_cast<DOMStorageContextWrapper*>( | 497 static_cast<DOMStorageContextWrapper*>( |
| 495 BrowserContext::GetStoragePartition( | 498 BrowserContext::GetStoragePartition( |
| 496 browser_context, site_instance.get())->GetDOMStorageContext()); | 499 browser_context, site_instance.get())->GetDOMStorageContext()); |
| 497 session_storage_namespace_ = | 500 session_storage_namespace_ = |
| 498 new SessionStorageNamespaceImpl(dom_storage_context); | 501 new SessionStorageNamespaceImpl(dom_storage_context); |
| 499 | 502 |
| 500 RenderViewHostImpl* render_view_host = | 503 RenderViewHost* render_view_host = |
| 501 new RenderViewHostImpl(site_instance.get(), | 504 RenderViewHostFactory::Create(site_instance.get(), |
| 502 this, | 505 this, |
| 503 this, | 506 this, |
| 504 MSG_ROUTING_NONE, | 507 MSG_ROUTING_NONE, |
| 505 MSG_ROUTING_NONE, | 508 MSG_ROUTING_NONE, |
| 506 false, | 509 false, |
| 507 false); | 510 false); |
| 508 web_contents_->RenderViewForInterstitialPageCreated(render_view_host); | 511 web_contents_->RenderViewForInterstitialPageCreated(render_view_host); |
| 509 return render_view_host; | 512 return render_view_host; |
| 510 } | 513 } |
| 511 | 514 |
| 512 WebContentsView* InterstitialPageImpl::CreateWebContentsView() { | 515 WebContentsView* InterstitialPageImpl::CreateWebContentsView() { |
| 513 if (!enabled() || !create_view_) | 516 if (!enabled() || !create_view_) |
| 514 return NULL; | 517 return NULL; |
| 515 WebContentsView* web_contents_view = web_contents()->GetView(); | 518 WebContentsView* web_contents_view = web_contents()->GetView(); |
| 516 WebContentsViewPort* web_contents_view_port = | 519 WebContentsViewPort* web_contents_view_port = |
| 517 static_cast<WebContentsViewPort*>(web_contents_view); | 520 static_cast<WebContentsViewPort*>(web_contents_view); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 void InterstitialPageImpl::ShowCreatedFullscreenWidget(int route_id) { | 706 void InterstitialPageImpl::ShowCreatedFullscreenWidget(int route_id) { |
| 704 NOTREACHED() | 707 NOTREACHED() |
| 705 << "InterstitialPage does not support showing full screen popups."; | 708 << "InterstitialPage does not support showing full screen popups."; |
| 706 } | 709 } |
| 707 | 710 |
| 708 SessionStorageNamespace* InterstitialPageImpl::GetSessionStorageNamespace( | 711 SessionStorageNamespace* InterstitialPageImpl::GetSessionStorageNamespace( |
| 709 SiteInstance* instance) { | 712 SiteInstance* instance) { |
| 710 return session_storage_namespace_.get(); | 713 return session_storage_namespace_.get(); |
| 711 } | 714 } |
| 712 | 715 |
| 716 FrameTree* InterstitialPageImpl::GetFrameTree() { |
| 717 return &frame_tree_; |
| 718 } |
| 719 |
| 713 void InterstitialPageImpl::Disable() { | 720 void InterstitialPageImpl::Disable() { |
| 714 enabled_ = false; | 721 enabled_ = false; |
| 715 } | 722 } |
| 716 | 723 |
| 717 void InterstitialPageImpl::Shutdown(RenderViewHostImpl* render_view_host) { | 724 void InterstitialPageImpl::Shutdown(RenderViewHostImpl* render_view_host) { |
| 718 render_view_host->Shutdown(); | 725 render_view_host->Shutdown(); |
| 719 // We are deleted now. | 726 // We are deleted now. |
| 720 } | 727 } |
| 721 | 728 |
| 722 void InterstitialPageImpl::OnNavigatingAwayOrTabClosing() { | 729 void InterstitialPageImpl::OnNavigatingAwayOrTabClosing() { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 | 819 |
| 813 web_contents->GetDelegateView()->TakeFocus(reverse); | 820 web_contents->GetDelegateView()->TakeFocus(reverse); |
| 814 } | 821 } |
| 815 | 822 |
| 816 void InterstitialPageImpl::InterstitialPageRVHDelegateView::OnFindReply( | 823 void InterstitialPageImpl::InterstitialPageRVHDelegateView::OnFindReply( |
| 817 int request_id, int number_of_matches, const gfx::Rect& selection_rect, | 824 int request_id, int number_of_matches, const gfx::Rect& selection_rect, |
| 818 int active_match_ordinal, bool final_update) { | 825 int active_match_ordinal, bool final_update) { |
| 819 } | 826 } |
| 820 | 827 |
| 821 } // namespace content | 828 } // namespace content |
| OLD | NEW |