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/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/logging.h" | 10 #include "base/logging.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 str_url.insert(0, "data:image/png;base64,"); | 26 str_url.insert(0, "data:image/png;base64,"); |
27 return str_url; | 27 return str_url; |
28 } | 28 } |
29 | 29 |
30 std::string GetImageDataUrlFromResource(int res) { | 30 std::string GetImageDataUrlFromResource(int res) { |
31 // Load resource icon and covert to base64 encoded data url | 31 // Load resource icon and covert to base64 encoded data url |
32 base::RefCountedStaticMemory* icon_data = | 32 base::RefCountedStaticMemory* icon_data = |
33 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(res); | 33 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(res); |
34 if (!icon_data) | 34 if (!icon_data) |
35 return std::string(); | 35 return std::string(); |
36 scoped_refptr<RefCountedMemory> raw_icon(icon_data); | 36 scoped_refptr<base::RefCountedMemory> raw_icon(icon_data); |
37 std::string str_url; | 37 std::string str_url; |
38 str_url.insert(str_url.end(), | 38 str_url.insert(str_url.end(), |
39 raw_icon->front(), | 39 raw_icon->front(), |
40 raw_icon->front() + raw_icon->size()); | 40 raw_icon->front() + raw_icon->size()); |
41 base::Base64Encode(str_url, &str_url); | 41 base::Base64Encode(str_url, &str_url); |
42 str_url.insert(0, "data:image/png;base64,"); | 42 str_url.insert(0, "data:image/png;base64,"); |
43 return str_url; | 43 return str_url; |
44 } | 44 } |
45 | 45 |
46 WindowOpenDisposition GetDispositionFromClick(const ListValue* args, | 46 WindowOpenDisposition GetDispositionFromClick(const ListValue* args, |
47 int start_index) { | 47 int start_index) { |
48 double button = 0.0; | 48 double button = 0.0; |
49 bool alt_key = false; | 49 bool alt_key = false; |
50 bool ctrl_key = false; | 50 bool ctrl_key = false; |
51 bool meta_key = false; | 51 bool meta_key = false; |
52 bool shift_key = false; | 52 bool shift_key = false; |
53 | 53 |
54 CHECK(args->GetDouble(start_index++, &button)); | 54 CHECK(args->GetDouble(start_index++, &button)); |
55 CHECK(args->GetBoolean(start_index++, &alt_key)); | 55 CHECK(args->GetBoolean(start_index++, &alt_key)); |
56 CHECK(args->GetBoolean(start_index++, &ctrl_key)); | 56 CHECK(args->GetBoolean(start_index++, &ctrl_key)); |
57 CHECK(args->GetBoolean(start_index++, &meta_key)); | 57 CHECK(args->GetBoolean(start_index++, &meta_key)); |
58 CHECK(args->GetBoolean(start_index++, &shift_key)); | 58 CHECK(args->GetBoolean(start_index++, &shift_key)); |
59 return disposition_utils::DispositionFromClick(button == 1.0, alt_key, | 59 return disposition_utils::DispositionFromClick(button == 1.0, alt_key, |
60 ctrl_key, meta_key, shift_key); | 60 ctrl_key, meta_key, shift_key); |
61 | 61 |
62 } | 62 } |
63 | 63 |
64 } // namespace web_ui_util | 64 } // namespace web_ui_util |
OLD | NEW |