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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) { |
140 std::string extension_id; | 140 std::string extension_id; |
141 CHECK(args->GetString(0, &extension_id)); | 141 CHECK(args->GetString(0, &extension_id)); |
142 | 142 |
143 ExtensionService* extension_service = | 143 ExtensionService* extension_service = |
144 Profile::FromWebUI(web_ui())->GetExtensionService(); | 144 Profile::FromWebUI(web_ui())->GetExtensionService(); |
145 const Extension* extension = extension_service->GetExtensionById( | 145 const extensions::Extension* extension = extension_service->GetExtensionById( |
146 extension_id, false); | 146 extension_id, false); |
147 if (!extension) | 147 if (!extension) |
148 return; | 148 return; |
149 app_icon_color_manager_->LoadIcon(extension); | 149 app_icon_color_manager_->LoadIcon(extension); |
150 } | 150 } |
151 | 151 |
152 void FaviconWebUIHandler::NotifyAppIconReady(const std::string& extension_id) { | 152 void FaviconWebUIHandler::NotifyAppIconReady(const std::string& extension_id) { |
153 const SkBitmap& bitmap = app_icon_color_manager_->GetIcon(extension_id); | 153 const SkBitmap& bitmap = app_icon_color_manager_->GetIcon(extension_id); |
154 // TODO(estade): would be nice to avoid a round trip through png encoding. | 154 // TODO(estade): would be nice to avoid a round trip through png encoding. |
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 |