| 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 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 } | 952 } |
| 953 | 953 |
| 954 void BookmarkModel::LoadFavicon( | 954 void BookmarkModel::LoadFavicon( |
| 955 BookmarkNode* node, | 955 BookmarkNode* node, |
| 956 favicon_base::IconType icon_type) { | 956 favicon_base::IconType icon_type) { |
| 957 if (node->is_folder()) | 957 if (node->is_folder()) |
| 958 return; | 958 return; |
| 959 | 959 |
| 960 DCHECK(node->url().is_valid()); | 960 DCHECK(node->url().is_valid()); |
| 961 node->set_favicon_state(BookmarkNode::LOADING_FAVICON); | 961 node->set_favicon_state(BookmarkNode::LOADING_FAVICON); |
| 962 base::CancelableTaskTracker::TaskId taskId = client_->GetFaviconImageForURL( | 962 base::CancelableTaskTracker::TaskId task_id = |
| 963 node->url(), | 963 base::CancelableTaskTracker::kBadTaskId; |
| 964 icon_type, | 964 if (icon_type == favicon_base::FAVICON) { |
| 965 icon_type == favicon_base::FAVICON ? gfx::kFaviconSize : 0, | 965 task_id = client_->GetFaviconImageForPageURL( |
| 966 base::Bind( | 966 node->url(), |
| 967 &BookmarkModel::OnFaviconDataAvailable, | 967 base::Bind( |
| 968 base::Unretained(this), | 968 &BookmarkModel::OnFaviconDataAvailable, |
| 969 node, | 969 base::Unretained(this), |
| 970 icon_type), | 970 node, |
| 971 &cancelable_task_tracker_); | 971 icon_type), |
| 972 if (taskId != base::CancelableTaskTracker::kBadTaskId) | 972 &cancelable_task_tracker_); |
| 973 node->set_favicon_load_task_id(taskId); | 973 } else { |
| 974 task_id = client_->GetTouchFaviconImageForPageURL( |
| 975 node->url(), |
| 976 base::Bind( |
| 977 &BookmarkModel::OnFaviconDataAvailable, |
| 978 base::Unretained(this), |
| 979 node, |
| 980 icon_type), |
| 981 &cancelable_task_tracker_); |
| 982 } |
| 983 if (task_id != base::CancelableTaskTracker::kBadTaskId) |
| 984 node->set_favicon_load_task_id(task_id); |
| 974 } | 985 } |
| 975 | 986 |
| 976 void BookmarkModel::FaviconLoaded(const BookmarkNode* node) { | 987 void BookmarkModel::FaviconLoaded(const BookmarkNode* node) { |
| 977 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_, | 988 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_, |
| 978 BookmarkNodeFaviconChanged(this, node)); | 989 BookmarkNodeFaviconChanged(this, node)); |
| 979 } | 990 } |
| 980 | 991 |
| 981 void BookmarkModel::CancelPendingFaviconLoadRequests(BookmarkNode* node) { | 992 void BookmarkModel::CancelPendingFaviconLoadRequests(BookmarkNode* node) { |
| 982 if (node->favicon_load_task_id() != base::CancelableTaskTracker::kBadTaskId) { | 993 if (node->favicon_load_task_id() != base::CancelableTaskTracker::kBadTaskId) { |
| 983 cancelable_task_tracker_.TryCancel(node->favicon_load_task_id()); | 994 cancelable_task_tracker_.TryCancel(node->favicon_load_task_id()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1007 BookmarkPermanentNode* mobile_node = | 1018 BookmarkPermanentNode* mobile_node = |
| 1008 CreatePermanentNode(BookmarkNode::MOBILE); | 1019 CreatePermanentNode(BookmarkNode::MOBILE); |
| 1009 return scoped_ptr<BookmarkLoadDetails>(new BookmarkLoadDetails( | 1020 return scoped_ptr<BookmarkLoadDetails>(new BookmarkLoadDetails( |
| 1010 bb_node, | 1021 bb_node, |
| 1011 other_node, | 1022 other_node, |
| 1012 mobile_node, | 1023 mobile_node, |
| 1013 client_->GetLoadExtraNodesCallback(), | 1024 client_->GetLoadExtraNodesCallback(), |
| 1014 new BookmarkIndex(client_, index_urls_, accept_languages), | 1025 new BookmarkIndex(client_, index_urls_, accept_languages), |
| 1015 next_node_id_)); | 1026 next_node_id_)); |
| 1016 } | 1027 } |
| OLD | NEW |