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 "chrome/browser/prerender/prerender_contents.h" | 5 #include "chrome/browser/prerender/prerender_contents.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 it != pending_prerenders_.end(); | 204 it != pending_prerenders_.end(); |
205 ++it) { | 205 ++it) { |
206 if (it->weak_prerender_handle.get() == &prerender_handle) | 206 if (it->weak_prerender_handle.get() == &prerender_handle) |
207 return true; | 207 return true; |
208 } | 208 } |
209 return false; | 209 return false; |
210 } | 210 } |
211 | 211 |
212 void PrerenderContents::StartPendingPrerenders() { | 212 void PrerenderContents::StartPendingPrerenders() { |
213 SessionStorageNamespace* session_storage_namespace = NULL; | 213 SessionStorageNamespace* session_storage_namespace = NULL; |
214 if (RenderViewHost* render_view_host = GetRenderViewHostMutable()) | 214 if (prerender_contents_.get()) { |
215 session_storage_namespace = render_view_host->GetSessionStorageNamespace(); | 215 // TODO(ajwong): This does not correctly handle storage for isolated apps. |
| 216 session_storage_namespace = |
| 217 prerender_contents_->web_contents()->GetController() |
| 218 .GetDefaultSessionStorageNamespace(); |
| 219 } |
216 DCHECK(child_id_ == -1 || session_storage_namespace); | 220 DCHECK(child_id_ == -1 || session_storage_namespace); |
217 | 221 |
218 std::vector<PendingPrerenderInfo> pending_prerender_list; | 222 std::vector<PendingPrerenderInfo> pending_prerender_list; |
219 pending_prerender_list.swap(pending_prerenders_); | 223 pending_prerender_list.swap(pending_prerenders_); |
220 for (std::vector<PendingPrerenderInfo>::iterator it = | 224 for (std::vector<PendingPrerenderInfo>::iterator it = |
221 pending_prerender_list.begin(); | 225 pending_prerender_list.begin(); |
222 it != pending_prerender_list.end(); | 226 it != pending_prerender_list.end(); |
223 ++it) { | 227 ++it) { |
224 if (it->weak_prerender_handle && it->weak_prerender_handle->IsValid()) { | 228 if (it->weak_prerender_handle && it->weak_prerender_handle->IsValid()) { |
225 prerender_manager_->StartPendingPrerender( | 229 prerender_manager_->StartPendingPrerender( |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 break; | 497 break; |
494 } | 498 } |
495 } | 499 } |
496 | 500 |
497 void PrerenderContents::OnRenderViewHostCreated( | 501 void PrerenderContents::OnRenderViewHostCreated( |
498 RenderViewHost* new_render_view_host) { | 502 RenderViewHost* new_render_view_host) { |
499 } | 503 } |
500 | 504 |
501 WebContents* PrerenderContents::CreateWebContents( | 505 WebContents* PrerenderContents::CreateWebContents( |
502 SessionStorageNamespace* session_storage_namespace) { | 506 SessionStorageNamespace* session_storage_namespace) { |
503 return WebContents::Create(profile_, NULL, MSG_ROUTING_NONE, NULL, | 507 // TODO(ajwong): Remove the temporary map once prerendering is aware of |
504 session_storage_namespace); | 508 // multiple session storage namespaces per tab. |
| 509 content::SessionStorageNamespaceMap session_storage_namespace_map; |
| 510 session_storage_namespace_map[""] = session_storage_namespace; |
| 511 return WebContents::CreateWithSessionStorage( |
| 512 profile_, NULL, MSG_ROUTING_NONE, NULL, session_storage_namespace_map); |
505 } | 513 } |
506 | 514 |
507 void PrerenderContents::OnUpdateFaviconURL( | 515 void PrerenderContents::OnUpdateFaviconURL( |
508 int32 page_id, | 516 int32 page_id, |
509 const std::vector<FaviconURL>& urls) { | 517 const std::vector<FaviconURL>& urls) { |
510 VLOG(1) << "PrerenderContents::OnUpdateFaviconURL" << icon_url_; | 518 VLOG(1) << "PrerenderContents::OnUpdateFaviconURL" << icon_url_; |
511 for (std::vector<FaviconURL>::const_iterator it = urls.begin(); | 519 for (std::vector<FaviconURL>::const_iterator it = urls.begin(); |
512 it != urls.end(); ++it) { | 520 it != urls.end(); ++it) { |
513 if (it->icon_type == FaviconURL::FAVICON) { | 521 if (it->icon_type == FaviconURL::FAVICON) { |
514 icon_url_ = it->icon_url; | 522 icon_url_ = it->icon_url; |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 bool PrerenderContents::IsCrossSiteNavigationPending() const { | 715 bool PrerenderContents::IsCrossSiteNavigationPending() const { |
708 if (!prerender_contents_.get() || !prerender_contents_->web_contents()) | 716 if (!prerender_contents_.get() || !prerender_contents_->web_contents()) |
709 return false; | 717 return false; |
710 const WebContents* web_contents = prerender_contents_->web_contents(); | 718 const WebContents* web_contents = prerender_contents_->web_contents(); |
711 return (web_contents->GetSiteInstance() != | 719 return (web_contents->GetSiteInstance() != |
712 web_contents->GetPendingSiteInstance()); | 720 web_contents->GetPendingSiteInstance()); |
713 } | 721 } |
714 | 722 |
715 | 723 |
716 } // namespace prerender | 724 } // namespace prerender |
OLD | NEW |