| 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/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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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) { |
| 123 FaviconService* favicon_service = | 123 FaviconService* favicon_service = |
| 124 Profile::FromWebUI(web_ui())->GetFaviconService(Profile::EXPLICIT_ACCESS); | 124 Profile::FromWebUI(web_ui())->GetFaviconService(Profile::EXPLICIT_ACCESS); |
| 125 int id = consumer_.GetClientData(favicon_service, request_handle); | 125 int id = consumer_.GetClientData(favicon_service, request_handle); |
| 126 scoped_ptr<StringValue> color_value; | 126 scoped_ptr<StringValue> color_value; |
| 127 | 127 |
| 128 if (favicon.is_valid()) | 128 if (favicon.is_valid()) |
| 129 color_value.reset(GetDominantColorCssString(favicon.image_data)); | 129 color_value.reset(GetDominantColorCssString(favicon.bitmap_data)); |
| 130 else | 130 else |
| 131 color_value.reset(new StringValue("#919191")); | 131 color_value.reset(new StringValue("#919191")); |
| 132 | 132 |
| 133 StringValue dom_id(dom_id_map_[id]); | 133 StringValue dom_id(dom_id_map_[id]); |
| 134 web_ui()->CallJavascriptFunction("ntp.setStripeColor", dom_id, *color_value); | 134 web_ui()->CallJavascriptFunction("ntp.setStripeColor", dom_id, *color_value); |
| 135 dom_id_map_.erase(id); | 135 dom_id_map_.erase(id); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void FaviconWebUIHandler::HandleGetAppIconDominantColor( | 138 void FaviconWebUIHandler::HandleGetAppIconDominantColor( |
| 139 const ListValue* args) { | 139 const ListValue* args) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 155 std::vector<unsigned char> bits; | 155 std::vector<unsigned char> bits; |
| 156 if (!gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &bits)) | 156 if (!gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &bits)) |
| 157 return; | 157 return; |
| 158 scoped_refptr<base::RefCountedStaticMemory> bits_mem( | 158 scoped_refptr<base::RefCountedStaticMemory> bits_mem( |
| 159 new base::RefCountedStaticMemory(&bits.front(), bits.size())); | 159 new base::RefCountedStaticMemory(&bits.front(), bits.size())); |
| 160 scoped_ptr<StringValue> color_value(GetDominantColorCssString(bits_mem)); | 160 scoped_ptr<StringValue> color_value(GetDominantColorCssString(bits_mem)); |
| 161 StringValue id(extension_id); | 161 StringValue id(extension_id); |
| 162 web_ui()->CallJavascriptFunction( | 162 web_ui()->CallJavascriptFunction( |
| 163 "ntp.setStripeColor", id, *color_value); | 163 "ntp.setStripeColor", id, *color_value); |
| 164 } | 164 } |
| OLD | NEW |