| 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/favicon/favicon_tab_helper.h" | 5 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 6 | 6 |
| 7 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/favicon/chrome_favicon_client.h" | 10 #include "chrome/browser/favicon/chrome_favicon_client.h" |
| 11 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" | 11 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" |
| 12 #include "chrome/browser/favicon/favicon_service_factory.h" | 12 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 13 #include "chrome/browser/history/history_service_factory.h" | 13 #include "chrome/browser/history/history_service_factory.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/search/search.h" | 15 #include "chrome/browser/search/search.h" |
| 16 #include "chrome/common/chrome_constants.h" | 16 #include "chrome/common/chrome_constants.h" |
| 17 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 18 #include "components/favicon/content/favicon_url_util.h" |
| 18 #include "components/favicon/core/favicon_handler.h" | 19 #include "components/favicon/core/favicon_handler.h" |
| 19 #include "components/favicon/core/favicon_service.h" | 20 #include "components/favicon/core/favicon_service.h" |
| 20 #include "components/favicon/core/favicon_tab_helper_observer.h" | 21 #include "components/favicon/core/favicon_tab_helper_observer.h" |
| 21 #include "components/favicon_base/favicon_types.h" | 22 #include "components/favicon_base/favicon_types.h" |
| 22 #include "components/history/core/browser/history_service.h" | 23 #include "components/history/core/browser/history_service.h" |
| 23 #include "content/public/browser/favicon_status.h" | 24 #include "content/public/browser/favicon_status.h" |
| 24 #include "content/public/browser/invalidate_type.h" | 25 #include "content/public/browser/invalidate_type.h" |
| 25 #include "content/public/browser/navigation_controller.h" | 26 #include "content/public/browser/navigation_controller.h" |
| 26 #include "content/public/browser/navigation_details.h" | 27 #include "content/public/browser/navigation_details.h" |
| 27 #include "content/public/browser/navigation_entry.h" | 28 #include "content/public/browser/navigation_entry.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 // FaviconHandler has the time to determine that the favicon needs to be | 277 // FaviconHandler has the time to determine that the favicon needs to be |
| 277 // redownloaded. | 278 // redownloaded. |
| 278 GURL url = details.entry->GetURL(); | 279 GURL url = details.entry->GetURL(); |
| 279 if (url != bypass_cache_page_url_) | 280 if (url != bypass_cache_page_url_) |
| 280 bypass_cache_page_url_ = GURL(); | 281 bypass_cache_page_url_ = GURL(); |
| 281 | 282 |
| 282 // Get the favicon, either from history or request it from the net. | 283 // Get the favicon, either from history or request it from the net. |
| 283 FetchFavicon(url); | 284 FetchFavicon(url); |
| 284 } | 285 } |
| 285 | 286 |
| 286 // Returns favicon_base::IconType the given icon_type corresponds to. | |
| 287 // TODO(jif): Move function to /components/favicon_base/content/ | |
| 288 // crbug.com/374281. | |
| 289 favicon_base::IconType ToChromeIconType( | |
| 290 content::FaviconURL::IconType icon_type) { | |
| 291 switch (icon_type) { | |
| 292 case content::FaviconURL::FAVICON: | |
| 293 return favicon_base::FAVICON; | |
| 294 case content::FaviconURL::TOUCH_ICON: | |
| 295 return favicon_base::TOUCH_ICON; | |
| 296 case content::FaviconURL::TOUCH_PRECOMPOSED_ICON: | |
| 297 return favicon_base::TOUCH_PRECOMPOSED_ICON; | |
| 298 case content::FaviconURL::INVALID_ICON: | |
| 299 return favicon_base::INVALID_ICON; | |
| 300 } | |
| 301 NOTREACHED(); | |
| 302 return favicon_base::INVALID_ICON; | |
| 303 } | |
| 304 | |
| 305 void FaviconTabHelper::DidUpdateFaviconURL( | 287 void FaviconTabHelper::DidUpdateFaviconURL( |
| 306 const std::vector<content::FaviconURL>& candidates) { | 288 const std::vector<content::FaviconURL>& candidates) { |
| 307 DCHECK(!candidates.empty()); | 289 DCHECK(!candidates.empty()); |
| 308 favicon_urls_ = candidates; | 290 favicon_urls_ = candidates; |
| 309 std::vector<favicon::FaviconURL> favicon_urls; | 291 std::vector<favicon::FaviconURL> favicon_urls = |
| 310 for (size_t i = 0; i < candidates.size(); i++) { | 292 favicon::FaviconURLsFromContentFaviconURLs(candidates); |
| 311 const content::FaviconURL& candidate = candidates[i]; | |
| 312 favicon_urls.push_back( | |
| 313 favicon::FaviconURL(candidate.icon_url, | |
| 314 ToChromeIconType(candidate.icon_type), | |
| 315 candidate.icon_sizes)); | |
| 316 } | |
| 317 favicon_handler_->OnUpdateFaviconURL(favicon_urls); | 293 favicon_handler_->OnUpdateFaviconURL(favicon_urls); |
| 318 if (touch_icon_handler_.get()) | 294 if (touch_icon_handler_.get()) |
| 319 touch_icon_handler_->OnUpdateFaviconURL(favicon_urls); | 295 touch_icon_handler_->OnUpdateFaviconURL(favicon_urls); |
| 320 if (large_icon_handler_.get()) | 296 if (large_icon_handler_.get()) |
| 321 large_icon_handler_->OnUpdateFaviconURL(favicon_urls); | 297 large_icon_handler_->OnUpdateFaviconURL(favicon_urls); |
| 322 } | 298 } |
| 323 | 299 |
| 324 void FaviconTabHelper::DidDownloadFavicon( | 300 void FaviconTabHelper::DidDownloadFavicon( |
| 325 int id, | 301 int id, |
| 326 int http_status_code, | 302 int http_status_code, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 340 id, image_url, bitmaps, original_bitmap_sizes); | 316 id, image_url, bitmaps, original_bitmap_sizes); |
| 341 if (touch_icon_handler_.get()) { | 317 if (touch_icon_handler_.get()) { |
| 342 touch_icon_handler_->OnDidDownloadFavicon( | 318 touch_icon_handler_->OnDidDownloadFavicon( |
| 343 id, image_url, bitmaps, original_bitmap_sizes); | 319 id, image_url, bitmaps, original_bitmap_sizes); |
| 344 } | 320 } |
| 345 if (large_icon_handler_.get()) { | 321 if (large_icon_handler_.get()) { |
| 346 large_icon_handler_->OnDidDownloadFavicon( | 322 large_icon_handler_->OnDidDownloadFavicon( |
| 347 id, image_url, bitmaps, original_bitmap_sizes); | 323 id, image_url, bitmaps, original_bitmap_sizes); |
| 348 } | 324 } |
| 349 } | 325 } |
| OLD | NEW |