| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 10 #include "base/bind.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 131 |
| 132 const BookmarkNode::MetaInfoMap* BookmarkNode::GetMetaInfoMap() const { | 132 const BookmarkNode::MetaInfoMap* BookmarkNode::GetMetaInfoMap() const { |
| 133 return meta_info_map_.get(); | 133 return meta_info_map_.get(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void BookmarkNode::Initialize(int64 id) { | 136 void BookmarkNode::Initialize(int64 id) { |
| 137 id_ = id; | 137 id_ = id; |
| 138 type_ = url_.is_empty() ? FOLDER : URL; | 138 type_ = url_.is_empty() ? FOLDER : URL; |
| 139 date_added_ = Time::Now(); | 139 date_added_ = Time::Now(); |
| 140 favicon_state_ = INVALID_FAVICON; | 140 favicon_state_ = INVALID_FAVICON; |
| 141 favicon_load_task_id_ = CancelableTaskTracker::kBadTaskId; | 141 favicon_load_task_id_ = base::CancelableTaskTracker::kBadTaskId; |
| 142 meta_info_map_.reset(); | 142 meta_info_map_.reset(); |
| 143 sync_transaction_version_ = kInvalidSyncTransactionVersion; | 143 sync_transaction_version_ = kInvalidSyncTransactionVersion; |
| 144 } | 144 } |
| 145 | 145 |
| 146 void BookmarkNode::InvalidateFavicon() { | 146 void BookmarkNode::InvalidateFavicon() { |
| 147 icon_url_ = GURL(); | 147 icon_url_ = GURL(); |
| 148 favicon_ = gfx::Image(); | 148 favicon_ = gfx::Image(); |
| 149 favicon_state_ = INVALID_FAVICON; | 149 favicon_state_ = INVALID_FAVICON; |
| 150 } | 150 } |
| 151 | 151 |
| (...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 } | 980 } |
| 981 node->SetTitle(l10n_util::GetStringUTF16(title_id)); | 981 node->SetTitle(l10n_util::GetStringUTF16(title_id)); |
| 982 node->set_type(type); | 982 node->set_type(type); |
| 983 return node; | 983 return node; |
| 984 } | 984 } |
| 985 | 985 |
| 986 void BookmarkModel::OnFaviconDataAvailable( | 986 void BookmarkModel::OnFaviconDataAvailable( |
| 987 BookmarkNode* node, | 987 BookmarkNode* node, |
| 988 const chrome::FaviconImageResult& image_result) { | 988 const chrome::FaviconImageResult& image_result) { |
| 989 DCHECK(node); | 989 DCHECK(node); |
| 990 node->set_favicon_load_task_id(CancelableTaskTracker::kBadTaskId); | 990 node->set_favicon_load_task_id(base::CancelableTaskTracker::kBadTaskId); |
| 991 node->set_favicon_state(BookmarkNode::LOADED_FAVICON); | 991 node->set_favicon_state(BookmarkNode::LOADED_FAVICON); |
| 992 if (!image_result.image.IsEmpty()) { | 992 if (!image_result.image.IsEmpty()) { |
| 993 node->set_favicon(image_result.image); | 993 node->set_favicon(image_result.image); |
| 994 node->set_icon_url(image_result.icon_url); | 994 node->set_icon_url(image_result.icon_url); |
| 995 FaviconLoaded(node); | 995 FaviconLoaded(node); |
| 996 } | 996 } |
| 997 } | 997 } |
| 998 | 998 |
| 999 void BookmarkModel::LoadFavicon(BookmarkNode* node) { | 999 void BookmarkModel::LoadFavicon(BookmarkNode* node) { |
| 1000 if (node->is_folder()) | 1000 if (node->is_folder()) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1014 &cancelable_task_tracker_); | 1014 &cancelable_task_tracker_); |
| 1015 node->set_favicon_load_task_id(handle); | 1015 node->set_favicon_load_task_id(handle); |
| 1016 } | 1016 } |
| 1017 | 1017 |
| 1018 void BookmarkModel::FaviconLoaded(const BookmarkNode* node) { | 1018 void BookmarkModel::FaviconLoaded(const BookmarkNode* node) { |
| 1019 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_, | 1019 FOR_EACH_OBSERVER(BookmarkModelObserver, observers_, |
| 1020 BookmarkNodeFaviconChanged(this, node)); | 1020 BookmarkNodeFaviconChanged(this, node)); |
| 1021 } | 1021 } |
| 1022 | 1022 |
| 1023 void BookmarkModel::CancelPendingFaviconLoadRequests(BookmarkNode* node) { | 1023 void BookmarkModel::CancelPendingFaviconLoadRequests(BookmarkNode* node) { |
| 1024 if (node->favicon_load_task_id() != CancelableTaskTracker::kBadTaskId) { | 1024 if (node->favicon_load_task_id() != base::CancelableTaskTracker::kBadTaskId) { |
| 1025 cancelable_task_tracker_.TryCancel(node->favicon_load_task_id()); | 1025 cancelable_task_tracker_.TryCancel(node->favicon_load_task_id()); |
| 1026 node->set_favicon_load_task_id(CancelableTaskTracker::kBadTaskId); | 1026 node->set_favicon_load_task_id(base::CancelableTaskTracker::kBadTaskId); |
| 1027 } | 1027 } |
| 1028 } | 1028 } |
| 1029 | 1029 |
| 1030 void BookmarkModel::Observe(int type, | 1030 void BookmarkModel::Observe(int type, |
| 1031 const content::NotificationSource& source, | 1031 const content::NotificationSource& source, |
| 1032 const content::NotificationDetails& details) { | 1032 const content::NotificationDetails& details) { |
| 1033 switch (type) { | 1033 switch (type) { |
| 1034 case chrome::NOTIFICATION_FAVICON_CHANGED: { | 1034 case chrome::NOTIFICATION_FAVICON_CHANGED: { |
| 1035 // Prevent the observers from getting confused for multiple favicon loads. | 1035 // Prevent the observers from getting confused for multiple favicon loads. |
| 1036 content::Details<FaviconChangedDetails> favicon_details(details); | 1036 content::Details<FaviconChangedDetails> favicon_details(details); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 BookmarkPermanentNode* bb_node = | 1073 BookmarkPermanentNode* bb_node = |
| 1074 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); | 1074 CreatePermanentNode(BookmarkNode::BOOKMARK_BAR); |
| 1075 BookmarkPermanentNode* other_node = | 1075 BookmarkPermanentNode* other_node = |
| 1076 CreatePermanentNode(BookmarkNode::OTHER_NODE); | 1076 CreatePermanentNode(BookmarkNode::OTHER_NODE); |
| 1077 BookmarkPermanentNode* mobile_node = | 1077 BookmarkPermanentNode* mobile_node = |
| 1078 CreatePermanentNode(BookmarkNode::MOBILE); | 1078 CreatePermanentNode(BookmarkNode::MOBILE); |
| 1079 return new BookmarkLoadDetails(bb_node, other_node, mobile_node, | 1079 return new BookmarkLoadDetails(bb_node, other_node, mobile_node, |
| 1080 new BookmarkIndex(profile_), | 1080 new BookmarkIndex(profile_), |
| 1081 next_node_id_); | 1081 next_node_id_); |
| 1082 } | 1082 } |
| OLD | NEW |