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

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

Issue 10272004: Move RefCountedMemory class to base namespace. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 7 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 15 matching lines...) Expand all
26 namespace { 26 namespace {
27 27
28 StringValue* SkColorToCss(SkColor color) { 28 StringValue* SkColorToCss(SkColor color) {
29 return new StringValue(base::StringPrintf("rgb(%d, %d, %d)", 29 return new StringValue(base::StringPrintf("rgb(%d, %d, %d)",
30 SkColorGetR(color), 30 SkColorGetR(color),
31 SkColorGetG(color), 31 SkColorGetG(color),
32 SkColorGetB(color))); 32 SkColorGetB(color)));
33 } 33 }
34 34
35 base::StringValue* GetDominantColorCssString( 35 base::StringValue* GetDominantColorCssString(
36 scoped_refptr<RefCountedMemory> png) { 36 scoped_refptr<base::RefCountedMemory> png) {
37 color_utils::GridSampler sampler; 37 color_utils::GridSampler sampler;
38 SkColor color = color_utils::CalculateKMeanColorOfPNG(png, 100, 665, sampler); 38 SkColor color = color_utils::CalculateKMeanColorOfPNG(png, 100, 665, sampler);
39 return SkColorToCss(color); 39 return SkColorToCss(color);
40 } 40 }
41 41
42 } // namespace 42 } // namespace
43 43
44 // Thin inheritance-dependent trampoline to forward notification of app 44 // Thin inheritance-dependent trampoline to forward notification of app
45 // icon loads to the FaviconWebUIHandler. Base class does caching of icons. 45 // icon loads to the FaviconWebUIHandler. Base class does caching of icons.
46 class ExtensionIconColorManager : public ExtensionIconManager { 46 class ExtensionIconColorManager : public ExtensionIconManager {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/favicon_webui_handler.h ('k') | chrome/browser/ui/webui/ntp/new_tab_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698