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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // Thin inheritance-dependent trampoline to forward notification of app | 45 // Thin inheritance-dependent trampoline to forward notification of app |
46 // icon loads to the FaviconWebUIHandler. Base class does caching of icons. | 46 // icon loads to the FaviconWebUIHandler. Base class does caching of icons. |
47 class ExtensionIconColorManager : public ExtensionIconManager { | 47 class ExtensionIconColorManager : public ExtensionIconManager { |
48 public: | 48 public: |
49 explicit ExtensionIconColorManager(FaviconWebUIHandler* handler) | 49 explicit ExtensionIconColorManager(FaviconWebUIHandler* handler) |
50 : ExtensionIconManager(), | 50 : ExtensionIconManager(), |
51 handler_(handler) {} | 51 handler_(handler) {} |
52 virtual ~ExtensionIconColorManager() {} | 52 virtual ~ExtensionIconColorManager() {} |
53 | 53 |
54 virtual void OnImageLoaded(const std::string& extension_id, | 54 virtual void OnImageLoaded(const std::string& extension_id, |
55 const gfx::Image& image) OVERRIDE { | 55 const gfx::Image& image) override { |
56 ExtensionIconManager::OnImageLoaded(extension_id, image); | 56 ExtensionIconManager::OnImageLoaded(extension_id, image); |
57 handler_->NotifyAppIconReady(extension_id); | 57 handler_->NotifyAppIconReady(extension_id); |
58 } | 58 } |
59 | 59 |
60 private: | 60 private: |
61 FaviconWebUIHandler* handler_; | 61 FaviconWebUIHandler* handler_; |
62 }; | 62 }; |
63 | 63 |
64 FaviconWebUIHandler::FaviconWebUIHandler() | 64 FaviconWebUIHandler::FaviconWebUIHandler() |
65 : id_(0), | 65 : id_(0), |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 if (!gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &bits)) | 158 if (!gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &bits)) |
159 return; | 159 return; |
160 scoped_refptr<base::RefCountedStaticMemory> bits_mem( | 160 scoped_refptr<base::RefCountedStaticMemory> bits_mem( |
161 new base::RefCountedStaticMemory(&bits.front(), bits.size())); | 161 new base::RefCountedStaticMemory(&bits.front(), bits.size())); |
162 scoped_ptr<base::StringValue> color_value( | 162 scoped_ptr<base::StringValue> color_value( |
163 GetDominantColorCssString(bits_mem)); | 163 GetDominantColorCssString(bits_mem)); |
164 base::StringValue id(extension_id); | 164 base::StringValue id(extension_id); |
165 web_ui()->CallJavascriptFunction( | 165 web_ui()->CallJavascriptFunction( |
166 "ntp.setFaviconDominantColor", id, *color_value); | 166 "ntp.setFaviconDominantColor", id, *color_value); |
167 } | 167 } |
OLD | NEW |