| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/web_ui_util.h" | 5 #include "chrome/browser/ui/webui/web_ui_util.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/string_util.h" | |
| 11 #include "chrome/common/url_constants.h" | |
| 12 #include "googleurl/src/gurl.h" | |
| 13 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| 14 #include "ui/gfx/codec/png_codec.h" | 11 #include "ui/gfx/codec/png_codec.h" |
| 15 | 12 |
| 16 namespace web_ui_util { | 13 namespace web_ui_util { |
| 17 | 14 |
| 18 std::string GetImageDataUrl(const SkBitmap& bitmap) { | 15 std::string GetImageDataUrl(const SkBitmap& bitmap) { |
| 19 std::vector<unsigned char> output; | 16 std::vector<unsigned char> output; |
| 20 gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &output); | 17 gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &output); |
| 21 std::string str_url; | 18 std::string str_url; |
| 22 str_url.insert(str_url.end(), output.begin(), output.end()); | 19 str_url.insert(str_url.end(), output.begin(), output.end()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 35 scoped_refptr<RefCountedMemory> raw_icon(icon_data); | 32 scoped_refptr<RefCountedMemory> raw_icon(icon_data); |
| 36 std::string str_url; | 33 std::string str_url; |
| 37 str_url.insert(str_url.end(), | 34 str_url.insert(str_url.end(), |
| 38 raw_icon->front(), | 35 raw_icon->front(), |
| 39 raw_icon->front() + raw_icon->size()); | 36 raw_icon->front() + raw_icon->size()); |
| 40 base::Base64Encode(str_url, &str_url); | 37 base::Base64Encode(str_url, &str_url); |
| 41 str_url.insert(0, "data:image/png;base64,"); | 38 str_url.insert(0, "data:image/png;base64,"); |
| 42 return str_url; | 39 return str_url; |
| 43 } | 40 } |
| 44 | 41 |
| 45 bool ChromeURLHostEquals(const GURL& url, const char* host) { | |
| 46 return (url.SchemeIs(chrome::kChromeUIScheme) || | |
| 47 url.SchemeIs(chrome::kAboutScheme)) && | |
| 48 LowerCaseEqualsASCII(url.host(), host); | |
| 49 } | |
| 50 | |
| 51 } // namespace web_ui_util | 42 } // namespace web_ui_util |
| OLD | NEW |