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/values.h" |
| 11 #include "content/browser/disposition_utils.h" |
10 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
11 #include "ui/gfx/codec/png_codec.h" | 13 #include "ui/gfx/codec/png_codec.h" |
12 | 14 |
13 namespace web_ui_util { | 15 namespace web_ui_util { |
14 | 16 |
15 std::string GetImageDataUrl(const SkBitmap& bitmap) { | 17 std::string GetImageDataUrl(const SkBitmap& bitmap) { |
16 std::vector<unsigned char> output; | 18 std::vector<unsigned char> output; |
17 gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &output); | 19 gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &output); |
18 std::string str_url; | 20 std::string str_url; |
19 str_url.insert(str_url.end(), output.begin(), output.end()); | 21 str_url.insert(str_url.end(), output.begin(), output.end()); |
(...skipping 12 matching lines...) Expand all Loading... |
32 scoped_refptr<RefCountedMemory> raw_icon(icon_data); | 34 scoped_refptr<RefCountedMemory> raw_icon(icon_data); |
33 std::string str_url; | 35 std::string str_url; |
34 str_url.insert(str_url.end(), | 36 str_url.insert(str_url.end(), |
35 raw_icon->front(), | 37 raw_icon->front(), |
36 raw_icon->front() + raw_icon->size()); | 38 raw_icon->front() + raw_icon->size()); |
37 base::Base64Encode(str_url, &str_url); | 39 base::Base64Encode(str_url, &str_url); |
38 str_url.insert(0, "data:image/png;base64,"); | 40 str_url.insert(0, "data:image/png;base64,"); |
39 return str_url; | 41 return str_url; |
40 } | 42 } |
41 | 43 |
| 44 WindowOpenDisposition GetDispositionFromClick(const ListValue* args, |
| 45 int start_index) { |
| 46 double button = 0.0; |
| 47 bool alt_key = false; |
| 48 bool ctrl_key = false; |
| 49 bool meta_key = false; |
| 50 bool shift_key = false; |
| 51 |
| 52 CHECK(args->GetDouble(start_index++, &button)); |
| 53 CHECK(args->GetBoolean(start_index++, &alt_key)); |
| 54 CHECK(args->GetBoolean(start_index++, &ctrl_key)); |
| 55 CHECK(args->GetBoolean(start_index++, &meta_key)); |
| 56 CHECK(args->GetBoolean(start_index++, &shift_key)); |
| 57 return disposition_utils::DispositionFromClick(button == 1.0, alt_key, |
| 58 ctrl_key, meta_key, shift_key); |
| 59 |
| 60 } |
| 61 |
42 } // namespace web_ui_util | 62 } // namespace web_ui_util |
OLD | NEW |