| 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/instant/instant_controller.h" | 5 #include "chrome/browser/instant/instant_controller.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/i18n/case_conversion.h" | 8 #include "base/i18n/case_conversion.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete_match.h" | 10 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 11 #include "chrome/browser/favicon/favicon_service_factory.h" | |
| 12 #include "chrome/browser/history/history.h" | 11 #include "chrome/browser/history/history.h" |
| 13 #include "chrome/browser/history/history_service_factory.h" | 12 #include "chrome/browser/history/history_service_factory.h" |
| 14 #include "chrome/browser/history/history_tab_helper.h" | 13 #include "chrome/browser/history/history_tab_helper.h" |
| 15 #include "chrome/browser/instant/instant_controller_delegate.h" | 14 #include "chrome/browser/instant/instant_controller_delegate.h" |
| 16 #include "chrome/browser/instant/instant_loader.h" | 15 #include "chrome/browser/instant/instant_loader.h" |
| 17 #include "chrome/browser/platform_util.h" | 16 #include "chrome/browser/platform_util.h" |
| 18 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
| 19 #include "chrome/browser/search_engines/template_url_service.h" | 18 #include "chrome/browser/search_engines/template_url_service.h" |
| 20 #include "chrome/browser/search_engines/template_url_service_factory.h" | 19 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 21 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 20 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 preview->web_contents()->GetController().GetActiveEntry(); | 280 preview->web_contents()->GetController().GetActiveEntry(); |
| 282 DCHECK_EQ(last_navigation->url, entry->GetURL()); | 281 DCHECK_EQ(last_navigation->url, entry->GetURL()); |
| 283 | 282 |
| 284 // Add the page to history. | 283 // Add the page to history. |
| 285 preview->history_tab_helper()->UpdateHistoryForNavigation(last_navigation); | 284 preview->history_tab_helper()->UpdateHistoryForNavigation(last_navigation); |
| 286 | 285 |
| 287 // Update the page title. | 286 // Update the page title. |
| 288 preview->history_tab_helper()->UpdateHistoryPageTitle(*entry); | 287 preview->history_tab_helper()->UpdateHistoryPageTitle(*entry); |
| 289 | 288 |
| 290 // Update the favicon. | 289 // Update the favicon. |
| 291 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( | 290 FaviconService* favicon_service = |
| 292 preview->profile(), Profile::EXPLICIT_ACCESS); | 291 preview->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS); |
| 293 if (favicon_service && entry->GetFavicon().valid && | 292 if (favicon_service && entry->GetFavicon().valid && |
| 294 entry->GetFavicon().image.IsEmpty()) { | 293 entry->GetFavicon().image.IsEmpty()) { |
| 295 std::vector<unsigned char> image_data; | 294 std::vector<unsigned char> image_data; |
| 296 // TODO: Add all variants once the history service supports it. | 295 // TODO: Add all variants once the history service supports it. |
| 297 gfx::PNGCodec::EncodeBGRASkBitmap( | 296 gfx::PNGCodec::EncodeBGRASkBitmap( |
| 298 entry->GetFavicon().image.AsBitmap(), false, &image_data); | 297 entry->GetFavicon().image.AsBitmap(), false, &image_data); |
| 299 favicon_service->SetFavicon(entry->GetURL(), | 298 favicon_service->SetFavicon(entry->GetURL(), |
| 300 entry->GetFavicon().url, | 299 entry->GetFavicon().url, |
| 301 image_data, | 300 image_data, |
| 302 history::FAVICON); | 301 history::FAVICON); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 return false; | 594 return false; |
| 596 } | 595 } |
| 597 | 596 |
| 598 return true; | 597 return true; |
| 599 } | 598 } |
| 600 | 599 |
| 601 bool InstantController::IsOutOfDate() const { | 600 bool InstantController::IsOutOfDate() const { |
| 602 return !last_active_tab_ || | 601 return !last_active_tab_ || |
| 603 last_active_tab_ != delegate_->GetActiveTabContents(); | 602 last_active_tab_ != delegate_->GetActiveTabContents(); |
| 604 } | 603 } |
| OLD | NEW |