OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |