Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bookmarks/bookmark_model.h" | 5 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 730 l10n_util::GetStringUTF16(IDS_BOOMARK_BAR_OTHER_FOLDER_NAME)); | 730 l10n_util::GetStringUTF16(IDS_BOOMARK_BAR_OTHER_FOLDER_NAME)); |
| 731 } | 731 } |
| 732 return node; | 732 return node; |
| 733 } | 733 } |
| 734 | 734 |
| 735 void BookmarkModel::OnFavIconDataAvailable( | 735 void BookmarkModel::OnFavIconDataAvailable( |
| 736 FaviconService::Handle handle, | 736 FaviconService::Handle handle, |
| 737 bool know_favicon, | 737 bool know_favicon, |
| 738 scoped_refptr<RefCountedMemory> data, | 738 scoped_refptr<RefCountedMemory> data, |
| 739 bool expired, | 739 bool expired, |
| 740 GURL icon_url) { | 740 GURL icon_url, |
| 741 history::IconType) { | |
|
sky
2011/03/09 21:41:08
Include name.
michaelbai
2011/03/09 23:11:45
Done.
| |
| 741 SkBitmap fav_icon; | 742 SkBitmap fav_icon; |
| 742 BookmarkNode* node = | 743 BookmarkNode* node = |
| 743 load_consumer_.GetClientData( | 744 load_consumer_.GetClientData( |
| 744 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), handle); | 745 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), handle); |
| 745 DCHECK(node); | 746 DCHECK(node); |
| 746 node->set_favicon_load_handle(0); | 747 node->set_favicon_load_handle(0); |
| 747 if (know_favicon && data.get() && data->size() && | 748 if (know_favicon && data.get() && data->size() && |
| 748 gfx::PNGCodec::Decode(data->front(), data->size(), &fav_icon)) { | 749 gfx::PNGCodec::Decode(data->front(), data->size(), &fav_icon)) { |
| 749 node->set_favicon(fav_icon); | 750 node->set_favicon(fav_icon); |
| 750 FavIconLoaded(node); | 751 FavIconLoaded(node); |
| 751 } | 752 } |
| 752 } | 753 } |
| 753 | 754 |
| 754 void BookmarkModel::LoadFavIcon(BookmarkNode* node) { | 755 void BookmarkModel::LoadFavIcon(BookmarkNode* node) { |
| 755 if (node->type() != BookmarkNode::URL) | 756 if (node->type() != BookmarkNode::URL) |
| 756 return; | 757 return; |
| 757 | 758 |
| 758 DCHECK(node->GetURL().is_valid()); | 759 DCHECK(node->GetURL().is_valid()); |
| 759 FaviconService* favicon_service = | 760 FaviconService* favicon_service = |
| 760 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); | 761 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); |
| 761 if (!favicon_service) | 762 if (!favicon_service) |
| 762 return; | 763 return; |
| 763 FaviconService::Handle handle = favicon_service->GetFaviconForURL( | 764 FaviconService::Handle handle = favicon_service->GetFaviconForURL( |
| 764 node->GetURL(), &load_consumer_, | 765 node->GetURL(), |
| 766 history::FAV_ICON, | |
| 767 &load_consumer_, | |
| 765 NewCallback(this, &BookmarkModel::OnFavIconDataAvailable)); | 768 NewCallback(this, &BookmarkModel::OnFavIconDataAvailable)); |
| 766 load_consumer_.SetClientData(favicon_service, handle, node); | 769 load_consumer_.SetClientData(favicon_service, handle, node); |
| 767 node->set_favicon_load_handle(handle); | 770 node->set_favicon_load_handle(handle); |
| 768 } | 771 } |
| 769 | 772 |
| 770 void BookmarkModel::CancelPendingFavIconLoadRequests(BookmarkNode* node) { | 773 void BookmarkModel::CancelPendingFavIconLoadRequests(BookmarkNode* node) { |
| 771 if (node->favicon_load_handle()) { | 774 if (node->favicon_load_handle()) { |
| 772 FaviconService* favicon_service = | 775 FaviconService* favicon_service = |
| 773 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); | 776 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); |
| 774 if (favicon_service) | 777 if (favicon_service) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 822 void BookmarkModel::SetFileChanged() { | 825 void BookmarkModel::SetFileChanged() { |
| 823 file_changed_ = true; | 826 file_changed_ = true; |
| 824 } | 827 } |
| 825 | 828 |
| 826 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() { | 829 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() { |
| 827 BookmarkNode* bb_node = CreateBookmarkNode(); | 830 BookmarkNode* bb_node = CreateBookmarkNode(); |
| 828 BookmarkNode* other_folder_node = CreateOtherBookmarksNode(); | 831 BookmarkNode* other_folder_node = CreateOtherBookmarksNode(); |
| 829 return new BookmarkLoadDetails( | 832 return new BookmarkLoadDetails( |
| 830 bb_node, other_folder_node, new BookmarkIndex(profile()), next_node_id_); | 833 bb_node, other_folder_node, new BookmarkIndex(profile()), next_node_id_); |
| 831 } | 834 } |
| OLD | NEW |