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

Side by Side Diff: chrome/browser/ui/webui/ntp/favicon_webui_handler.cc

Issue 10870022: Change FaviconData to be able to return data for multiple bitmaps for same icon URL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 (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/ui/webui/ntp/favicon_webui_handler.h" 5 #include "chrome/browser/ui/webui/ntp/favicon_webui_handler.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/string_split.h" 9 #include "base/string_split.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 url, 112 url,
113 history::FAVICON, 113 history::FAVICON,
114 &consumer_, 114 &consumer_,
115 base::Bind(&FaviconWebUIHandler::OnFaviconDataAvailable, 115 base::Bind(&FaviconWebUIHandler::OnFaviconDataAvailable,
116 base::Unretained(this))); 116 base::Unretained(this)));
117 consumer_.SetClientData(favicon_service, handle, id_++); 117 consumer_.SetClientData(favicon_service, handle, id_++);
118 } 118 }
119 119
120 void FaviconWebUIHandler::OnFaviconDataAvailable( 120 void FaviconWebUIHandler::OnFaviconDataAvailable(
121 FaviconService::Handle request_handle, 121 FaviconService::Handle request_handle,
122 history::FaviconData favicon) { 122 history::FaviconData favicon_data,
123 std::vector<GURL> icon_urls_in_db) {
123 FaviconService* favicon_service = 124 FaviconService* favicon_service =
124 Profile::FromWebUI(web_ui())->GetFaviconService(Profile::EXPLICIT_ACCESS); 125 Profile::FromWebUI(web_ui())->GetFaviconService(Profile::EXPLICIT_ACCESS);
125 int id = consumer_.GetClientData(favicon_service, request_handle); 126 int id = consumer_.GetClientData(favicon_service, request_handle);
126 scoped_ptr<StringValue> color_value; 127 scoped_ptr<StringValue> color_value;
127 128
128 if (favicon.is_valid()) 129 if (favicon_data.has_valid_bitmaps())
129 color_value.reset(GetDominantColorCssString(favicon.image_data)); 130 color_value.reset(GetDominantColorCssString(favicon_data.first_bitmap()));
130 else 131 else
131 color_value.reset(new StringValue("#919191")); 132 color_value.reset(new StringValue("#919191"));
132 133
133 StringValue dom_id(dom_id_map_[id]); 134 StringValue dom_id(dom_id_map_[id]);
134 web_ui()->CallJavascriptFunction("ntp.setStripeColor", dom_id, *color_value); 135 web_ui()->CallJavascriptFunction("ntp.setStripeColor", dom_id, *color_value);
135 dom_id_map_.erase(id); 136 dom_id_map_.erase(id);
136 } 137 }
137 138
138 void FaviconWebUIHandler::HandleGetAppIconDominantColor( 139 void FaviconWebUIHandler::HandleGetAppIconDominantColor(
139 const ListValue* args) { 140 const ListValue* args) {
(...skipping 15 matching lines...) Expand all
155 std::vector<unsigned char> bits; 156 std::vector<unsigned char> bits;
156 if (!gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &bits)) 157 if (!gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &bits))
157 return; 158 return;
158 scoped_refptr<base::RefCountedStaticMemory> bits_mem( 159 scoped_refptr<base::RefCountedStaticMemory> bits_mem(
159 new base::RefCountedStaticMemory(&bits.front(), bits.size())); 160 new base::RefCountedStaticMemory(&bits.front(), bits.size()));
160 scoped_ptr<StringValue> color_value(GetDominantColorCssString(bits_mem)); 161 scoped_ptr<StringValue> color_value(GetDominantColorCssString(bits_mem));
161 StringValue id(extension_id); 162 StringValue id(extension_id);
162 web_ui()->CallJavascriptFunction( 163 web_ui()->CallJavascriptFunction(
163 "ntp.setStripeColor", id, *color_value); 164 "ntp.setStripeColor", id, *color_value);
164 } 165 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698