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 "chrome/browser/bookmarks/chrome_bookmark_client.h" | 5 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 namespace { | 31 namespace { |
32 | 32 |
33 void NotifyHistoryOfRemovedURLs(Profile* profile, | 33 void NotifyHistoryOfRemovedURLs(Profile* profile, |
34 const std::set<GURL>& removed_urls) { | 34 const std::set<GURL>& removed_urls) { |
35 HistoryService* history_service = | 35 HistoryService* history_service = |
36 HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); | 36 HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); |
37 if (history_service) | 37 if (history_service) |
38 history_service->URLsNoLongerBookmarked(removed_urls); | 38 history_service->URLsNoLongerBookmarked(removed_urls); |
39 } | 39 } |
40 | 40 |
| 41 void RunCallbackWithImage( |
| 42 const favicon_base::FaviconImageCallback& callback, |
| 43 const favicon_base::FaviconRawBitmapResult& bitmap_result) { |
| 44 favicon_base::FaviconImageResult result; |
| 45 if (bitmap_result.is_valid()) { |
| 46 result.image = gfx::Image::CreateFrom1xPNGBytes( |
| 47 bitmap_result.bitmap_data->front(), bitmap_result.bitmap_data->size()); |
| 48 result.icon_url = bitmap_result.icon_url; |
| 49 callback.Run(result); |
| 50 return; |
| 51 } |
| 52 callback.Run(result); |
| 53 } |
| 54 |
41 } // namespace | 55 } // namespace |
42 | 56 |
43 ChromeBookmarkClient::ChromeBookmarkClient(Profile* profile) | 57 ChromeBookmarkClient::ChromeBookmarkClient(Profile* profile) |
44 : profile_(profile), model_(NULL), managed_node_(NULL) { | 58 : profile_(profile), model_(NULL), managed_node_(NULL) { |
45 } | 59 } |
46 | 60 |
47 ChromeBookmarkClient::~ChromeBookmarkClient() { | 61 ChromeBookmarkClient::~ChromeBookmarkClient() { |
48 } | 62 } |
49 | 63 |
50 void ChromeBookmarkClient::Init(BookmarkModel* model) { | 64 void ChromeBookmarkClient::Init(BookmarkModel* model) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 104 } |
91 | 105 |
92 bool ChromeBookmarkClient::PreferTouchIcon() { | 106 bool ChromeBookmarkClient::PreferTouchIcon() { |
93 #if !defined(OS_IOS) | 107 #if !defined(OS_IOS) |
94 return false; | 108 return false; |
95 #else | 109 #else |
96 return true; | 110 return true; |
97 #endif | 111 #endif |
98 } | 112 } |
99 | 113 |
100 base::CancelableTaskTracker::TaskId ChromeBookmarkClient::GetFaviconImageForURL( | 114 base::CancelableTaskTracker::TaskId |
| 115 ChromeBookmarkClient::GetFaviconImageForPageURL( |
101 const GURL& page_url, | 116 const GURL& page_url, |
102 int icon_types, | 117 favicon_base::IconType type, |
103 int desired_size_in_dip, | |
104 const favicon_base::FaviconImageCallback& callback, | 118 const favicon_base::FaviconImageCallback& callback, |
105 base::CancelableTaskTracker* tracker) { | 119 base::CancelableTaskTracker* tracker) { |
106 FaviconService* favicon_service = | 120 FaviconService* favicon_service = |
107 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 121 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
108 if (!favicon_service) | 122 if (!favicon_service) |
109 return base::CancelableTaskTracker::kBadTaskId; | 123 return base::CancelableTaskTracker::kBadTaskId; |
110 return favicon_service->GetFaviconImageForPageURL( | 124 if (type == favicon_base::FAVICON) { |
111 FaviconService::FaviconForPageURLParams( | 125 return favicon_service->GetFaviconImageForPageURL( |
112 page_url, icon_types, desired_size_in_dip), | 126 page_url, callback, tracker); |
113 callback, | 127 } else { |
114 tracker); | 128 return favicon_service->GetRawFaviconForPageURL( |
| 129 page_url, |
| 130 type, |
| 131 0, |
| 132 base::Bind(&RunCallbackWithImage, callback), |
| 133 tracker); |
| 134 } |
115 } | 135 } |
116 | 136 |
117 bool ChromeBookmarkClient::SupportsTypedCountForNodes() { | 137 bool ChromeBookmarkClient::SupportsTypedCountForNodes() { |
118 return true; | 138 return true; |
119 } | 139 } |
120 | 140 |
121 void ChromeBookmarkClient::GetTypedCountForNodes( | 141 void ChromeBookmarkClient::GetTypedCountForNodes( |
122 const NodeSet& nodes, | 142 const NodeSet& nodes, |
123 NodeTypedCountPairs* node_typed_count_pairs) { | 143 NodeTypedCountPairs* node_typed_count_pairs) { |
124 HistoryService* history_service = | 144 HistoryService* history_service = |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 return extra_nodes.Pass(); | 274 return extra_nodes.Pass(); |
255 } | 275 } |
256 | 276 |
257 std::string ChromeBookmarkClient::GetManagedBookmarksDomain() { | 277 std::string ChromeBookmarkClient::GetManagedBookmarksDomain() { |
258 policy::ProfilePolicyConnector* connector = | 278 policy::ProfilePolicyConnector* connector = |
259 policy::ProfilePolicyConnectorFactory::GetForProfile(profile_); | 279 policy::ProfilePolicyConnectorFactory::GetForProfile(profile_); |
260 if (connector->IsPolicyFromCloudPolicy(policy::key::kManagedBookmarks)) | 280 if (connector->IsPolicyFromCloudPolicy(policy::key::kManagedBookmarks)) |
261 return connector->GetManagementDomain(); | 281 return connector->GetManagementDomain(); |
262 return std::string(); | 282 return std::string(); |
263 } | 283 } |
OLD | NEW |