| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/jumplist_win.h" | 5 #include "chrome/browser/jumplist_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shobjidl.h> | 8 #include <shobjidl.h> |
| 9 #include <propkey.h> | 9 #include <propkey.h> |
| 10 #include <propvarutil.h> | 10 #include <propvarutil.h> |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 bool JumpList::StartLoadingFavIcon() { | 681 bool JumpList::StartLoadingFavIcon() { |
| 682 if (icon_urls_.empty()) | 682 if (icon_urls_.empty()) |
| 683 return false; | 683 return false; |
| 684 | 684 |
| 685 // Ask FaviconService if it has a favicon of a URL. | 685 // Ask FaviconService if it has a favicon of a URL. |
| 686 // When FaviconService has one, it will call OnFaviconDataAvailable(). | 686 // When FaviconService has one, it will call OnFaviconDataAvailable(). |
| 687 GURL url(icon_urls_.front().first); | 687 GURL url(icon_urls_.front().first); |
| 688 FaviconService* favicon_service = | 688 FaviconService* favicon_service = |
| 689 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); | 689 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); |
| 690 FaviconService::Handle handle = favicon_service->GetFaviconForURL( | 690 FaviconService::Handle handle = favicon_service->GetFaviconForURL( |
| 691 url, &favicon_consumer_, | 691 url, history::FAVICON, &favicon_consumer_, |
| 692 NewCallback(this, &JumpList::OnFaviconDataAvailable)); | 692 NewCallback(this, &JumpList::OnFaviconDataAvailable)); |
| 693 return true; | 693 return true; |
| 694 } | 694 } |
| 695 | 695 |
| 696 void JumpList::OnSegmentUsageAvailable( | 696 void JumpList::OnSegmentUsageAvailable( |
| 697 CancelableRequestProvider::Handle handle, | 697 CancelableRequestProvider::Handle handle, |
| 698 std::vector<PageUsageData*>* data) { | 698 std::vector<PageUsageData*>* data) { |
| 699 // Create a list of ShellLinkItem objects from the given list of | 699 // Create a list of ShellLinkItem objects from the given list of |
| 700 // PageUsageData objects. | 700 // PageUsageData objects. |
| 701 // The command that opens a web page with chrome is: | 701 // The command that opens a web page with chrome is: |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 &recently_closed_pages_, kRecentlyClosedCount); | 746 &recently_closed_pages_, kRecentlyClosedCount); |
| 747 } | 747 } |
| 748 } | 748 } |
| 749 | 749 |
| 750 // Send a query that retrieves the first favicon. | 750 // Send a query that retrieves the first favicon. |
| 751 StartLoadingFavIcon(); | 751 StartLoadingFavIcon(); |
| 752 } | 752 } |
| 753 | 753 |
| 754 void JumpList::OnFaviconDataAvailable( | 754 void JumpList::OnFaviconDataAvailable( |
| 755 FaviconService::Handle handle, | 755 FaviconService::Handle handle, |
| 756 bool know_favicon, | 756 history::FaviconData favicon) { |
| 757 scoped_refptr<RefCountedMemory> data, | |
| 758 bool expired, | |
| 759 GURL icon_url) { | |
| 760 // Attach the received data to the ShellLinkItem object. | 757 // Attach the received data to the ShellLinkItem object. |
| 761 // This data will be decoded by JumpListUpdateTask. | 758 // This data will be decoded by JumpListUpdateTask. |
| 762 if (know_favicon && data.get() && data->size()) { | 759 if (favicon.is_valid()) { |
| 763 if (!icon_urls_.empty() && icon_urls_.front().second) | 760 if (!icon_urls_.empty() && icon_urls_.front().second) |
| 764 icon_urls_.front().second->SetIconData(data); | 761 icon_urls_.front().second->SetIconData(favicon.image_data); |
| 765 } | 762 } |
| 766 | 763 |
| 767 // if we need to load more favicons, we send another query and exit. | 764 // if we need to load more favicons, we send another query and exit. |
| 768 if (!icon_urls_.empty()) | 765 if (!icon_urls_.empty()) |
| 769 icon_urls_.pop_front(); | 766 icon_urls_.pop_front(); |
| 770 if (StartLoadingFavIcon()) | 767 if (StartLoadingFavIcon()) |
| 771 return; | 768 return; |
| 772 | 769 |
| 773 // Finished loading all favicons needed by the application JumpList. | 770 // Finished loading all favicons needed by the application JumpList. |
| 774 // We create a JumpListUpdateTask that creates icon files, and we post it to | 771 // We create a JumpListUpdateTask that creates icon files, and we post it to |
| 775 // the file thread. | 772 // the file thread. |
| 776 BrowserThread::PostTask( | 773 BrowserThread::PostTask( |
| 777 BrowserThread::FILE, FROM_HERE, | 774 BrowserThread::FILE, FROM_HERE, |
| 778 new JumpListUpdateTask(app_id_.c_str(), icon_dir_, most_visited_pages_, | 775 new JumpListUpdateTask(app_id_.c_str(), icon_dir_, most_visited_pages_, |
| 779 recently_closed_pages_)); | 776 recently_closed_pages_)); |
| 780 | 777 |
| 781 // Delete all items in these lists since we don't need these lists any longer. | 778 // Delete all items in these lists since we don't need these lists any longer. |
| 782 most_visited_pages_.clear(); | 779 most_visited_pages_.clear(); |
| 783 recently_closed_pages_.clear(); | 780 recently_closed_pages_.clear(); |
| 784 } | 781 } |
| OLD | NEW |