| 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.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "content/browser/dom_storage/dom_storage_context_impl.h" |
| 16 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
| 15 #include "content/browser/renderer_host/render_process_host_impl.h" | 17 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 16 #include "content/browser/renderer_host/render_view_host_impl.h" | 18 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 17 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" | 19 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" |
| 18 #include "content/browser/site_instance_impl.h" | 20 #include "content/browser/site_instance_impl.h" |
| 19 #include "content/browser/web_contents/navigation_controller_impl.h" | 21 #include "content/browser/web_contents/navigation_controller_impl.h" |
| 20 #include "content/browser/web_contents/navigation_entry_impl.h" | 22 #include "content/browser/web_contents/navigation_entry_impl.h" |
| 21 #include "content/browser/web_contents/web_contents_impl.h" | 23 #include "content/browser/web_contents/web_contents_impl.h" |
| 22 #include "content/common/view_messages.h" | 24 #include "content/common/view_messages.h" |
| 23 #include "content/port/browser/render_view_host_delegate_view.h" | 25 #include "content/port/browser/render_view_host_delegate_view.h" |
| 24 #include "content/port/browser/render_widget_host_view_port.h" | 26 #include "content/port/browser/render_widget_host_view_port.h" |
| 27 #include "content/public/browser/browser_context.h" |
| 25 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
| 29 #include "content/public/browser/content_browser_client.h" |
| 26 #include "content/public/browser/dom_operation_notification_details.h" | 30 #include "content/public/browser/dom_operation_notification_details.h" |
| 27 #include "content/public/browser/interstitial_page_delegate.h" | 31 #include "content/public/browser/interstitial_page_delegate.h" |
| 28 #include "content/public/browser/invalidate_type.h" | 32 #include "content/public/browser/invalidate_type.h" |
| 29 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
| 30 #include "content/public/browser/notification_source.h" | 34 #include "content/public/browser/notification_source.h" |
| 31 #include "content/public/browser/web_contents_view.h" | 35 #include "content/public/browser/web_contents_view.h" |
| 32 #include "content/public/common/bindings_policy.h" | 36 #include "content/public/common/bindings_policy.h" |
| 33 #include "content/public/common/page_transition_types.h" | 37 #include "content/public/common/page_transition_types.h" |
| 34 #include "net/base/escape.h" | 38 #include "net/base/escape.h" |
| 35 #include "net/url_request/url_request_context_getter.h" | 39 #include "net/url_request/url_request_context_getter.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 224 |
| 221 if (new_navigation_) { | 225 if (new_navigation_) { |
| 222 NavigationEntryImpl* entry = new NavigationEntryImpl; | 226 NavigationEntryImpl* entry = new NavigationEntryImpl; |
| 223 entry->SetURL(url_); | 227 entry->SetURL(url_); |
| 224 entry->SetVirtualURL(url_); | 228 entry->SetVirtualURL(url_); |
| 225 entry->set_page_type(content::PAGE_TYPE_INTERSTITIAL); | 229 entry->set_page_type(content::PAGE_TYPE_INTERSTITIAL); |
| 226 | 230 |
| 227 // Give delegates a chance to set some states on the navigation entry. | 231 // Give delegates a chance to set some states on the navigation entry. |
| 228 delegate_->OverrideEntry(entry); | 232 delegate_->OverrideEntry(entry); |
| 229 | 233 |
| 230 web_contents_->GetControllerImpl().AddTransientEntry(entry); | 234 web_contents_->GetController().AddTransientEntry(entry); |
| 231 } | 235 } |
| 232 | 236 |
| 233 DCHECK(!render_view_host_); | 237 DCHECK(!render_view_host_); |
| 234 render_view_host_ = static_cast<RenderViewHostImpl*>(CreateRenderViewHost()); | 238 render_view_host_ = static_cast<RenderViewHostImpl*>(CreateRenderViewHost()); |
| 235 CreateWebContentsView(); | 239 CreateWebContentsView(); |
| 236 | 240 |
| 237 std::string data_url = "data:text/html;charset=utf-8," + | 241 std::string data_url = "data:text/html;charset=utf-8," + |
| 238 net::EscapePath(delegate_->GetHTMLContents()); | 242 net::EscapePath(delegate_->GetHTMLContents()); |
| 239 render_view_host_->NavigateToURL(GURL(data_url)); | 243 render_view_host_->NavigateToURL(GURL(data_url)); |
| 240 | 244 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 void InterstitialPageImpl::HandleKeyboardEvent( | 474 void InterstitialPageImpl::HandleKeyboardEvent( |
| 471 const NativeWebKeyboardEvent& event) { | 475 const NativeWebKeyboardEvent& event) { |
| 472 return web_contents_->HandleKeyboardEvent(event); | 476 return web_contents_->HandleKeyboardEvent(event); |
| 473 } | 477 } |
| 474 | 478 |
| 475 WebContents* InterstitialPageImpl::web_contents() const { | 479 WebContents* InterstitialPageImpl::web_contents() const { |
| 476 return web_contents_; | 480 return web_contents_; |
| 477 } | 481 } |
| 478 | 482 |
| 479 RenderViewHost* InterstitialPageImpl::CreateRenderViewHost() { | 483 RenderViewHost* InterstitialPageImpl::CreateRenderViewHost() { |
| 484 // Interstitial pages don't want to share the session storage so we mint a |
| 485 // new one. |
| 486 using content::BrowserContext; |
| 487 BrowserContext* browser_context = web_contents()->GetBrowserContext(); |
| 488 scoped_refptr<SiteInstance> site_instance = |
| 489 SiteInstance::Create(browser_context); |
| 490 const std::string& partition_id = |
| 491 content::GetContentClient()->browser()-> |
| 492 GetStoragePartitionIdForSiteInstance(browser_context, |
| 493 site_instance); |
| 494 DOMStorageContextImpl* dom_storage_context = |
| 495 static_cast<DOMStorageContextImpl*>( |
| 496 BrowserContext::GetDOMStorageContextByPartitionId(browser_context, |
| 497 partition_id)); |
| 498 SessionStorageNamespaceImpl* session_storage_namespace_impl = |
| 499 new SessionStorageNamespaceImpl(dom_storage_context); |
| 500 |
| 480 RenderViewHostImpl* render_view_host = new RenderViewHostImpl( | 501 RenderViewHostImpl* render_view_host = new RenderViewHostImpl( |
| 481 SiteInstance::Create(web_contents()->GetBrowserContext()), this, this, | 502 site_instance, this, this, MSG_ROUTING_NONE, false, |
| 482 MSG_ROUTING_NONE, false, NULL); | 503 session_storage_namespace_impl); |
| 483 web_contents_->RenderViewForInterstitialPageCreated(render_view_host); | 504 web_contents_->RenderViewForInterstitialPageCreated(render_view_host); |
| 484 return render_view_host; | 505 return render_view_host; |
| 485 } | 506 } |
| 486 | 507 |
| 487 WebContentsView* InterstitialPageImpl::CreateWebContentsView() { | 508 WebContentsView* InterstitialPageImpl::CreateWebContentsView() { |
| 488 if (!create_view_) | 509 if (!create_view_) |
| 489 return NULL; | 510 return NULL; |
| 490 WebContentsView* web_contents_view = web_contents()->GetView(); | 511 WebContentsView* web_contents_view = web_contents()->GetView(); |
| 491 RenderWidgetHostView* view = | 512 RenderWidgetHostView* view = |
| 492 web_contents_view->CreateViewForWidget(render_view_host_); | 513 web_contents_view->CreateViewForWidget(render_view_host_); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 if (!web_contents->GetDelegateView()) | 758 if (!web_contents->GetDelegateView()) |
| 738 return; | 759 return; |
| 739 | 760 |
| 740 web_contents->GetDelegateView()->TakeFocus(reverse); | 761 web_contents->GetDelegateView()->TakeFocus(reverse); |
| 741 } | 762 } |
| 742 | 763 |
| 743 void InterstitialPageImpl::InterstitialPageRVHDelegateView::OnFindReply( | 764 void InterstitialPageImpl::InterstitialPageRVHDelegateView::OnFindReply( |
| 744 int request_id, int number_of_matches, const gfx::Rect& selection_rect, | 765 int request_id, int number_of_matches, const gfx::Rect& selection_rect, |
| 745 int active_match_ordinal, bool final_update) { | 766 int active_match_ordinal, bool final_update) { |
| 746 } | 767 } |
| OLD | NEW |