From cac8709a0d06fee9d9f048b9e779ce59902673a5 Mon Sep 17 00:00:00 2001 From: jamescook Date: Fri, 25 Mar 2016 11:11:53 -0700 Subject: Mash: Show app icons in shelf based on the Widget's app icon * Use the large icon from WidgetDelegate::GetWindowAppIcon(). * In the mojo app's NativeWidgetMus, serialize the icon's SkBitmap as a vector of bytes and set it as a shared window property. * In the window manager, pass the serialized icon to any UserWindowObservers. * In the system UI, deserialize the icon and use it on the shelf. * Set an icon in task_viewer as a demonstration. The window property serialization is handled by a custom TypeConverter for vector, SkBitmap. In the future it would be nice to use the serialized form of the Skia Mojom struct skia.Bitmap, but that will require Mojo to generate a public API to read the serialized bytes. Also fixed an issue where the app's primary widget and the window manager's non-client-frame widget would fight over window titles. A screenshot of the shelf is attached to the bug. BUG=595850 TEST=launch mash, run mojo:task_viewer, note QuickLaunch shelf icon is default but TaskViewer icon is a gear Review URL: https://codereview.chromium.org/1824183002 Cr-Commit-Position: refs/heads/master@{#383312} --- mash/task_viewer/task_viewer.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'mash/task_viewer/task_viewer.cc') diff --git a/mash/task_viewer/task_viewer.cc b/mash/task_viewer/task_viewer.cc index 0e01a00..fb5cb1f 100644 --- a/mash/task_viewer/task_viewer.cc +++ b/mash/task_viewer/task_viewer.cc @@ -19,6 +19,8 @@ #include "mojo/shell/public/cpp/connector.h" #include "mojo/shell/public/interfaces/shell.mojom.h" #include "ui/base/models/table_model.h" +#include "ui/base/resource/resource_bundle.h" +#include "ui/resources/grit/ui_resources.h" #include "ui/views/background.h" #include "ui/views/controls/button/label_button.h" #include "ui/views/controls/table/table_view.h" @@ -87,6 +89,13 @@ class TaskViewerContents : public views::WidgetDelegateView, return base::ASCIIToUTF16("Tasks"); } + gfx::ImageSkia GetWindowAppIcon() override { + // TODO(jamescook): Create a new .pak file for this app and make a custom + // icon, perhaps one that looks like the Chrome OS task viewer icon. + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + return *rb.GetImageSkiaNamed(IDR_NOTIFICATION_SETTINGS); + } + // Overridden from views::View: void Layout() override { gfx::Rect bounds = GetLocalBounds(); -- cgit v1.1