Chromium Code Reviews| Index: ash/public/cpp/shelf_struct_traits.cc |
| diff --git a/ash/public/cpp/shelf_struct_traits.cc b/ash/public/cpp/shelf_struct_traits.cc |
| index 001bfa516b7dc0432b242f863d2bb0b3f39de445..0750986474ddae19a1b60c73effa36b6f89da5ed 100644 |
| --- a/ash/public/cpp/shelf_struct_traits.cc |
| +++ b/ash/public/cpp/shelf_struct_traits.cc |
| @@ -14,6 +14,15 @@ using ShelfItemStructTraits = |
| StructTraits<ash::mojom::ShelfItemDataView, ash::ShelfItem>; |
| // static |
| +bool StructTraits<ash::mojom::ShelfIDDataView, ash::ShelfID>::Read( |
| + ash::mojom::ShelfIDDataView data, |
| + ash::ShelfID* out) { |
| + // A non-empty launch id requires a non-empty app id. |
| + return data.ReadAppId(&out->app_id) && !data.ReadLaunchId(&out->launch_id) && |
|
James Cook
2017/05/04 22:14:08
extra "!" here?
Also, this might be clearer if it
msw
2017/05/04 23:06:50
Done. Good catch!
|
| + (out->launch_id.empty() || !out->app_id.empty()); |
| +} |
| + |
| +// static |
| const SkBitmap& ShelfItemStructTraits::image(const ash::ShelfItem& i) { |
| // TODO(crbug.com/655874): Remove this when we have a gfx::Image[Skia] mojom. |
| static const SkBitmap kNullSkBitmap; |
| @@ -24,15 +33,11 @@ const SkBitmap& ShelfItemStructTraits::image(const ash::ShelfItem& i) { |
| bool ShelfItemStructTraits::Read(ash::mojom::ShelfItemDataView data, |
| ash::ShelfItem* out) { |
| SkBitmap image; |
| - std::string app_id; |
| - std::string launch_id; |
| if (!data.ReadType(&out->type) || !data.ReadImage(&image) || |
| - !data.ReadStatus(&out->status) || !data.ReadAppId(&app_id) || |
| - !data.ReadLaunchId(&launch_id) || !data.ReadTitle(&out->title)) { |
| + !data.ReadStatus(&out->status) || !data.ReadShelfId(&out->id) || |
| + !data.ReadTitle(&out->title)) { |
| return false; |
| } |
| - out->id = data.shelf_id(); |
| - out->app_launch_id = ash::AppLaunchId(app_id, launch_id); |
| // TODO(crbug.com/655874): Support high-dpi images via gfx::Image[Skia] mojom. |
| out->image = gfx::ImageSkia::CreateFrom1xBitmap(image); |
| out->shows_tooltip = data.shows_tooltip(); |