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_process_host.h" | 57 #include "content/public/browser/render_process_host.h" |
57 #include "content/public/browser/render_view_host.h" | 58 #include "content/public/browser/render_view_host.h" |
58 #include "content/public/browser/session_storage_namespace.h" | 59 #include "content/public/browser/session_storage_namespace.h" |
59 #include "content/public/browser/web_contents.h" | 60 #include "content/public/browser/web_contents.h" |
60 #include "content/public/browser/web_contents_delegate.h" | 61 #include "content/public/browser/web_contents_delegate.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 local_predictor_->Shutdown(); | 314 local_predictor_->Shutdown(); |
314 profile_ = NULL; | 315 profile_ = NULL; |
315 | 316 |
316 DCHECK(active_prerenders_.empty()); | 317 DCHECK(active_prerenders_.empty()); |
317 } | 318 } |
318 | 319 |
319 PrerenderHandle* PrerenderManager::AddPrerenderFromLinkRelPrerender( | 320 PrerenderHandle* PrerenderManager::AddPrerenderFromLinkRelPrerender( |
320 int process_id, | 321 int process_id, |
321 int route_id, | 322 int route_id, |
322 const GURL& url, | 323 const GURL& url, |
324 const uint32 rel_types, | |
323 const content::Referrer& referrer, | 325 const content::Referrer& referrer, |
324 const gfx::Size& size) { | 326 const gfx::Size& size) { |
325 Origin origin = ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN; | 327 Origin origin = rel_types & PrerenderRelTypePrerender ? |
328 ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN : | |
329 ORIGIN_LINK_REL_NEXT; | |
davidben
2014/01/04 00:19:46
Nit: I'm personally paranoid about C precedence an
| |
326 SessionStorageNamespace* session_storage_namespace = NULL; | 330 SessionStorageNamespace* session_storage_namespace = NULL; |
327 // Unit tests pass in a process_id == -1. | 331 // Unit tests pass in a process_id == -1. |
328 if (process_id != -1) { | 332 if (process_id != -1) { |
329 RenderViewHost* source_render_view_host = | 333 RenderViewHost* source_render_view_host = |
330 RenderViewHost::FromID(process_id, route_id); | 334 RenderViewHost::FromID(process_id, route_id); |
331 if (!source_render_view_host) | 335 if (!source_render_view_host) |
332 return NULL; | 336 return NULL; |
333 WebContents* source_web_contents = | 337 WebContents* source_web_contents = |
334 WebContents::FromRenderViewHost(source_render_view_host); | 338 WebContents::FromRenderViewHost(source_render_view_host); |
335 if (!source_web_contents) | 339 if (!source_web_contents) |
336 return NULL; | 340 return NULL; |
337 if (source_web_contents->GetURL().host() == url.host()) | 341 if (origin == ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN && |
342 source_web_contents->GetURL().host() == url.host()) { | |
338 origin = ORIGIN_LINK_REL_PRERENDER_SAMEDOMAIN; | 343 origin = ORIGIN_LINK_REL_PRERENDER_SAMEDOMAIN; |
344 } | |
339 // TODO(ajwong): This does not correctly handle storage for isolated apps. | 345 // TODO(ajwong): This does not correctly handle storage for isolated apps. |
340 session_storage_namespace = | 346 session_storage_namespace = |
341 source_web_contents->GetController() | 347 source_web_contents->GetController() |
342 .GetDefaultSessionStorageNamespace(); | 348 .GetDefaultSessionStorageNamespace(); |
343 } | 349 } |
344 | 350 |
345 // If the prerender request comes from a recently cancelled prerender that | 351 // If the prerender request comes from a recently cancelled prerender that |
346 // |this| still owns, then abort the prerender. | 352 // |this| still owns, then abort the prerender. |
347 for (ScopedVector<PrerenderData>::iterator it = to_delete_prerenders_.begin(); | 353 for (ScopedVector<PrerenderData>::iterator it = to_delete_prerenders_.begin(); |
348 it != to_delete_prerenders_.end(); ++it) { | 354 it != to_delete_prerenders_.end(); ++it) { |
(...skipping 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1868 void PrerenderManager::RecordEvent(PrerenderContents* contents, | 1874 void PrerenderManager::RecordEvent(PrerenderContents* contents, |
1869 PrerenderEvent event) const { | 1875 PrerenderEvent event) const { |
1870 if (!contents) | 1876 if (!contents) |
1871 histograms_->RecordEvent(ORIGIN_NONE, kNoExperiment, event); | 1877 histograms_->RecordEvent(ORIGIN_NONE, kNoExperiment, event); |
1872 else | 1878 else |
1873 histograms_->RecordEvent(contents->origin(), contents->experiment_id(), | 1879 histograms_->RecordEvent(contents->origin(), contents->experiment_id(), |
1874 event); | 1880 event); |
1875 } | 1881 } |
1876 | 1882 |
1877 } // namespace prerender | 1883 } // namespace prerender |
OLD | NEW |