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

Unified Diff: ui/views/mus/native_widget_mus.cc

Issue 1824183002: Mash: Show app icons in shelf based on the Widget's app icon (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: //ui/resources Created 4 years, 9 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
« mash/wm/window_manager.cc ('K') | « mash/wm/window_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/mus/native_widget_mus.cc
diff --git a/ui/views/mus/native_widget_mus.cc b/ui/views/mus/native_widget_mus.cc
index 10fa38555069458e4104fa3c7b0dbe7ee4c6ea8e..5339bb1657cd8dd0821f94d0e86fb708c060a212 100644
--- a/ui/views/mus/native_widget_mus.cc
+++ b/ui/views/mus/native_widget_mus.cc
@@ -196,6 +196,17 @@ int ResizeBehaviorFromDelegate(WidgetDelegate* delegate) {
return behavior;
}
+// Returns the 1x window app icon or an empty SkBitmap if no icon is available.
+// TODO(jamescook): Support other scale factors.
+SkBitmap AppIconFromDelegate(WidgetDelegate* delegate) {
+ if (!delegate)
+ return SkBitmap();
+ gfx::ImageSkia app_icon = delegate->GetWindowAppIcon();
+ if (app_icon.isNull())
+ return SkBitmap();
+ return app_icon.GetRepresentation(1.f).sk_bitmap();
+}
+
} // namespace
class NativeWidgetMus::MusWindowObserver : public mus::WindowObserver {
@@ -352,6 +363,12 @@ void NativeWidgetMus::ConfigurePropertiesForNewWindow(
(*properties)[mus::mojom::WindowManager::kResizeBehavior_Property] =
mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert(
ResizeBehaviorFromDelegate(init_params.delegate));
+ SkBitmap app_icon = AppIconFromDelegate(init_params.delegate);
+ if (!app_icon.isNull()) {
+ (*properties)[mus::mojom::WindowManager::kWindowAppIcon_Property] =
+ mojo::TypeConverter<const std::vector<uint8_t>, SkBitmap>::Convert(
+ app_icon);
+ }
}
////////////////////////////////////////////////////////////////////////////////
@@ -542,7 +559,13 @@ bool NativeWidgetMus::SetWindowTitle(const base::string16& title) {
void NativeWidgetMus::SetWindowIcons(const gfx::ImageSkia& window_icon,
const gfx::ImageSkia& app_icon) {
- // NOTIMPLEMENTED();
+ if (!app_icon.isNull()) {
sky 2016/03/23 23:30:40 Seems like you should always update the icon. That
James Cook 2016/03/25 15:39:28 Done. This revealed a problem that both the primar
+ // Send the app icon 1x bitmap to the window manager.
+ // TODO(jamescook): Support other scale factors.
+ window_->SetSharedProperty<SkBitmap>(
+ mus::mojom::WindowManager::kWindowAppIcon_Property,
+ app_icon.GetRepresentation(1.f).sk_bitmap());
+ }
}
void NativeWidgetMus::InitModalType(ui::ModalType modal_type) {
« mash/wm/window_manager.cc ('K') | « mash/wm/window_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698