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 |
11 #include "base/process_util.h" | 11 #include "base/process_util.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/history/history_tab_helper.h" | 13 #include "chrome/browser/history/history_tab_helper.h" |
14 #include "chrome/browser/history/history_types.h" | 14 #include "chrome/browser/history/history_types.h" |
15 #include "chrome/browser/prerender/prerender_final_status.h" | 15 #include "chrome/browser/prerender/prerender_final_status.h" |
16 #include "chrome/browser/prerender/prerender_handle.h" | 16 #include "chrome/browser/prerender/prerender_handle.h" |
17 #include "chrome/browser/prerender/prerender_manager.h" | 17 #include "chrome/browser/prerender/prerender_manager.h" |
18 #include "chrome/browser/prerender/prerender_render_view_host_observer.h" | 18 #include "chrome/browser/prerender/prerender_render_view_host_observer.h" |
19 #include "chrome/browser/prerender/prerender_tracker.h" | 19 #include "chrome/browser/prerender/prerender_tracker.h" |
20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 21 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
22 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
23 #include "chrome/common/icon_messages.h" | |
24 #include "chrome/common/prerender_messages.h" | 23 #include "chrome/common/prerender_messages.h" |
25 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
26 #include "content/public/browser/browser_child_process_host.h" | 25 #include "content/public/browser/browser_child_process_host.h" |
27 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
28 #include "content/public/browser/render_process_host.h" | 27 #include "content/public/browser/render_process_host.h" |
29 #include "content/public/browser/render_view_host.h" | 28 #include "content/public/browser/render_view_host.h" |
30 #include "content/public/browser/resource_request_details.h" | 29 #include "content/public/browser/resource_request_details.h" |
31 #include "content/public/browser/session_storage_namespace.h" | 30 #include "content/public/browser/session_storage_namespace.h" |
32 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
33 #include "content/public/browser/web_contents_delegate.h" | 32 #include "content/public/browser/web_contents_delegate.h" |
34 #include "content/public/browser/web_contents_view.h" | 33 #include "content/public/browser/web_contents_view.h" |
| 34 #include "content/public/common/favicon_url.h" |
35 #include "ui/gfx/rect.h" | 35 #include "ui/gfx/rect.h" |
36 | 36 |
37 using content::DownloadItem; | 37 using content::DownloadItem; |
38 using content::OpenURLParams; | 38 using content::OpenURLParams; |
39 using content::RenderViewHost; | 39 using content::RenderViewHost; |
40 using content::ResourceRedirectDetails; | 40 using content::ResourceRedirectDetails; |
41 using content::SessionStorageNamespace; | 41 using content::SessionStorageNamespace; |
42 using content::WebContents; | 42 using content::WebContents; |
43 | 43 |
44 namespace prerender { | 44 namespace prerender { |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 | 305 |
306 prerendering_has_started_ = true; | 306 prerendering_has_started_ = true; |
307 | 307 |
308 WebContents* new_contents = CreateWebContents(session_storage_namespace); | 308 WebContents* new_contents = CreateWebContents(session_storage_namespace); |
309 prerender_contents_.reset( | 309 prerender_contents_.reset( |
310 TabContents::Factory::CreateTabContents(new_contents)); | 310 TabContents::Factory::CreateTabContents(new_contents)); |
311 content::WebContentsObserver::Observe(new_contents); | 311 content::WebContentsObserver::Observe(new_contents); |
312 | 312 |
313 tab_contents_delegate_.reset(new TabContentsDelegateImpl(this)); | 313 tab_contents_delegate_.reset(new TabContentsDelegateImpl(this)); |
314 new_contents->SetDelegate(tab_contents_delegate_.get()); | 314 new_contents->SetDelegate(tab_contents_delegate_.get()); |
315 | 315 new_contents->RegisterFaviconDelegate(this); |
316 // Set the size of the prerender WebContents. | 316 // Set the size of the prerender WebContents. |
317 prerender_contents_->web_contents()->GetView()->SizeContents(size_); | 317 prerender_contents_->web_contents()->GetView()->SizeContents(size_); |
318 | 318 |
319 // Register as an observer of the RenderViewHost so we get messages. | 319 // Register as an observer of the RenderViewHost so we get messages. |
320 render_view_host_observer_.reset( | 320 render_view_host_observer_.reset( |
321 new PrerenderRenderViewHostObserver(this, GetRenderViewHostMutable())); | 321 new PrerenderRenderViewHostObserver(this, GetRenderViewHostMutable())); |
322 | 322 |
323 child_id_ = GetRenderViewHost()->GetProcess()->GetID(); | 323 child_id_ = GetRenderViewHost()->GetProcess()->GetID(); |
324 route_id_ = GetRenderViewHost()->GetRoutingID(); | 324 route_id_ = GetRenderViewHost()->GetRoutingID(); |
325 | 325 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 WebContents* PrerenderContents::CreateWebContents( | 490 WebContents* PrerenderContents::CreateWebContents( |
491 SessionStorageNamespace* session_storage_namespace) { | 491 SessionStorageNamespace* session_storage_namespace) { |
492 // TODO(ajwong): Remove the temporary map once prerendering is aware of | 492 // TODO(ajwong): Remove the temporary map once prerendering is aware of |
493 // multiple session storage namespaces per tab. | 493 // multiple session storage namespaces per tab. |
494 content::SessionStorageNamespaceMap session_storage_namespace_map; | 494 content::SessionStorageNamespaceMap session_storage_namespace_map; |
495 session_storage_namespace_map[""] = session_storage_namespace; | 495 session_storage_namespace_map[""] = session_storage_namespace; |
496 return WebContents::CreateWithSessionStorage( | 496 return WebContents::CreateWithSessionStorage( |
497 profile_, NULL, MSG_ROUTING_NONE, NULL, session_storage_namespace_map); | 497 profile_, NULL, MSG_ROUTING_NONE, NULL, session_storage_namespace_map); |
498 } | 498 } |
499 | 499 |
500 void PrerenderContents::OnUpdateFaviconURL( | 500 void PrerenderContents::UpdateFaviconURL( |
501 int32 page_id, | 501 int32 page_id, |
502 const std::vector<FaviconURL>& urls) { | 502 const std::vector<content::FaviconURL>& urls) { |
503 VLOG(1) << "PrerenderContents::OnUpdateFaviconURL" << icon_url_; | 503 VLOG(1) << "PrerenderContents::OnUpdateFaviconURL" << icon_url_; |
504 for (std::vector<FaviconURL>::const_iterator it = urls.begin(); | 504 for (std::vector<content::FaviconURL>::const_iterator it = urls.begin(); |
505 it != urls.end(); ++it) { | 505 it != urls.end(); ++it) { |
506 if (it->icon_type == FaviconURL::FAVICON) { | 506 if (it->icon_type == content::FaviconURL::FAVICON) { |
507 icon_url_ = it->icon_url; | 507 icon_url_ = it->icon_url; |
508 VLOG(1) << icon_url_; | 508 VLOG(1) << icon_url_; |
509 return; | 509 return; |
510 } | 510 } |
511 } | 511 } |
512 } | 512 } |
513 | 513 |
514 bool PrerenderContents::AddAliasURL(const GURL& url) { | 514 bool PrerenderContents::AddAliasURL(const GURL& url) { |
515 const bool http = url.SchemeIs(chrome::kHttpScheme); | 515 const bool http = url.SchemeIs(chrome::kHttpScheme); |
516 const bool https = url.SchemeIs(chrome::kHttpsScheme); | 516 const bool https = url.SchemeIs(chrome::kHttpsScheme); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 bool PrerenderContents::IsCrossSiteNavigationPending() const { | 708 bool PrerenderContents::IsCrossSiteNavigationPending() const { |
709 if (!prerender_contents_.get() || !prerender_contents_->web_contents()) | 709 if (!prerender_contents_.get() || !prerender_contents_->web_contents()) |
710 return false; | 710 return false; |
711 const WebContents* web_contents = prerender_contents_->web_contents(); | 711 const WebContents* web_contents = prerender_contents_->web_contents(); |
712 return (web_contents->GetSiteInstance() != | 712 return (web_contents->GetSiteInstance() != |
713 web_contents->GetPendingSiteInstance()); | 713 web_contents->GetPendingSiteInstance()); |
714 } | 714 } |
715 | 715 |
716 | 716 |
717 } // namespace prerender | 717 } // namespace prerender |
OLD | NEW |