OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/arc/test/fake_app_instance.h" | 5 #include "components/arc/test/fake_app_instance.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
18 #include "mojo/common/common_type_converters.h" | |
19 | 18 |
20 namespace mojo { | 19 namespace mojo { |
21 | 20 |
22 template <> | 21 template <> |
23 struct TypeConverter<arc::mojom::AppInfoPtr, arc::mojom::AppInfo> { | 22 struct TypeConverter<arc::mojom::AppInfoPtr, arc::mojom::AppInfo> { |
24 static arc::mojom::AppInfoPtr Convert(const arc::mojom::AppInfo& app_info) { | 23 static arc::mojom::AppInfoPtr Convert(const arc::mojom::AppInfo& app_info) { |
25 return app_info.Clone(); | 24 return app_info.Clone(); |
26 } | 25 } |
27 }; | 26 }; |
28 | 27 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 } | 106 } |
108 | 107 |
109 bool FakeAppInstance::GenerateAndSendIcon(const mojom::AppInfo& app, | 108 bool FakeAppInstance::GenerateAndSendIcon(const mojom::AppInfo& app, |
110 mojom::ScaleFactor scale_factor, | 109 mojom::ScaleFactor scale_factor, |
111 std::string* png_data_as_string) { | 110 std::string* png_data_as_string) { |
112 if (!GetFakeIcon(scale_factor, png_data_as_string)) { | 111 if (!GetFakeIcon(scale_factor, png_data_as_string)) { |
113 return false; | 112 return false; |
114 } | 113 } |
115 | 114 |
116 app_host_->OnAppIcon(app.package_name, app.activity, scale_factor, | 115 app_host_->OnAppIcon(app.package_name, app.activity, scale_factor, |
117 mojo::Array<uint8_t>::From(*png_data_as_string)); | 116 std::vector<uint8_t>(png_data_as_string->begin(), |
| 117 png_data_as_string->end())); |
118 | 118 |
119 return true; | 119 return true; |
120 } | 120 } |
121 | 121 |
122 bool FakeAppInstance::GetFakeIcon(mojom::ScaleFactor scale_factor, | 122 bool FakeAppInstance::GetFakeIcon(mojom::ScaleFactor scale_factor, |
123 std::string* png_data_as_string) { | 123 std::string* png_data_as_string) { |
124 CHECK(png_data_as_string != nullptr); | 124 CHECK(png_data_as_string != nullptr); |
125 std::string icon_file_name; | 125 std::string icon_file_name; |
126 switch (scale_factor) { | 126 switch (scale_factor) { |
127 case mojom::ScaleFactor::SCALE_FACTOR_100P: | 127 case mojom::ScaleFactor::SCALE_FACTOR_100P: |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 } | 254 } |
255 | 255 |
256 void FakeAppInstance::RequestIcon(const std::string& icon_resource_id, | 256 void FakeAppInstance::RequestIcon(const std::string& icon_resource_id, |
257 arc::mojom::ScaleFactor scale_factor, | 257 arc::mojom::ScaleFactor scale_factor, |
258 const RequestIconCallback& callback) { | 258 const RequestIconCallback& callback) { |
259 shortcut_icon_requests_.push_back( | 259 shortcut_icon_requests_.push_back( |
260 base::MakeUnique<ShortcutIconRequest>(icon_resource_id, scale_factor)); | 260 base::MakeUnique<ShortcutIconRequest>(icon_resource_id, scale_factor)); |
261 | 261 |
262 std::string png_data_as_string; | 262 std::string png_data_as_string; |
263 if (GetFakeIcon(scale_factor, &png_data_as_string)) { | 263 if (GetFakeIcon(scale_factor, &png_data_as_string)) { |
264 callback.Run(mojo::Array<uint8_t>::From(png_data_as_string)); | 264 callback.Run(std::vector<uint8_t>(png_data_as_string.begin(), |
| 265 png_data_as_string.end())); |
265 } | 266 } |
266 } | 267 } |
267 | 268 |
268 void FakeAppInstance::RemoveCachedIcon(const std::string& icon_resource_id) {} | 269 void FakeAppInstance::RemoveCachedIcon(const std::string& icon_resource_id) {} |
269 | 270 |
270 } // namespace arc | 271 } // namespace arc |
OLD | NEW |