Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/win/jumplist.h" | 5 #include "chrome/browser/win/jumplist.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 515 if (!waiting_for_icons) { | 515 if (!waiting_for_icons) { |
| 516 // No more favicons are needed by the application JumpList. Schedule a | 516 // No more favicons are needed by the application JumpList. Schedule a |
| 517 // RunUpdateOnFileThread call. | 517 // RunUpdateOnFileThread call. |
| 518 PostRunUpdate(); | 518 PostRunUpdate(); |
| 519 return; | 519 return; |
| 520 } | 520 } |
| 521 | 521 |
| 522 favicon::FaviconService* favicon_service = | 522 favicon::FaviconService* favicon_service = |
| 523 FaviconServiceFactory::GetForProfile(profile_, | 523 FaviconServiceFactory::GetForProfile(profile_, |
| 524 ServiceAccessType::EXPLICIT_ACCESS); | 524 ServiceAccessType::EXPLICIT_ACCESS); |
| 525 task_id_ = favicon_service->GetFaviconImageForPageURL( | 525 task_id_ = favicon_service->GetRawFaviconForPageURL( |
| 526 url, | 526 url, favicon_base::FAVICON, 0, |
|
sky
2017/01/30 23:56:11
Supplying 0 for a size may result in a large sized
chengx
2017/01/31 00:39:38
The original API, i.e., GetFaviconImageForPageURL,
| |
| 527 base::Bind(&JumpList::OnFaviconDataAvailable, base::Unretained(this)), | 527 base::Bind(&JumpList::OnFaviconDataAvailable, base::Unretained(this)), |
| 528 &cancelable_task_tracker_); | 528 &cancelable_task_tracker_); |
| 529 } | 529 } |
| 530 | 530 |
| 531 void JumpList::OnFaviconDataAvailable( | 531 void JumpList::OnFaviconDataAvailable( |
| 532 const favicon_base::FaviconImageResult& image_result) { | 532 const favicon_base::FaviconRawBitmapResult& image_result) { |
| 533 DCHECK(CalledOnValidThread()); | 533 DCHECK(CalledOnValidThread()); |
| 534 | 534 |
| 535 // If there is currently a favicon request in progress, it is now outdated, | 535 // If there is currently a favicon request in progress, it is now outdated, |
| 536 // as we have received another, so nullify the handle from the old request. | 536 // as we have received another, so nullify the handle from the old request. |
| 537 task_id_ = base::CancelableTaskTracker::kBadTaskId; | 537 task_id_ = base::CancelableTaskTracker::kBadTaskId; |
| 538 // Lock the list to set icon data and pop the url. | 538 // Lock the list to set icon data and pop the url. |
| 539 { | 539 { |
| 540 JumpListData* data = &jumplist_data_->data; | 540 JumpListData* data = &jumplist_data_->data; |
| 541 base::AutoLock auto_lock(data->list_lock_); | 541 base::AutoLock auto_lock(data->list_lock_); |
| 542 // Attach the received data to the ShellLinkItem object. | 542 // Attach the received data to the ShellLinkItem object. |
| 543 // This data will be decoded by the RunUpdateOnFileThread method. | 543 // This data will be decoded by the RunUpdateOnFileThread method. |
| 544 if (!image_result.image.IsEmpty()) { | 544 if (image_result.is_valid()) { |
| 545 if (!data->icon_urls_.empty() && data->icon_urls_.front().second.get()) | 545 if (!data->icon_urls_.empty() && data->icon_urls_.front().second.get()) |
| 546 data->icon_urls_.front().second->set_icon_data( | 546 data->icon_urls_.front().second->set_icon_data( |
| 547 image_result.image.AsBitmap()); | 547 gfx::Image::CreateFrom1xPNGBytes(image_result.bitmap_data) |
|
grt (UTC plus 2)
2017/01/30 10:02:40
Is it necessarily the case that the favicon bitmap
chengx
2017/01/31 00:39:38
Sure.
| |
| 548 .AsBitmap()); | |
| 548 } | 549 } |
| 549 | 550 |
| 550 if (!data->icon_urls_.empty()) | 551 if (!data->icon_urls_.empty()) |
| 551 data->icon_urls_.pop_front(); | 552 data->icon_urls_.pop_front(); |
| 552 } | 553 } |
| 553 // Check whether we need to load more favicons. | 554 // Check whether we need to load more favicons. |
| 554 StartLoadingFavicon(); | 555 StartLoadingFavicon(); |
| 555 } | 556 } |
| 556 | 557 |
| 557 void JumpList::OnIncognitoAvailabilityChanged() { | 558 void JumpList::OnIncognitoAvailabilityChanged() { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 608 void JumpList::TopSitesLoaded(history::TopSites* top_sites) { | 609 void JumpList::TopSitesLoaded(history::TopSites* top_sites) { |
| 609 } | 610 } |
| 610 | 611 |
| 611 void JumpList::TopSitesChanged(history::TopSites* top_sites, | 612 void JumpList::TopSitesChanged(history::TopSites* top_sites, |
| 612 ChangeReason change_reason) { | 613 ChangeReason change_reason) { |
| 613 top_sites->GetMostVisitedURLs( | 614 top_sites->GetMostVisitedURLs( |
| 614 base::Bind(&JumpList::OnMostVisitedURLsAvailable, | 615 base::Bind(&JumpList::OnMostVisitedURLsAvailable, |
| 615 weak_ptr_factory_.GetWeakPtr()), | 616 weak_ptr_factory_.GetWeakPtr()), |
| 616 false); | 617 false); |
| 617 } | 618 } |
| OLD | NEW |