Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Side by Side Diff: chrome/browser/prerender/prerender_manager.cc

Issue 10933065: Separate same domain and cross domain <link rel=...> prerenders for reporting. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: fix rebase... Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 linked_ptr<PrerenderData>(new PrerenderData(this))); 231 linked_ptr<PrerenderData>(new PrerenderData(this)));
232 PrerenderHandle* prerender_handle = 232 PrerenderHandle* prerender_handle =
233 new PrerenderHandle(pending_prerender_list_.back().get()); 233 new PrerenderHandle(pending_prerender_list_.back().get());
234 contents->AddPendingPrerender( 234 contents->AddPendingPrerender(
235 prerender_handle->weak_ptr_factory_.GetWeakPtr(), 235 prerender_handle->weak_ptr_factory_.GetWeakPtr(),
236 url, referrer, size); 236 url, referrer, size);
237 return prerender_handle; 237 return prerender_handle;
238 } 238 }
239 } 239 }
240 240
241 bool is_same_domain = false;
242 SessionStorageNamespace* session_storage_namespace = NULL;
241 // Unit tests pass in a process_id == -1. 243 // Unit tests pass in a process_id == -1.
242 SessionStorageNamespace* session_storage_namespace = NULL;
243 if (process_id != -1) { 244 if (process_id != -1) {
244 RenderViewHost* source_render_view_host = 245 RenderViewHost* source_render_view_host =
245 RenderViewHost::FromID(process_id, route_id); 246 RenderViewHost::FromID(process_id, route_id);
246 if (!source_render_view_host) 247 if (!source_render_view_host)
247 return NULL; 248 return NULL;
248 WebContents* source_web_contents = 249 WebContents* source_web_contents =
249 WebContents::FromRenderViewHost(source_render_view_host); 250 WebContents::FromRenderViewHost(source_render_view_host);
250 if (!source_web_contents) 251 if (!source_web_contents)
251 return NULL; 252 return NULL;
253
254 if (source_web_contents->GetURL().host() == url.host())
dominich 2012/09/13 20:03:36 shorter: is_same_domain = source_web_contents->Get
gavinp 2012/09/14 02:00:42 Done.
255 is_same_domain = true;
252 // TODO(ajwong): This does not correctly handle storage for isolated apps. 256 // TODO(ajwong): This does not correctly handle storage for isolated apps.
253 session_storage_namespace = 257 session_storage_namespace =
254 source_web_contents->GetController() 258 source_web_contents->GetController()
255 .GetDefaultSessionStorageNamespace(); 259 .GetDefaultSessionStorageNamespace();
256 } 260 }
257 261
258 return AddPrerender(ORIGIN_LINK_REL_PRERENDER, 262 return AddPrerender(is_same_domain ? ORIGIN_LINK_REL_PRERENDER_SAMEDOMAIN
263 : ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN,
259 process_id, url, referrer, size, 264 process_id, url, referrer, size,
260 session_storage_namespace); 265 session_storage_namespace);
261 #endif 266 #endif
262 } 267 }
263 268
264 PrerenderHandle* PrerenderManager::AddPrerenderFromOmnibox( 269 PrerenderHandle* PrerenderManager::AddPrerenderFromOmnibox(
265 const GURL& url, 270 const GURL& url,
266 SessionStorageNamespace* session_storage_namespace, 271 SessionStorageNamespace* session_storage_namespace,
267 const gfx::Size& size) { 272 const gfx::Size& size) {
268 if (!IsOmniboxEnabled(profile_)) 273 if (!IsOmniboxEnabled(profile_))
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 int process_id, 910 int process_id,
906 const GURL& url_arg, 911 const GURL& url_arg,
907 const content::Referrer& referrer, 912 const content::Referrer& referrer,
908 const gfx::Size& size, 913 const gfx::Size& size,
909 SessionStorageNamespace* session_storage_namespace) { 914 SessionStorageNamespace* session_storage_namespace) {
910 DCHECK(CalledOnValidThread()); 915 DCHECK(CalledOnValidThread());
911 916
912 if (!IsEnabled()) 917 if (!IsEnabled())
913 return NULL; 918 return NULL;
914 919
915 if (origin == ORIGIN_LINK_REL_PRERENDER && 920 if (origin == ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN &&
916 IsGoogleSearchResultURL(referrer.url)) { 921 IsGoogleSearchResultURL(referrer.url)) {
917 origin = ORIGIN_GWS_PRERENDER; 922 origin = ORIGIN_GWS_PRERENDER;
dominich 2012/09/13 20:03:36 GWS could be same-domain.
gavinp 2012/09/14 02:00:42 That's true... But the goal here is to gather stat
dominich 2012/09/14 14:40:45 I'm suggesting changing the conditional, not the e
gavinp 2012/09/14 21:10:47 DOH. Reading comprehension fail. Thanks. I have no
918 } 923 }
919 924
920 DeleteOldEntries(); 925 DeleteOldEntries();
921 DeletePendingDeleteEntries(); 926 DeletePendingDeleteEntries();
922 927
923 GURL url = url_arg; 928 GURL url = url_arg;
924 GURL alias_url; 929 GURL alias_url;
925 uint8 experiment = GetQueryStringBasedExperiment(url_arg); 930 uint8 experiment = GetQueryStringBasedExperiment(url_arg);
926 bool control_group_behavior = 931 bool control_group_behavior =
927 IsControlGroup() || IsControlGroupExperiment(experiment); 932 IsControlGroup() || IsControlGroupExperiment(experiment);
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 if (!render_process_host || !render_process_host->GetBrowserContext()) 1293 if (!render_process_host || !render_process_host->GetBrowserContext())
1289 return NULL; 1294 return NULL;
1290 Profile* profile = Profile::FromBrowserContext( 1295 Profile* profile = Profile::FromBrowserContext(
1291 render_process_host->GetBrowserContext()); 1296 render_process_host->GetBrowserContext());
1292 if (!profile) 1297 if (!profile)
1293 return NULL; 1298 return NULL;
1294 return PrerenderManagerFactory::GetInstance()->GetForProfile(profile); 1299 return PrerenderManagerFactory::GetInstance()->GetForProfile(profile);
1295 } 1300 }
1296 1301
1297 } // namespace prerender 1302 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698