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 "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 preview->history_tab_helper()->UpdateHistoryForNavigation(last_navigation); | 338 preview->history_tab_helper()->UpdateHistoryForNavigation(last_navigation); |
339 | 339 |
340 // Update the page title. | 340 // Update the page title. |
341 preview->history_tab_helper()->UpdateHistoryPageTitle(*entry); | 341 preview->history_tab_helper()->UpdateHistoryPageTitle(*entry); |
342 | 342 |
343 // Update the favicon. | 343 // Update the favicon. |
344 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( | 344 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( |
345 preview->profile(), Profile::EXPLICIT_ACCESS); | 345 preview->profile(), Profile::EXPLICIT_ACCESS); |
346 if (favicon_service && entry->GetFavicon().valid && | 346 if (favicon_service && entry->GetFavicon().valid && |
347 entry->GetFavicon().image.IsEmpty()) { | 347 entry->GetFavicon().image.IsEmpty()) { |
348 std::vector<unsigned char> image_data; | 348 favicon_service->SetFavicons(entry->GetURL(), entry->GetFavicon().url, |
349 // TODO: Add all variants once the history service supports it. | 349 history::FAVICON, entry->GetFavicon().image); |
350 gfx::PNGCodec::EncodeBGRASkBitmap( | |
351 entry->GetFavicon().image.AsBitmap(), false, &image_data); | |
352 favicon_service->SetFavicon(entry->GetURL(), | |
353 entry->GetFavicon().url, | |
354 image_data, | |
355 history::FAVICON); | |
356 } | 350 } |
357 } | 351 } |
358 | 352 |
359 // Add a fake history entry with a non-Instant search URL, so that search | 353 // Add a fake history entry with a non-Instant search URL, so that search |
360 // terms extraction (for autocomplete history matches) works. | 354 // terms extraction (for autocomplete history matches) works. |
361 HistoryService* history = HistoryServiceFactory::GetForProfile( | 355 HistoryService* history = HistoryServiceFactory::GetForProfile( |
362 preview->profile(), Profile::EXPLICIT_ACCESS); | 356 preview->profile(), Profile::EXPLICIT_ACCESS); |
363 if (history) { | 357 if (history) { |
364 history->AddPage(url_for_history_, NULL, 0, GURL(), last_transition_type_, | 358 history->AddPage(url_for_history_, NULL, 0, GURL(), last_transition_type_, |
365 history::RedirectList(), history::SOURCE_BROWSED, false); | 359 history::RedirectList(), history::SOURCE_BROWSED, false); |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 iter->second > kMaxInstantSupportFailures) | 711 iter->second > kMaxInstantSupportFailures) |
718 return false; | 712 return false; |
719 | 713 |
720 return true; | 714 return true; |
721 } | 715 } |
722 | 716 |
723 bool InstantController::IsOutOfDate() const { | 717 bool InstantController::IsOutOfDate() const { |
724 return !last_active_tab_ || | 718 return !last_active_tab_ || |
725 last_active_tab_ != delegate_->GetActiveTabContents(); | 719 last_active_tab_ != delegate_->GetActiveTabContents(); |
726 } | 720 } |
OLD | NEW |