| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/favicon_tab_helper.h" |
| 12 #include "chrome/browser/prerender/prerender_contents.h" | 13 #include "chrome/browser/prerender/prerender_contents.h" |
| 13 #include "chrome/browser/prerender/prerender_final_status.h" | 14 #include "chrome/browser/prerender/prerender_final_status.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 15 #include "chrome/common/render_messages.h" | 17 #include "chrome/common/render_messages.h" |
| 16 #include "content/browser/browser_thread.h" | 18 #include "content/browser/browser_thread.h" |
| 17 #include "content/browser/renderer_host/render_view_host.h" | 19 #include "content/browser/renderer_host/render_view_host.h" |
| 18 #include "content/browser/renderer_host/render_process_host.h" | 20 #include "content/browser/renderer_host/render_process_host.h" |
| 19 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 21 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 20 #include "content/browser/tab_contents/render_view_host_manager.h" | 22 #include "content/browser/tab_contents/render_view_host_manager.h" |
| 21 #include "content/browser/tab_contents/tab_contents.h" | 23 #include "content/browser/tab_contents/tab_contents.h" |
| 22 #include "content/common/notification_service.h" | 24 #include "content/common/notification_service.h" |
| 23 #include "googleurl/src/url_parse.h" | 25 #include "googleurl/src/url_parse.h" |
| 24 #include "googleurl/src/url_canon.h" | 26 #include "googleurl/src/url_canon.h" |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 | 332 |
| 331 ViewHostMsg_FrameNavigate_Params* p = pc->navigate_params(); | 333 ViewHostMsg_FrameNavigate_Params* p = pc->navigate_params(); |
| 332 if (p != NULL) | 334 if (p != NULL) |
| 333 tc->DidNavigate(rvh, *p); | 335 tc->DidNavigate(rvh, *p); |
| 334 | 336 |
| 335 string16 title = pc->title(); | 337 string16 title = pc->title(); |
| 336 if (!title.empty()) | 338 if (!title.empty()) |
| 337 tc->UpdateTitle(rvh, pc->page_id(), UTF16ToWideHack(title)); | 339 tc->UpdateTitle(rvh, pc->page_id(), UTF16ToWideHack(title)); |
| 338 | 340 |
| 339 GURL icon_url = pc->icon_url(); | 341 GURL icon_url = pc->icon_url(); |
| 340 if (!icon_url.is_empty()) | 342 if (!icon_url.is_empty()) { |
| 341 tc->favicon_helper().OnUpdateFaviconURL(pc->page_id(), icon_url); | 343 // TODO(avi): move prerendering to use TCWs; remove this. |
| 344 TabContentsWrapper* wrapper = |
| 345 TabContentsWrapper::GetCurrentWrapperForContents(tc); |
| 346 wrapper->favicon_tab_helper()->OnUpdateFaviconURL(pc->page_id(), icon_url); |
| 347 } |
| 342 | 348 |
| 343 if (pc->has_stopped_loading()) | 349 if (pc->has_stopped_loading()) |
| 344 tc->DidStopLoading(); | 350 tc->DidStopLoading(); |
| 345 | 351 |
| 346 return true; | 352 return true; |
| 347 } | 353 } |
| 348 | 354 |
| 349 void PrerenderManager::RemoveEntry(PrerenderContents* entry) { | 355 void PrerenderManager::RemoveEntry(PrerenderContents* entry) { |
| 350 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 356 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 351 for (std::list<PrerenderContentsData>::iterator it = prerender_list_.begin(); | 357 for (std::list<PrerenderContentsData>::iterator it = prerender_list_.begin(); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 | 587 |
| 582 bool PrerenderManager::IsTabContentsPrerendered(TabContents* tc) const { | 588 bool PrerenderManager::IsTabContentsPrerendered(TabContents* tc) const { |
| 583 return prerendered_tc_set_.count(tc) > 0; | 589 return prerendered_tc_set_.count(tc) > 0; |
| 584 } | 590 } |
| 585 | 591 |
| 586 bool PrerenderManager::WouldTabContentsBePrerendered(TabContents* tc) const { | 592 bool PrerenderManager::WouldTabContentsBePrerendered(TabContents* tc) const { |
| 587 return would_be_prerendered_tc_set_.count(tc) > 0; | 593 return would_be_prerendered_tc_set_.count(tc) > 0; |
| 588 } | 594 } |
| 589 | 595 |
| 590 } // namespace prerender | 596 } // namespace prerender |
| OLD | NEW |