Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(490)

Unified Diff: ash/public/cpp/shelf_struct_traits.cc

Issue 2860503002: mash: Replace int ShelfIDs with AppLaunchID strings. (Closed)
Patch Set: Fix struct traits typo. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/public/cpp/shelf_struct_traits.h ('k') | ash/public/cpp/shelf_struct_traits_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..219bb291eb4bd57ee79a45eecea57da6fb02f6f1 100644
--- a/ash/public/cpp/shelf_struct_traits.cc
+++ b/ash/public/cpp/shelf_struct_traits.cc
@@ -14,6 +14,16 @@ using ShelfItemStructTraits =
StructTraits<ash::mojom::ShelfItemDataView, ash::ShelfItem>;
// static
+bool StructTraits<ash::mojom::ShelfIDDataView, ash::ShelfID>::Read(
+ ash::mojom::ShelfIDDataView data,
+ ash::ShelfID* out) {
+ if (!data.ReadAppId(&out->app_id) ||!data.ReadLaunchId(&out->launch_id))
+ return false;
+ // A non-empty launch id requires a non-empty app id.
+ return 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 +34,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();
« no previous file with comments | « ash/public/cpp/shelf_struct_traits.h ('k') | ash/public/cpp/shelf_struct_traits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698