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

Side by Side Diff: chrome/browser/bookmarks/bookmark_model.cc

Issue 6651014: Applied the IconType. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Addressed the comments Created 9 years, 9 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 | Annotate | Revision Log
OLDNEW
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 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 node->SetTitle(l10n_util::GetStringUTF16(IDS_BOOMARK_BAR_FOLDER_NAME)); 727 node->SetTitle(l10n_util::GetStringUTF16(IDS_BOOMARK_BAR_FOLDER_NAME));
728 } else { 728 } else {
729 node->SetTitle( 729 node->SetTitle(
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 history::FaviconData favicon) {
738 scoped_refptr<RefCountedMemory> data,
739 bool expired,
740 GURL icon_url) {
741 SkBitmap fav_icon; 738 SkBitmap fav_icon;
742 BookmarkNode* node = 739 BookmarkNode* node =
743 load_consumer_.GetClientData( 740 load_consumer_.GetClientData(
744 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), handle); 741 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), handle);
745 DCHECK(node); 742 DCHECK(node);
746 node->set_favicon_load_handle(0); 743 node->set_favicon_load_handle(0);
747 if (know_favicon && data.get() && data->size() && 744 if (favicon.is_valid() && gfx::PNGCodec::Decode(favicon.image_data->front(),
748 gfx::PNGCodec::Decode(data->front(), data->size(), &fav_icon)) { 745 favicon.image_data->size(),
746 &fav_icon)) {
749 node->set_favicon(fav_icon); 747 node->set_favicon(fav_icon);
750 FavIconLoaded(node); 748 FavIconLoaded(node);
751 } 749 }
752 } 750 }
753 751
754 void BookmarkModel::LoadFavIcon(BookmarkNode* node) { 752 void BookmarkModel::LoadFavIcon(BookmarkNode* node) {
755 if (node->type() != BookmarkNode::URL) 753 if (node->type() != BookmarkNode::URL)
756 return; 754 return;
757 755
758 DCHECK(node->GetURL().is_valid()); 756 DCHECK(node->GetURL().is_valid());
759 FaviconService* favicon_service = 757 FaviconService* favicon_service =
760 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); 758 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
761 if (!favicon_service) 759 if (!favicon_service)
762 return; 760 return;
763 FaviconService::Handle handle = favicon_service->GetFaviconForURL( 761 FaviconService::Handle handle = favicon_service->GetFaviconForURL(
764 node->GetURL(), &load_consumer_, 762 node->GetURL(), history::FAV_ICON, &load_consumer_,
765 NewCallback(this, &BookmarkModel::OnFavIconDataAvailable)); 763 NewCallback(this, &BookmarkModel::OnFavIconDataAvailable));
766 load_consumer_.SetClientData(favicon_service, handle, node); 764 load_consumer_.SetClientData(favicon_service, handle, node);
767 node->set_favicon_load_handle(handle); 765 node->set_favicon_load_handle(handle);
768 } 766 }
769 767
770 void BookmarkModel::CancelPendingFavIconLoadRequests(BookmarkNode* node) { 768 void BookmarkModel::CancelPendingFavIconLoadRequests(BookmarkNode* node) {
771 if (node->favicon_load_handle()) { 769 if (node->favicon_load_handle()) {
772 FaviconService* favicon_service = 770 FaviconService* favicon_service =
773 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); 771 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
774 if (favicon_service) 772 if (favicon_service)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 void BookmarkModel::SetFileChanged() { 820 void BookmarkModel::SetFileChanged() {
823 file_changed_ = true; 821 file_changed_ = true;
824 } 822 }
825 823
826 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() { 824 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() {
827 BookmarkNode* bb_node = CreateBookmarkNode(); 825 BookmarkNode* bb_node = CreateBookmarkNode();
828 BookmarkNode* other_folder_node = CreateOtherBookmarksNode(); 826 BookmarkNode* other_folder_node = CreateOtherBookmarksNode();
829 return new BookmarkLoadDetails( 827 return new BookmarkLoadDetails(
830 bb_node, other_folder_node, new BookmarkIndex(profile()), next_node_id_); 828 bb_node, other_folder_node, new BookmarkIndex(profile()), next_node_id_);
831 } 829 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698