Chromium Code Reviews| 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 <utility> | 9 #include <utility> |
| 9 | 10 |
| 10 #include "base/process_util.h" | 11 #include "base/process_util.h" |
| 11 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/history/history_tab_helper.h" | 13 #include "chrome/browser/history/history_tab_helper.h" |
| 13 #include "chrome/browser/history/history_types.h" | 14 #include "chrome/browser/history/history_types.h" |
| 14 #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" | |
| 15 #include "chrome/browser/prerender/prerender_manager.h" | 17 #include "chrome/browser/prerender/prerender_manager.h" |
| 16 #include "chrome/browser/prerender/prerender_render_view_host_observer.h" | 18 #include "chrome/browser/prerender/prerender_render_view_host_observer.h" |
| 17 #include "chrome/browser/prerender/prerender_tracker.h" | 19 #include "chrome/browser/prerender/prerender_tracker.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 21 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 20 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
| 21 #include "chrome/common/icon_messages.h" | 23 #include "chrome/common/icon_messages.h" |
| 22 #include "chrome/common/prerender_messages.h" | 24 #include "chrome/common/prerender_messages.h" |
| 23 #include "chrome/common/url_constants.h" | 25 #include "chrome/common/url_constants.h" |
| 24 #include "content/public/browser/resource_request_details.h" | 26 #include "content/public/browser/resource_request_details.h" |
| 25 #include "content/public/browser/browser_child_process_host.h" | 27 #include "content/public/browser/browser_child_process_host.h" |
| 26 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
| 27 #include "content/public/browser/render_process_host.h" | 29 #include "content/public/browser/render_process_host.h" |
| 28 #include "content/public/browser/render_view_host.h" | 30 #include "content/public/browser/render_view_host.h" |
| 29 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
| 30 #include "content/public/browser/web_contents_delegate.h" | 32 #include "content/public/browser/web_contents_delegate.h" |
| 31 #include "content/public/browser/web_contents_view.h" | 33 #include "content/public/browser/web_contents_view.h" |
| 32 #include "ui/gfx/rect.h" | 34 #include "ui/gfx/rect.h" |
| 33 | 35 |
| 34 using content::DownloadItem; | 36 using content::DownloadItem; |
| 35 using content::OpenURLParams; | 37 using content::OpenURLParams; |
| 36 using content::RenderViewHost; | 38 using content::RenderViewHost; |
| 37 using content::ResourceRedirectDetails; | 39 using content::ResourceRedirectDetails; |
| 40 using content::SessionStorageNamespace; | |
| 38 using content::WebContents; | 41 using content::WebContents; |
| 39 | 42 |
| 40 namespace prerender { | 43 namespace prerender { |
| 41 | 44 |
| 42 namespace { | 45 namespace { |
| 43 | 46 |
| 44 // Compares URLs ignoring any ref for the purposes of matching URLs when | |
| 45 // prerendering. | |
| 46 struct PrerenderURLPredicate { | |
| 47 explicit PrerenderURLPredicate(const GURL& url) | |
| 48 : url_(url) { | |
| 49 } | |
| 50 | |
| 51 bool operator()(const GURL& url) const { | |
| 52 return url.scheme() == url_.scheme() && | |
| 53 url.host() == url_.host() && | |
| 54 url.port() == url_.port() && | |
| 55 url.path() == url_.path() && | |
| 56 url.query() == url_.query(); | |
| 57 } | |
| 58 GURL url_; | |
| 59 }; | |
| 60 | |
| 61 // Tells the render process at |child_id| whether |url| is a new prerendered | 47 // Tells the render process at |child_id| whether |url| is a new prerendered |
| 62 // page, or whether |url| is being removed as a prerendered page. Currently | 48 // page, or whether |url| is being removed as a prerendered page. Currently |
| 63 // this will only inform the render process that created the prerendered page | 49 // this will only inform the render process that created the prerendered page |
| 64 // with <link rel="prerender"> tags about it. This means that if the user | 50 // with <link rel="prerender"> tags about it. This means that if the user |
| 65 // clicks on a link for a prerendered URL in a different page, the prerender | 51 // clicks on a link for a prerendered URL in a different page, the prerender |
| 66 // will not be swapped in. | 52 // will not be swapped in. |
| 67 void InformRenderProcessAboutPrerender(const GURL& url, | 53 void InformRenderProcessAboutPrerender(const GURL& url, |
| 68 bool is_add, | 54 bool is_add, |
| 69 int child_id) { | 55 int child_id) { |
| 70 if (child_id < 0) | 56 if (child_id < 0) |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 87 public: | 73 public: |
| 88 virtual PrerenderContents* CreatePrerenderContents( | 74 virtual PrerenderContents* CreatePrerenderContents( |
| 89 PrerenderManager* prerender_manager, PrerenderTracker* prerender_tracker, | 75 PrerenderManager* prerender_manager, PrerenderTracker* prerender_tracker, |
| 90 Profile* profile, const GURL& url, const content::Referrer& referrer, | 76 Profile* profile, const GURL& url, const content::Referrer& referrer, |
| 91 Origin origin, uint8 experiment_id) OVERRIDE { | 77 Origin origin, uint8 experiment_id) OVERRIDE { |
| 92 return new PrerenderContents(prerender_manager, prerender_tracker, profile, | 78 return new PrerenderContents(prerender_manager, prerender_tracker, profile, |
| 93 url, referrer, origin, experiment_id); | 79 url, referrer, origin, experiment_id); |
| 94 } | 80 } |
| 95 }; | 81 }; |
| 96 | 82 |
| 97 struct PrerenderContents::PendingPrerenderInfo { | |
| 98 PendingPrerenderInfo(const GURL& url, | |
| 99 const content::Referrer& referrer, | |
| 100 const gfx::Size& size); | |
| 101 const GURL url; | |
| 102 const content::Referrer referrer; | |
| 103 const gfx::Size size; | |
| 104 }; | |
| 105 | |
| 106 PrerenderContents::PendingPrerenderInfo::PendingPrerenderInfo( | |
| 107 const GURL& url, | |
| 108 const content::Referrer& referrer, | |
| 109 const gfx::Size& size) | |
| 110 : url(url), | |
| 111 referrer(referrer), | |
| 112 size(size) { | |
| 113 } | |
| 114 | |
| 115 // TabContentsDelegateImpl ----------------------------------------------------- | 83 // TabContentsDelegateImpl ----------------------------------------------------- |
| 116 | 84 |
| 117 class PrerenderContents::TabContentsDelegateImpl | 85 class PrerenderContents::TabContentsDelegateImpl |
| 118 : public content::WebContentsDelegate { | 86 : public content::WebContentsDelegate { |
| 119 public: | 87 public: |
| 120 explicit TabContentsDelegateImpl(PrerenderContents* prerender_contents) : | 88 explicit TabContentsDelegateImpl(PrerenderContents* prerender_contents) : |
| 121 prerender_contents_(prerender_contents) { | 89 prerender_contents_(prerender_contents) { |
| 122 } | 90 } |
| 123 | 91 |
| 124 // content::WebContentsDelegate implementation: | 92 // content::WebContentsDelegate implementation: |
| 125 virtual WebContents* OpenURLFromTab(WebContents* source, | 93 virtual WebContents* OpenURLFromTab(WebContents* source, |
| 126 const OpenURLParams& params) OVERRIDE { | 94 const OpenURLParams& params) OVERRIDE { |
| 127 // |OpenURLFromTab| is typically called when a frame performs a navigation | 95 // |OpenURLFromTab| is typically called when a frame performs a navigation |
| 128 // that requires the browser to perform the transition instead of WebKit. | 96 // that requires the browser to perform the transition instead of WebKit. |
| 129 // Examples include prerendering a site that redirects to an app URL, | 97 // Examples include prerendering a site that redirects to an app URL, |
| 130 // or if --enable-strict-site-isolation is specified and the prerendered | 98 // or if --enable-strict-site-isolation is specified and the prerendered |
| 131 // frame redirects to a different origin. | 99 // frame redirects to a different origin. |
| 132 // TODO(cbentzel): Consider supporting this if it is a common case during | 100 // TODO(cbentzel): Consider supporting this if it is a common case during |
| 133 // prerenders. | 101 // prerenders. |
| 134 prerender_contents_->Destroy(FINAL_STATUS_OPEN_URL); | 102 prerender_contents_->Destroy(FINAL_STATUS_OPEN_URL); |
| 135 return NULL; | 103 return NULL; |
| 136 } | 104 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 private: | 180 private: |
| 213 typedef std::vector<scoped_refptr<history::HistoryAddPageArgs> > | 181 typedef std::vector<scoped_refptr<history::HistoryAddPageArgs> > |
| 214 AddPageVector; | 182 AddPageVector; |
| 215 | 183 |
| 216 // Caches pages to be added to the history. | 184 // Caches pages to be added to the history. |
| 217 AddPageVector add_page_vector_; | 185 AddPageVector add_page_vector_; |
| 218 | 186 |
| 219 PrerenderContents* prerender_contents_; | 187 PrerenderContents* prerender_contents_; |
| 220 }; | 188 }; |
| 221 | 189 |
| 222 void PrerenderContents::AddPendingPrerender(const GURL& url, | 190 void PrerenderContents::AddPendingPrerender( |
| 223 const content::Referrer& referrer, | 191 const base::WeakPtr<PrerenderHandle> weak_prerender_handle, |
| 224 const gfx::Size& size) { | 192 const GURL& url, |
| 225 pending_prerender_list_.push_back(PendingPrerenderInfo(url, referrer, size)); | 193 const content::Referrer& referrer, |
| 194 const gfx::Size& size) { | |
| 195 pending_prerender_list_.push_back( | |
| 196 PendingPrerenderInfo(weak_prerender_handle, url, referrer, size)); | |
| 226 } | 197 } |
| 227 | 198 |
| 228 bool PrerenderContents::IsPendingEntry(const GURL& url) const { | 199 bool PrerenderContents::IsPendingEntry( |
| 229 for (PendingPrerenderList::const_iterator it = | 200 const PrerenderHandle* prerender_handle) const { |
| 201 for (std::vector<PendingPrerenderInfo>::const_iterator it = | |
|
dominich
2012/07/03 17:08:39
Another reason to not remove the typedef - you wou
| |
| 230 pending_prerender_list_.begin(); | 202 pending_prerender_list_.begin(); |
| 231 it != pending_prerender_list_.end(); | 203 it != pending_prerender_list_.end(); |
| 232 ++it) { | 204 ++it) { |
| 233 if (it->url == url) | 205 if (it->weak_prerender_handle.get() == prerender_handle) |
|
dominich
2012/07/03 17:08:39
i'm curious how this compiled before. it /should/
gavinp
2012/07/03 18:45:41
See base::WeakPtr<T>::operator T*() { return get()
dominich
2012/07/03 20:02:41
Aha!
I do not like that one bit. However, it is n
gavinp
2012/07/04 03:01:17
I concur that it's out of scope. You might be surp
| |
| 234 return true; | 206 return true; |
| 235 } | 207 } |
| 236 return false; | 208 return false; |
| 237 } | 209 } |
| 238 | 210 |
| 239 void PrerenderContents::StartPendingPrerenders() { | 211 void PrerenderContents::StartPendingPrerenders() { |
| 240 PendingPrerenderList pending_prerender_list; | 212 SessionStorageNamespace* session_storage_namespace = NULL; |
| 213 if (RenderViewHost* render_view_host = GetRenderViewHostMutable()) { | |
| 214 session_storage_namespace = render_view_host->GetSessionStorageNamespace(); | |
| 215 } else { | |
| 216 DCHECK_EQ(-1, child_id_) | |
| 217 << "session_storage_namespace != NULL, except in tests"; | |
| 218 } | |
| 219 | |
| 220 std::vector<PendingPrerenderInfo> pending_prerender_list; | |
| 241 pending_prerender_list.swap(pending_prerender_list_); | 221 pending_prerender_list.swap(pending_prerender_list_); |
| 242 for (PendingPrerenderList::iterator it = pending_prerender_list.begin(); | 222 for (std::vector<PendingPrerenderInfo>::iterator it = |
| 223 pending_prerender_list.begin(); | |
| 243 it != pending_prerender_list.end(); | 224 it != pending_prerender_list.end(); |
| 244 ++it) { | 225 ++it) { |
| 245 prerender_manager_->AddPrerenderFromLinkRelPrerender( | 226 if (it->weak_prerender_handle && it->weak_prerender_handle->IsValid()) { |
| 246 child_id_, route_id_, it->url, it->referrer, it->size); | 227 prerender_manager_->StartPendingPrerender( |
| 228 it->weak_prerender_handle.get(), ORIGIN_LINK_REL_PRERENDER, child_id_, | |
|
dominich
2012/07/03 17:08:39
and again - how did this compile?
mmenke
2012/07/09 18:06:57
It's actually pretty common to rely on the weak po
| |
| 229 it->url, it->referrer, it->size, session_storage_namespace); | |
| 230 } | |
| 247 } | 231 } |
| 248 } | 232 } |
| 249 | 233 |
| 234 PrerenderContents::PendingPrerenderInfo::PendingPrerenderInfo( | |
| 235 const base::WeakPtr<PrerenderHandle> weak_prerender_handle, | |
| 236 const GURL& url, | |
| 237 const content::Referrer& referrer, | |
| 238 const gfx::Size& size) | |
| 239 : weak_prerender_handle(weak_prerender_handle), | |
| 240 url(url), | |
| 241 referrer(referrer), | |
| 242 size(size) { | |
| 243 } | |
| 244 | |
| 245 PrerenderContents::PendingPrerenderInfo::~PendingPrerenderInfo() { | |
| 246 } | |
| 247 | |
| 250 PrerenderContents::PrerenderContents( | 248 PrerenderContents::PrerenderContents( |
| 251 PrerenderManager* prerender_manager, | 249 PrerenderManager* prerender_manager, |
| 252 PrerenderTracker* prerender_tracker, | 250 PrerenderTracker* prerender_tracker, |
| 253 Profile* profile, | 251 Profile* profile, |
| 254 const GURL& url, | 252 const GURL& url, |
| 255 const content::Referrer& referrer, | 253 const content::Referrer& referrer, |
| 256 Origin origin, | 254 Origin origin, |
| 257 uint8 experiment_id) | 255 uint8 experiment_id) |
| 258 : prerendering_has_started_(false), | 256 : prerendering_has_started_(false), |
| 259 prerender_manager_(prerender_manager), | 257 prerender_manager_(prerender_manager), |
| 260 prerender_tracker_(prerender_tracker), | 258 prerender_tracker_(prerender_tracker), |
| 261 prerender_url_(url), | 259 prerender_url_(url), |
| 262 referrer_(referrer), | 260 referrer_(referrer), |
| 263 profile_(profile), | 261 profile_(profile), |
| 264 page_id_(0), | 262 page_id_(0), |
| 263 session_storage_namespace_(NULL), | |
| 265 has_stopped_loading_(false), | 264 has_stopped_loading_(false), |
| 266 has_finished_loading_(false), | 265 has_finished_loading_(false), |
| 267 final_status_(FINAL_STATUS_MAX), | 266 final_status_(FINAL_STATUS_MAX), |
| 268 match_complete_status_(MATCH_COMPLETE_DEFAULT), | 267 match_complete_status_(MATCH_COMPLETE_DEFAULT), |
| 269 prerendering_has_been_cancelled_(false), | 268 prerendering_has_been_cancelled_(false), |
| 270 child_id_(-1), | 269 child_id_(-1), |
| 271 route_id_(-1), | 270 route_id_(-1), |
| 272 origin_(origin), | 271 origin_(origin), |
| 273 experiment_id_(experiment_id), | 272 experiment_id_(experiment_id), |
| 274 creator_child_id_(-1) { | 273 creator_child_id_(-1) { |
| 275 DCHECK(prerender_manager != NULL); | 274 DCHECK(prerender_manager != NULL); |
| 276 } | 275 } |
| 277 | 276 |
| 277 void PrerenderContents::MakeIntoDummyReplacementOf( | |
| 278 const PrerenderContents* original_prerender_contents) { | |
| 279 load_start_time_ = original_prerender_contents->load_start_time_; | |
| 280 session_storage_namespace_ = | |
| 281 original_prerender_contents->session_storage_namespace_; | |
| 282 } | |
| 283 | |
| 278 bool PrerenderContents::Init() { | 284 bool PrerenderContents::Init() { |
| 279 return AddAliasURL(prerender_url_); | 285 return AddAliasURL(prerender_url_); |
| 280 } | 286 } |
| 281 | 287 |
| 282 // static | 288 // static |
| 283 PrerenderContents::Factory* PrerenderContents::CreateFactory() { | 289 PrerenderContents::Factory* PrerenderContents::CreateFactory() { |
| 284 return new PrerenderContentsFactoryImpl(); | 290 return new PrerenderContentsFactoryImpl(); |
| 285 } | 291 } |
| 286 | 292 |
| 287 void PrerenderContents::StartPrerendering( | 293 void PrerenderContents::StartPrerendering( |
| 288 int creator_child_id, | 294 int creator_child_id, |
| 289 const gfx::Size& size, | 295 const gfx::Size& size, |
| 290 content::SessionStorageNamespace* session_storage_namespace, | 296 SessionStorageNamespace* session_storage_namespace, |
| 291 bool is_control_group) { | 297 bool is_control_group) { |
| 292 DCHECK(profile_ != NULL); | 298 DCHECK(profile_ != NULL); |
| 293 DCHECK(!size.IsEmpty()); | 299 DCHECK(!size.IsEmpty()); |
| 294 DCHECK(!prerendering_has_started_); | 300 DCHECK(!prerendering_has_started_); |
| 295 DCHECK(prerender_contents_.get() == NULL); | 301 DCHECK(prerender_contents_.get() == NULL); |
| 296 DCHECK_EQ(-1, creator_child_id_); | 302 DCHECK_EQ(-1, creator_child_id_); |
| 297 DCHECK(size_.IsEmpty()); | 303 DCHECK(size_.IsEmpty()); |
| 298 DCHECK_EQ(1U, alias_urls_.size()); | 304 DCHECK_EQ(1U, alias_urls_.size()); |
| 299 | 305 |
| 300 creator_child_id_ = creator_child_id; | 306 creator_child_id_ = creator_child_id; |
| 307 session_storage_namespace_ = session_storage_namespace; | |
| 301 size_ = size; | 308 size_ = size; |
| 302 | 309 |
| 303 InformRenderProcessAboutPrerender(prerender_url_, true, | 310 InformRenderProcessAboutPrerender(prerender_url_, true, |
| 304 creator_child_id_); | 311 creator_child_id_); |
| 305 | 312 |
| 313 DCHECK(load_start_time_.is_null()); | |
| 314 load_start_time_ = base::TimeTicks::Now(); | |
| 315 | |
| 306 // Everything after this point sets up the WebContents object and associated | 316 // Everything after this point sets up the WebContents object and associated |
| 307 // RenderView for the prerender page. Don't do this for members of the | 317 // RenderView for the prerender page. Don't do this for members of the |
| 308 // control group. | 318 // control group. |
| 309 if (is_control_group) | 319 if (is_control_group) |
| 310 return; | 320 return; |
| 311 | 321 |
| 312 prerendering_has_started_ = true; | 322 prerendering_has_started_ = true; |
| 313 | 323 |
| 314 WebContents* new_contents = CreateWebContents(session_storage_namespace); | 324 WebContents* new_contents = CreateWebContents(session_storage_namespace); |
| 315 prerender_contents_.reset(new TabContents(new_contents)); | 325 prerender_contents_.reset(new TabContents(new_contents)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 351 // Register to inform new RenderViews that we're prerendering. | 361 // Register to inform new RenderViews that we're prerendering. |
| 352 notification_registrar_.Add( | 362 notification_registrar_.Add( |
| 353 this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, | 363 this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, |
| 354 content::Source<WebContents>(new_contents)); | 364 content::Source<WebContents>(new_contents)); |
| 355 | 365 |
| 356 // Register for redirect notifications sourced from |this|. | 366 // Register for redirect notifications sourced from |this|. |
| 357 notification_registrar_.Add( | 367 notification_registrar_.Add( |
| 358 this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, | 368 this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, |
| 359 content::Source<WebContents>(GetWebContents())); | 369 content::Source<WebContents>(GetWebContents())); |
| 360 | 370 |
| 361 DCHECK(load_start_time_.is_null()); | |
| 362 load_start_time_ = base::TimeTicks::Now(); | |
| 363 | |
| 364 // Transfer over the user agent override. | 371 // Transfer over the user agent override. |
| 365 new_contents->SetUserAgentOverride( | 372 new_contents->SetUserAgentOverride( |
| 366 prerender_manager_->config().user_agent_override); | 373 prerender_manager_->config().user_agent_override); |
| 367 | 374 |
| 368 new_contents->GetController().LoadURLWithUserAgentOverride( | 375 new_contents->GetController().LoadURLWithUserAgentOverride( |
| 369 prerender_url_, | 376 prerender_url_, |
| 370 referrer_, | 377 referrer_, |
| 371 (origin_ == ORIGIN_OMNIBOX ? content::PAGE_TRANSITION_TYPED : | 378 (origin_ == ORIGIN_OMNIBOX ? content::PAGE_TRANSITION_TYPED : |
| 372 content::PAGE_TRANSITION_LINK), | 379 content::PAGE_TRANSITION_LINK), |
| 373 false, | 380 false, |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 487 NOTREACHED() << "Unexpected notification sent."; | 494 NOTREACHED() << "Unexpected notification sent."; |
| 488 break; | 495 break; |
| 489 } | 496 } |
| 490 } | 497 } |
| 491 | 498 |
| 492 void PrerenderContents::OnRenderViewHostCreated( | 499 void PrerenderContents::OnRenderViewHostCreated( |
| 493 RenderViewHost* new_render_view_host) { | 500 RenderViewHost* new_render_view_host) { |
| 494 } | 501 } |
| 495 | 502 |
| 496 WebContents* PrerenderContents::CreateWebContents( | 503 WebContents* PrerenderContents::CreateWebContents( |
| 497 content::SessionStorageNamespace* session_storage_namespace) { | 504 SessionStorageNamespace* session_storage_namespace) { |
| 498 return WebContents::Create(profile_, NULL, MSG_ROUTING_NONE, NULL, | 505 return WebContents::Create(profile_, NULL, MSG_ROUTING_NONE, NULL, |
| 499 session_storage_namespace); | 506 session_storage_namespace); |
| 500 } | 507 } |
| 501 | 508 |
| 502 void PrerenderContents::OnUpdateFaviconURL( | 509 void PrerenderContents::OnUpdateFaviconURL( |
| 503 int32 page_id, | 510 int32 page_id, |
| 504 const std::vector<FaviconURL>& urls) { | 511 const std::vector<FaviconURL>& urls) { |
| 505 VLOG(1) << "PrerenderContents::OnUpdateFaviconURL" << icon_url_; | 512 VLOG(1) << "PrerenderContents::OnUpdateFaviconURL" << icon_url_; |
| 506 for (std::vector<FaviconURL>::const_iterator it = urls.begin(); | 513 for (std::vector<FaviconURL>::const_iterator it = urls.begin(); |
| 507 it != urls.end(); ++it) { | 514 it != urls.end(); ++it) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 539 | 546 |
| 540 void PrerenderContents::AddAliasURLsFromOtherPrerenderContents( | 547 void PrerenderContents::AddAliasURLsFromOtherPrerenderContents( |
| 541 PrerenderContents* other_pc) { | 548 PrerenderContents* other_pc) { |
| 542 for (std::vector<GURL>::const_iterator it = other_pc->alias_urls_.begin(); | 549 for (std::vector<GURL>::const_iterator it = other_pc->alias_urls_.begin(); |
| 543 it != other_pc->alias_urls_.end(); | 550 it != other_pc->alias_urls_.end(); |
| 544 ++it) { | 551 ++it) { |
| 545 alias_urls_.push_back(*it); | 552 alias_urls_.push_back(*it); |
| 546 } | 553 } |
| 547 } | 554 } |
| 548 | 555 |
| 549 bool PrerenderContents::MatchesURL(const GURL& url, GURL* matching_url) const { | 556 bool PrerenderContents::Matches( |
| 550 std::vector<GURL>::const_iterator matching_url_iterator = | 557 const GURL& url, |
| 551 std::find_if(alias_urls_.begin(), | 558 const SessionStorageNamespace* session_storage_namespace) { |
| 552 alias_urls_.end(), | 559 if (session_storage_namespace_ != session_storage_namespace) |
| 553 PrerenderURLPredicate(url)); | 560 return false; |
| 554 if (matching_url_iterator != alias_urls_.end()) { | 561 return std::count_if(alias_urls_.begin(), alias_urls_.end(), |
| 555 if (matching_url) | 562 std::bind2nd(std::equal_to<GURL>(), url)) != 0; |
| 556 *matching_url = *matching_url_iterator; | |
| 557 return true; | |
| 558 } | |
| 559 return false; | |
| 560 } | 563 } |
| 561 | 564 |
| 562 void PrerenderContents::RenderViewGone(base::TerminationStatus status) { | 565 void PrerenderContents::RenderViewGone(base::TerminationStatus status) { |
| 563 Destroy(FINAL_STATUS_RENDERER_CRASHED); | 566 Destroy(FINAL_STATUS_RENDERER_CRASHED); |
| 564 } | 567 } |
| 565 | 568 |
| 566 void PrerenderContents::DidStopLoading() { | 569 void PrerenderContents::DidStopLoading() { |
| 567 has_stopped_loading_ = true; | 570 has_stopped_loading_ = true; |
| 568 } | 571 } |
| 569 | 572 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 702 bool PrerenderContents::IsCrossSiteNavigationPending() const { | 705 bool PrerenderContents::IsCrossSiteNavigationPending() const { |
| 703 if (!prerender_contents_.get() || !prerender_contents_->web_contents()) | 706 if (!prerender_contents_.get() || !prerender_contents_->web_contents()) |
| 704 return false; | 707 return false; |
| 705 const WebContents* web_contents = prerender_contents_->web_contents(); | 708 const WebContents* web_contents = prerender_contents_->web_contents(); |
| 706 return (web_contents->GetSiteInstance() != | 709 return (web_contents->GetSiteInstance() != |
| 707 web_contents->GetPendingSiteInstance()); | 710 web_contents->GetPendingSiteInstance()); |
| 708 } | 711 } |
| 709 | 712 |
| 710 | 713 |
| 711 } // namespace prerender | 714 } // namespace prerender |
| OLD | NEW |