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

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

Issue 763903003: bookmarks: Only try to get favicon for URL nodes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/bookmarks/browser/bookmark_model.h" 5 #include "components/bookmarks/browser/bookmark_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 bookmarks::CloneBookmarkNode(this, elements, new_parent, index, true); 296 bookmarks::CloneBookmarkNode(this, elements, new_parent, index, true);
297 297
298 if (store_.get()) 298 if (store_.get())
299 store_->ScheduleSave(); 299 store_->ScheduleSave();
300 } 300 }
301 301
302 const gfx::Image& BookmarkModel::GetFavicon(const BookmarkNode* node) { 302 const gfx::Image& BookmarkModel::GetFavicon(const BookmarkNode* node) {
303 DCHECK(node); 303 DCHECK(node);
304 if (node->favicon_state() == BookmarkNode::INVALID_FAVICON) { 304 if (node->favicon_state() == BookmarkNode::INVALID_FAVICON) {
305 BookmarkNode* mutable_node = AsMutable(node); 305 BookmarkNode* mutable_node = AsMutable(node);
306 LoadFavicon( 306 LoadFavicon(mutable_node,
307 mutable_node, 307 client_->PreferTouchIcon() ? favicon_base::TOUCH_ICON
308 client_->PreferTouchIcon() ? 308 : favicon_base::FAVICON);
309 favicon_base::TOUCH_ICON :
310 favicon_base::FAVICON);
311 } 309 }
312 return node->favicon(); 310 return node->favicon();
313 } 311 }
314 312
315 favicon_base::IconType BookmarkModel::GetFaviconType(const BookmarkNode* node) { 313 favicon_base::IconType BookmarkModel::GetFaviconType(const BookmarkNode* node) {
316 DCHECK(node); 314 DCHECK(node);
317 return node->favicon_type(); 315 return node->favicon_type();
318 } 316 }
319 317
320 void BookmarkModel::SetTitle(const BookmarkNode* node, 318 void BookmarkModel::SetTitle(const BookmarkNode* node,
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 node->set_favicon(image_result.image); 957 node->set_favicon(image_result.image);
960 node->set_icon_url(image_result.icon_url); 958 node->set_icon_url(image_result.icon_url);
961 FaviconLoaded(node); 959 FaviconLoaded(node);
962 } else if (icon_type == favicon_base::TOUCH_ICON) { 960 } else if (icon_type == favicon_base::TOUCH_ICON) {
963 // Couldn't load the touch icon, fallback to the regular favicon. 961 // Couldn't load the touch icon, fallback to the regular favicon.
964 DCHECK(client_->PreferTouchIcon()); 962 DCHECK(client_->PreferTouchIcon());
965 LoadFavicon(node, favicon_base::FAVICON); 963 LoadFavicon(node, favicon_base::FAVICON);
966 } 964 }
967 } 965 }
968 966
969 void BookmarkModel::LoadFavicon( 967 void BookmarkModel::LoadFavicon(BookmarkNode* node,
970 BookmarkNode* node, 968 favicon_base::IconType icon_type) {
971 favicon_base::IconType icon_type) {
972 if (node->is_folder()) 969 if (node->is_folder())
973 return; 970 return;
974 971
975 DCHECK(node->url().is_valid()); 972 DCHECK(node->url().is_valid());
976 node->set_favicon_state(BookmarkNode::LOADING_FAVICON); 973 node->set_favicon_state(BookmarkNode::LOADING_FAVICON);
977 base::CancelableTaskTracker::TaskId taskId = 974 base::CancelableTaskTracker::TaskId taskId =
978 client_->GetFaviconImageForPageURL( 975 client_->GetFaviconImageForPageURL(
979 node->url(), 976 node->url(),
980 icon_type, 977 icon_type,
981 base::Bind( 978 base::Bind(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 BookmarkPermanentNode* mobile_node = 1019 BookmarkPermanentNode* mobile_node =
1023 CreatePermanentNode(BookmarkNode::MOBILE); 1020 CreatePermanentNode(BookmarkNode::MOBILE);
1024 return scoped_ptr<BookmarkLoadDetails>(new BookmarkLoadDetails( 1021 return scoped_ptr<BookmarkLoadDetails>(new BookmarkLoadDetails(
1025 bb_node, 1022 bb_node,
1026 other_node, 1023 other_node,
1027 mobile_node, 1024 mobile_node,
1028 client_->GetLoadExtraNodesCallback(), 1025 client_->GetLoadExtraNodesCallback(),
1029 new BookmarkIndex(client_, accept_languages), 1026 new BookmarkIndex(client_, accept_languages),
1030 next_node_id_)); 1027 next_node_id_));
1031 } 1028 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698