| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gears_integration.h" | 5 #include "chrome/browser/gears_integration.h" |
| 6 | 6 |
| 7 #include "base/gfx/png_encoder.h" | 7 #include "app/gfx/codec/png_codec.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "chrome/browser/chrome_plugin_host.h" | 11 #include "chrome/browser/chrome_plugin_host.h" |
| 12 #include "chrome/common/chrome_plugin_util.h" | 12 #include "chrome/common/chrome_plugin_util.h" |
| 13 #include "chrome/common/gears_api.h" | 13 #include "chrome/common/gears_api.h" |
| 14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 15 #include "net/base/base64.h" | 15 #include "net/base/base64.h" |
| 16 #include "third_party/skia/include/core/SkBitmap.h" | 16 #include "third_party/skia/include/core/SkBitmap.h" |
| 17 #include "webkit/glue/dom_operations.h" | 17 #include "webkit/glue/dom_operations.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 // Helper function to convert a 16x16 favicon to a data: URL with the icon | 111 // Helper function to convert a 16x16 favicon to a data: URL with the icon |
| 112 // encoded as a PNG. | 112 // encoded as a PNG. |
| 113 static GURL ConvertSkBitmapToDataURL(const SkBitmap& icon) { | 113 static GURL ConvertSkBitmapToDataURL(const SkBitmap& icon) { |
| 114 DCHECK(!icon.isNull()); | 114 DCHECK(!icon.isNull()); |
| 115 DCHECK(icon.width() == 16 && icon.height() == 16); | 115 DCHECK(icon.width() == 16 && icon.height() == 16); |
| 116 | 116 |
| 117 // Get the FavIcon data. | 117 // Get the FavIcon data. |
| 118 std::vector<unsigned char> icon_data; | 118 std::vector<unsigned char> icon_data; |
| 119 PNGEncoder::EncodeBGRASkBitmap(icon, false, &icon_data); | 119 gfx::PNGCodec::EncodeBGRASkBitmap(icon, false, &icon_data); |
| 120 | 120 |
| 121 // Base64-encode it (to make it a data URL). | 121 // Base64-encode it (to make it a data URL). |
| 122 std::string icon_data_str(reinterpret_cast<char*>(&icon_data[0]), | 122 std::string icon_data_str(reinterpret_cast<char*>(&icon_data[0]), |
| 123 icon_data.size()); | 123 icon_data.size()); |
| 124 std::string icon_base64_encoded; | 124 std::string icon_base64_encoded; |
| 125 net::Base64Encode(icon_data_str, &icon_base64_encoded); | 125 net::Base64Encode(icon_data_str, &icon_base64_encoded); |
| 126 GURL icon_url("data:image/png;base64," + icon_base64_encoded); | 126 GURL icon_url("data:image/png;base64," + icon_base64_encoded); |
| 127 | 127 |
| 128 return icon_url; | 128 return icon_url; |
| 129 } | 129 } |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 struct RunnableMethodTraits<QueryShortcutsCommand> { | 300 struct RunnableMethodTraits<QueryShortcutsCommand> { |
| 301 void RetainCallee(QueryShortcutsCommand*) {} | 301 void RetainCallee(QueryShortcutsCommand*) {} |
| 302 void ReleaseCallee(QueryShortcutsCommand*) {} | 302 void ReleaseCallee(QueryShortcutsCommand*) {} |
| 303 }; | 303 }; |
| 304 | 304 |
| 305 void GearsQueryShortcuts(GearsQueryShortcutsCallback* callback) { | 305 void GearsQueryShortcuts(GearsQueryShortcutsCallback* callback) { |
| 306 CPHandleCommand(GEARSPLUGINCOMMAND_GET_SHORTCUT_LIST, | 306 CPHandleCommand(GEARSPLUGINCOMMAND_GET_SHORTCUT_LIST, |
| 307 new QueryShortcutsCommand(callback), | 307 new QueryShortcutsCommand(callback), |
| 308 NULL); | 308 NULL); |
| 309 } | 309 } |
| OLD | NEW |