Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: components/favicon/core/large_icon_service.cc

Issue 2883293002: LargeIconService returns icon of the desired size (Closed)
Patch Set: Add comment and change the logic of the min size Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/favicon/core/large_icon_service.h" 5 #include "components/favicon/core/large_icon_service.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 301
302 } // namespace 302 } // namespace
303 303
304 LargeIconService::LargeIconService( 304 LargeIconService::LargeIconService(
305 FaviconService* favicon_service, 305 FaviconService* favicon_service,
306 const scoped_refptr<base::TaskRunner>& background_task_runner, 306 const scoped_refptr<base::TaskRunner>& background_task_runner,
307 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher) 307 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher)
308 : favicon_service_(favicon_service), 308 : favicon_service_(favicon_service),
309 background_task_runner_(background_task_runner), 309 background_task_runner_(background_task_runner),
310 image_fetcher_(std::move(image_fetcher)) { 310 image_fetcher_(std::move(image_fetcher)) {
311 large_icon_types_.push_back(favicon_base::IconType::FAVICON); 311 large_icon_types_.push_back(favicon_base::IconType::FAVICON);
jkrcal 2017/05/18 12:33:55 Actually another fix for the issue could be using
gambard 2017/05/18 13:43:59 Yes but I think we want to have a preference. I re
jkrcal 2017/05/18 13:50:59 Okay, let's keep it as it is now.
312 large_icon_types_.push_back(favicon_base::IconType::TOUCH_ICON); 312 large_icon_types_.push_back(favicon_base::IconType::TOUCH_ICON);
313 large_icon_types_.push_back(favicon_base::IconType::TOUCH_PRECOMPOSED_ICON); 313 large_icon_types_.push_back(favicon_base::IconType::TOUCH_PRECOMPOSED_ICON);
314 } 314 }
315 315
316 LargeIconService::~LargeIconService() { 316 LargeIconService::~LargeIconService() {
317 } 317 }
318 318
319 base::CancelableTaskTracker::TaskId 319 base::CancelableTaskTracker::TaskId
320 LargeIconService::GetLargeIconOrFallbackStyle( 320 LargeIconService::GetLargeIconOrFallbackStyle(
321 const GURL& page_url, 321 const GURL& page_url,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 const favicon_base::LargeIconCallback& raw_bitmap_callback, 378 const favicon_base::LargeIconCallback& raw_bitmap_callback,
379 const favicon_base::LargeIconImageCallback& image_callback, 379 const favicon_base::LargeIconImageCallback& image_callback,
380 base::CancelableTaskTracker* tracker) { 380 base::CancelableTaskTracker* tracker) {
381 DCHECK_LE(1, min_source_size_in_pixel); 381 DCHECK_LE(1, min_source_size_in_pixel);
382 DCHECK_LE(0, desired_size_in_pixel); 382 DCHECK_LE(0, desired_size_in_pixel);
383 383
384 scoped_refptr<LargeIconWorker> worker = new LargeIconWorker( 384 scoped_refptr<LargeIconWorker> worker = new LargeIconWorker(
385 min_source_size_in_pixel, desired_size_in_pixel, raw_bitmap_callback, 385 min_source_size_in_pixel, desired_size_in_pixel, raw_bitmap_callback,
386 image_callback, background_task_runner_, tracker); 386 image_callback, background_task_runner_, tracker);
387 387
388 int max_size_in_pixel =
389 std::max(desired_size_in_pixel, min_source_size_in_pixel);
388 // TODO(beaudoin): For now this is just a wrapper around 390 // TODO(beaudoin): For now this is just a wrapper around
389 // GetLargestRawFaviconForPageURL. Add the logic required to select the best 391 // GetLargestRawFaviconForPageURL. Add the logic required to select the best
390 // possible large icon. Also add logic to fetch-on-demand when the URL of 392 // possible large icon. Also add logic to fetch-on-demand when the URL of
391 // a large icon is known but its bitmap is not available. 393 // a large icon is known but its bitmap is not available.
392 return favicon_service_->GetLargestRawFaviconForPageURL( 394 return favicon_service_->GetLargestRawFaviconForPageURL(
393 page_url, large_icon_types_, min_source_size_in_pixel, 395 page_url, large_icon_types_, max_size_in_pixel,
jkrcal 2017/05/18 12:33:55 nit: I do not like the naming. Passing in a max_si
gambard 2017/05/18 13:43:59 I don't like changing the value of arguments. but
jkrcal 2017/05/18 13:50:59 I see. ideal is better to me than max. Maybe size_
394 base::Bind(&LargeIconWorker::OnIconLookupComplete, worker), tracker); 396 base::Bind(&LargeIconWorker::OnIconLookupComplete, worker), tracker);
395 } 397 }
396 398
397 } // namespace favicon 399 } // namespace favicon
OLDNEW
« components/favicon/core/large_icon_service.h ('K') | « components/favicon/core/large_icon_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698