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

Side by Side Diff: chrome/browser/bookmarks/chrome_bookmark_client.cc

Issue 331163003: [Refactor] Change FaviconService API to take in a desired pixel size (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months 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 | Annotate | Revision Log
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 "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 22 matching lines...) Expand all
33 namespace { 33 namespace {
34 34
35 void NotifyHistoryOfRemovedURLs(Profile* profile, 35 void NotifyHistoryOfRemovedURLs(Profile* profile,
36 const std::set<GURL>& removed_urls) { 36 const std::set<GURL>& removed_urls) {
37 HistoryService* history_service = 37 HistoryService* history_service =
38 HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); 38 HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS);
39 if (history_service) 39 if (history_service)
40 history_service->URLsNoLongerBookmarked(removed_urls); 40 history_service->URLsNoLongerBookmarked(removed_urls);
41 } 41 }
42 42
43 void RunCallbackWithImage(
44 const favicon_base::FaviconImageCallback& callback,
45 const favicon_base::FaviconRawBitmapResult& bitmap_result) {
46 favicon_base::FaviconImageResult result;
47 if (bitmap_result.is_valid()) {
48 result.image = gfx::Image::CreateFrom1xPNGBytes(
49 bitmap_result.bitmap_data->front(), bitmap_result.bitmap_data->size());
50 result.icon_url = bitmap_result.icon_url;
51 callback.Run(result);
52 return;
53 }
54 callback.Run(result);
55 }
56
43 } // namespace 57 } // namespace
44 58
45 ChromeBookmarkClient::ChromeBookmarkClient(Profile* profile) 59 ChromeBookmarkClient::ChromeBookmarkClient(Profile* profile)
46 : profile_(profile), model_(NULL), managed_node_(NULL) { 60 : profile_(profile), model_(NULL), managed_node_(NULL) {
47 } 61 }
48 62
49 ChromeBookmarkClient::~ChromeBookmarkClient() { 63 ChromeBookmarkClient::~ChromeBookmarkClient() {
50 } 64 }
51 65
52 void ChromeBookmarkClient::Init(BookmarkModel* model) { 66 void ChromeBookmarkClient::Init(BookmarkModel* model) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 106 }
93 107
94 bool ChromeBookmarkClient::PreferTouchIcon() { 108 bool ChromeBookmarkClient::PreferTouchIcon() {
95 #if !defined(OS_IOS) 109 #if !defined(OS_IOS)
96 return false; 110 return false;
97 #else 111 #else
98 return true; 112 return true;
99 #endif 113 #endif
100 } 114 }
101 115
102 base::CancelableTaskTracker::TaskId ChromeBookmarkClient::GetFaviconImageForURL( 116 base::CancelableTaskTracker::TaskId
117 ChromeBookmarkClient::GetFaviconImageForPageURL(
103 const GURL& page_url, 118 const GURL& page_url,
104 int icon_types,
105 int desired_size_in_dip,
106 const favicon_base::FaviconImageCallback& callback, 119 const favicon_base::FaviconImageCallback& callback,
107 base::CancelableTaskTracker* tracker) { 120 base::CancelableTaskTracker* tracker) {
108 FaviconService* favicon_service = 121 FaviconService* favicon_service =
109 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 122 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
110 if (!favicon_service) 123 if (!favicon_service)
111 return base::CancelableTaskTracker::kBadTaskId; 124 return base::CancelableTaskTracker::kBadTaskId;
112 return favicon_service->GetFaviconImageForPageURL( 125 return favicon_service->GetFaviconImageForPageURL(
113 FaviconService::FaviconForPageURLParams( 126 page_url, callback, tracker);
114 page_url, icon_types, desired_size_in_dip), 127 }
115 callback, 128
129 base::CancelableTaskTracker::TaskId
130 ChromeBookmarkClient::GetTouchFaviconImageForPageURL(
131 const GURL& page_url,
132 const favicon_base::FaviconImageCallback& callback,
133 base::CancelableTaskTracker* tracker) {
134 FaviconService* favicon_service =
135 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
136 if (!favicon_service)
137 return base::CancelableTaskTracker::kBadTaskId;
138 return favicon_service->GetRawFaviconForPageURL(
139 page_url,
140 favicon_base::TOUCH_ICON,
141 0,
142 base::Bind(&RunCallbackWithImage, callback),
116 tracker); 143 tracker);
117 } 144 }
118 145
119 bool ChromeBookmarkClient::SupportsTypedCountForNodes() { 146 bool ChromeBookmarkClient::SupportsTypedCountForNodes() {
120 return true; 147 return true;
121 } 148 }
122 149
123 void ChromeBookmarkClient::GetTypedCountForNodes( 150 void ChromeBookmarkClient::GetTypedCountForNodes(
124 const NodeSet& nodes, 151 const NodeSet& nodes,
125 NodeTypedCountPairs* node_typed_count_pairs) { 152 NodeTypedCountPairs* node_typed_count_pairs) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 return extra_nodes.Pass(); 281 return extra_nodes.Pass();
255 } 282 }
256 283
257 std::string ChromeBookmarkClient::GetManagedBookmarksDomain() { 284 std::string ChromeBookmarkClient::GetManagedBookmarksDomain() {
258 policy::ProfilePolicyConnector* connector = 285 policy::ProfilePolicyConnector* connector =
259 policy::ProfilePolicyConnectorFactory::GetForProfile(profile_); 286 policy::ProfilePolicyConnectorFactory::GetForProfile(profile_);
260 if (connector->IsPolicyFromCloudPolicy(policy::key::kManagedBookmarks)) 287 if (connector->IsPolicyFromCloudPolicy(policy::key::kManagedBookmarks))
261 return connector->GetManagementDomain(); 288 return connector->GetManagementDomain();
262 return std::string(); 289 return std::string();
263 } 290 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698