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/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 scoped_ptr<base::StringValue> color( | 105 scoped_ptr<base::StringValue> color( |
106 SkColorToCss(history::kPrepopulatedPages[i].color)); | 106 SkColorToCss(history::kPrepopulatedPages[i].color)); |
107 web_ui()->CallJavascriptFunction("ntp.setFaviconDominantColor", | 107 web_ui()->CallJavascriptFunction("ntp.setFaviconDominantColor", |
108 dom_id_value, *color); | 108 dom_id_value, *color); |
109 return; | 109 return; |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 dom_id_map_[id_] = dom_id; | 113 dom_id_map_[id_] = dom_id; |
114 favicon_service->GetRawFaviconForPageURL( | 114 favicon_service->GetRawFaviconForPageURL( |
115 FaviconService::FaviconForPageURLParams( | 115 url, |
116 url, favicon_base::FAVICON, gfx::kFaviconSize), | 116 favicon_base::FAVICON, |
117 1.0f, | 117 gfx::kFaviconSize, |
118 base::Bind(&FaviconWebUIHandler::OnFaviconDataAvailable, | 118 base::Bind(&FaviconWebUIHandler::OnFaviconDataAvailable, |
119 base::Unretained(this), | 119 base::Unretained(this), |
120 id_++), | 120 id_++), |
121 &cancelable_task_tracker_); | 121 &cancelable_task_tracker_); |
122 } | 122 } |
123 | 123 |
124 void FaviconWebUIHandler::OnFaviconDataAvailable( | 124 void FaviconWebUIHandler::OnFaviconDataAvailable( |
125 int id, | 125 int id, |
126 const favicon_base::FaviconRawBitmapResult& bitmap_result) { | 126 const favicon_base::FaviconRawBitmapResult& bitmap_result) { |
127 scoped_ptr<base::StringValue> color_value; | 127 scoped_ptr<base::StringValue> color_value; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 if (!gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &bits)) | 159 if (!gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &bits)) |
160 return; | 160 return; |
161 scoped_refptr<base::RefCountedStaticMemory> bits_mem( | 161 scoped_refptr<base::RefCountedStaticMemory> bits_mem( |
162 new base::RefCountedStaticMemory(&bits.front(), bits.size())); | 162 new base::RefCountedStaticMemory(&bits.front(), bits.size())); |
163 scoped_ptr<base::StringValue> color_value( | 163 scoped_ptr<base::StringValue> color_value( |
164 GetDominantColorCssString(bits_mem)); | 164 GetDominantColorCssString(bits_mem)); |
165 base::StringValue id(extension_id); | 165 base::StringValue id(extension_id); |
166 web_ui()->CallJavascriptFunction( | 166 web_ui()->CallJavascriptFunction( |
167 "ntp.setFaviconDominantColor", id, *color_value); | 167 "ntp.setFaviconDominantColor", id, *color_value); |
168 } | 168 } |
OLD | NEW |