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

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: sync 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 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 node->set_title(l10n_util::GetStringUTF16(IDS_BOOMARK_BAR_FOLDER_NAME)); 729 node->set_title(l10n_util::GetStringUTF16(IDS_BOOMARK_BAR_FOLDER_NAME));
730 } else { 730 } else {
731 node->set_title( 731 node->set_title(
732 l10n_util::GetStringUTF16(IDS_BOOMARK_BAR_OTHER_FOLDER_NAME)); 732 l10n_util::GetStringUTF16(IDS_BOOMARK_BAR_OTHER_FOLDER_NAME));
733 } 733 }
734 return node; 734 return node;
735 } 735 }
736 736
737 void BookmarkModel::OnFaviconDataAvailable( 737 void BookmarkModel::OnFaviconDataAvailable(
738 FaviconService::Handle handle, 738 FaviconService::Handle handle,
739 bool know_favicon, 739 history::FaviconData favicon) {
740 scoped_refptr<RefCountedMemory> data, 740 SkBitmap fav_icon;
Avi (use Gerrit) 2011/03/16 17:48:36 FYI, it's favicon, not fav_icon. See crbug.com/760
741 bool expired,
742 GURL icon_url) {
743 SkBitmap favicon;
744 BookmarkNode* node = 741 BookmarkNode* node =
745 load_consumer_.GetClientData( 742 load_consumer_.GetClientData(
746 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), handle); 743 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), handle);
747 DCHECK(node); 744 DCHECK(node);
748 node->set_favicon_load_handle(0); 745 node->set_favicon_load_handle(0);
749 if (know_favicon && data.get() && data->size() && 746 if (favicon.is_valid() && gfx::PNGCodec::Decode(favicon.image_data->front(),
750 gfx::PNGCodec::Decode(data->front(), data->size(), &favicon)) { 747 favicon.image_data->size(),
751 node->set_favicon(favicon); 748 &fav_icon)) {
749 node->set_favicon(fav_icon);
752 FaviconLoaded(node); 750 FaviconLoaded(node);
753 } 751 }
754 } 752 }
755 753
756 void BookmarkModel::LoadFavicon(BookmarkNode* node) { 754 void BookmarkModel::LoadFavicon(BookmarkNode* node) {
757 if (node->type() != BookmarkNode::URL) 755 if (node->type() != BookmarkNode::URL)
758 return; 756 return;
759 757
760 DCHECK(node->GetURL().is_valid()); 758 DCHECK(node->GetURL().is_valid());
761 FaviconService* favicon_service = 759 FaviconService* favicon_service =
762 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); 760 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
763 if (!favicon_service) 761 if (!favicon_service)
764 return; 762 return;
765 FaviconService::Handle handle = favicon_service->GetFaviconForURL( 763 FaviconService::Handle handle = favicon_service->GetFaviconForURL(
766 node->GetURL(), &load_consumer_, 764 node->GetURL(), history::FAVICON, &load_consumer_,
767 NewCallback(this, &BookmarkModel::OnFaviconDataAvailable)); 765 NewCallback(this, &BookmarkModel::OnFaviconDataAvailable));
768 load_consumer_.SetClientData(favicon_service, handle, node); 766 load_consumer_.SetClientData(favicon_service, handle, node);
769 node->set_favicon_load_handle(handle); 767 node->set_favicon_load_handle(handle);
770 } 768 }
771 769
772 void BookmarkModel::CancelPendingFaviconLoadRequests(BookmarkNode* node) { 770 void BookmarkModel::CancelPendingFaviconLoadRequests(BookmarkNode* node) {
773 if (node->favicon_load_handle()) { 771 if (node->favicon_load_handle()) {
774 FaviconService* favicon_service = 772 FaviconService* favicon_service =
775 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); 773 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
776 if (favicon_service) 774 if (favicon_service)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 void BookmarkModel::SetFileChanged() { 822 void BookmarkModel::SetFileChanged() {
825 file_changed_ = true; 823 file_changed_ = true;
826 } 824 }
827 825
828 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() { 826 BookmarkLoadDetails* BookmarkModel::CreateLoadDetails() {
829 BookmarkNode* bb_node = CreateBookmarkNode(); 827 BookmarkNode* bb_node = CreateBookmarkNode();
830 BookmarkNode* other_folder_node = CreateOtherBookmarksNode(); 828 BookmarkNode* other_folder_node = CreateOtherBookmarksNode();
831 return new BookmarkLoadDetails( 829 return new BookmarkLoadDetails(
832 bb_node, other_folder_node, new BookmarkIndex(profile()), next_node_id_); 830 bb_node, other_folder_node, new BookmarkIndex(profile()), next_node_id_);
833 } 831 }
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_model.h ('k') | chrome/browser/custom_home_pages_table_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698