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_manager.h" | 5 #include "chrome/browser/prerender/prerender_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "chrome/browser/prerender/prerender_util.h" | 41 #include "chrome/browser/prerender/prerender_util.h" |
42 #include "chrome/browser/profiles/profile.h" | 42 #include "chrome/browser/profiles/profile.h" |
43 #include "chrome/browser/search/search.h" | 43 #include "chrome/browser/search/search.h" |
44 #include "chrome/browser/tab_contents/tab_util.h" | 44 #include "chrome/browser/tab_contents/tab_util.h" |
45 #include "chrome/browser/ui/browser_navigator.h" | 45 #include "chrome/browser/ui/browser_navigator.h" |
46 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 46 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
47 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" | 47 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" |
48 #include "chrome/common/chrome_switches.h" | 48 #include "chrome/common/chrome_switches.h" |
49 #include "chrome/common/pref_names.h" | 49 #include "chrome/common/pref_names.h" |
50 #include "chrome/common/prerender_messages.h" | 50 #include "chrome/common/prerender_messages.h" |
| 51 #include "chrome/common/prerender_types.h" |
51 #include "content/public/browser/browser_thread.h" | 52 #include "content/public/browser/browser_thread.h" |
52 #include "content/public/browser/devtools_agent_host.h" | 53 #include "content/public/browser/devtools_agent_host.h" |
53 #include "content/public/browser/navigation_controller.h" | 54 #include "content/public/browser/navigation_controller.h" |
54 #include "content/public/browser/notification_service.h" | 55 #include "content/public/browser/notification_service.h" |
55 #include "content/public/browser/notification_source.h" | 56 #include "content/public/browser/notification_source.h" |
56 #include "content/public/browser/render_frame_host.h" | 57 #include "content/public/browser/render_frame_host.h" |
57 #include "content/public/browser/render_process_host.h" | 58 #include "content/public/browser/render_process_host.h" |
58 #include "content/public/browser/render_view_host.h" | 59 #include "content/public/browser/render_view_host.h" |
59 #include "content/public/browser/session_storage_namespace.h" | 60 #include "content/public/browser/session_storage_namespace.h" |
60 #include "content/public/browser/web_contents.h" | 61 #include "content/public/browser/web_contents.h" |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 local_predictor_->Shutdown(); | 308 local_predictor_->Shutdown(); |
308 profile_ = NULL; | 309 profile_ = NULL; |
309 | 310 |
310 DCHECK(active_prerenders_.empty()); | 311 DCHECK(active_prerenders_.empty()); |
311 } | 312 } |
312 | 313 |
313 PrerenderHandle* PrerenderManager::AddPrerenderFromLinkRelPrerender( | 314 PrerenderHandle* PrerenderManager::AddPrerenderFromLinkRelPrerender( |
314 int process_id, | 315 int process_id, |
315 int route_id, | 316 int route_id, |
316 const GURL& url, | 317 const GURL& url, |
| 318 const uint32 rel_types, |
317 const content::Referrer& referrer, | 319 const content::Referrer& referrer, |
318 const gfx::Size& size) { | 320 const gfx::Size& size) { |
319 Origin origin = ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN; | 321 Origin origin = rel_types & PrerenderRelTypePrerender ? |
| 322 ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN : |
| 323 ORIGIN_LINK_REL_NEXT; |
320 SessionStorageNamespace* session_storage_namespace = NULL; | 324 SessionStorageNamespace* session_storage_namespace = NULL; |
321 // Unit tests pass in a process_id == -1. | 325 // Unit tests pass in a process_id == -1. |
322 if (process_id != -1) { | 326 if (process_id != -1) { |
323 RenderViewHost* source_render_view_host = | 327 RenderViewHost* source_render_view_host = |
324 RenderViewHost::FromID(process_id, route_id); | 328 RenderViewHost::FromID(process_id, route_id); |
325 if (!source_render_view_host) | 329 if (!source_render_view_host) |
326 return NULL; | 330 return NULL; |
327 WebContents* source_web_contents = | 331 WebContents* source_web_contents = |
328 WebContents::FromRenderViewHost(source_render_view_host); | 332 WebContents::FromRenderViewHost(source_render_view_host); |
329 if (!source_web_contents) | 333 if (!source_web_contents) |
330 return NULL; | 334 return NULL; |
331 if (source_web_contents->GetURL().host() == url.host()) | 335 if (origin == ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN && |
| 336 source_web_contents->GetURL().host() == url.host()) { |
332 origin = ORIGIN_LINK_REL_PRERENDER_SAMEDOMAIN; | 337 origin = ORIGIN_LINK_REL_PRERENDER_SAMEDOMAIN; |
| 338 } |
333 // TODO(ajwong): This does not correctly handle storage for isolated apps. | 339 // TODO(ajwong): This does not correctly handle storage for isolated apps. |
334 session_storage_namespace = | 340 session_storage_namespace = |
335 source_web_contents->GetController() | 341 source_web_contents->GetController() |
336 .GetDefaultSessionStorageNamespace(); | 342 .GetDefaultSessionStorageNamespace(); |
337 } | 343 } |
338 | 344 |
339 return AddPrerender(origin, process_id, url, referrer, size, | 345 return AddPrerender(origin, process_id, url, referrer, size, |
340 session_storage_namespace); | 346 session_storage_namespace); |
341 } | 347 } |
342 | 348 |
(...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1761 history::VisitVector* visists) { | 1767 history::VisitVector* visists) { |
1762 histograms_->RecordPrerenderPageVisitedStatus(origin, experiment_id, success); | 1768 histograms_->RecordPrerenderPageVisitedStatus(origin, experiment_id, success); |
1763 } | 1769 } |
1764 | 1770 |
1765 // static | 1771 // static |
1766 void PrerenderManager::HangSessionStorageMergesForTesting() { | 1772 void PrerenderManager::HangSessionStorageMergesForTesting() { |
1767 g_hang_session_storage_merges_for_testing = true; | 1773 g_hang_session_storage_merges_for_testing = true; |
1768 } | 1774 } |
1769 | 1775 |
1770 } // namespace prerender | 1776 } // namespace prerender |
OLD | NEW |