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

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: added unit tests 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
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..9b99d6bd4aeda9e11a24d3a5d9dbad17da8be47c 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,18 @@ bool NativeWidgetMus::SetWindowTitle(const base::string16& title) {
void NativeWidgetMus::SetWindowIcons(const gfx::ImageSkia& window_icon,
const gfx::ImageSkia& app_icon) {
- // NOTIMPLEMENTED();
+ const char* const kWindowAppIcon_Property =
+ mus::mojom::WindowManager::kWindowAppIcon_Property;
+
+ if (!app_icon.isNull()) {
+ // Send the app icon 1x bitmap to the window manager.
+ // TODO(jamescook): Support other scale factors.
+ window_->SetSharedProperty<SkBitmap>(
+ kWindowAppIcon_Property, app_icon.GetRepresentation(1.f).sk_bitmap());
+ } else if (window_->HasSharedProperty(kWindowAppIcon_Property)) {
+ // Remove the existing icon.
+ window_->ClearSharedProperty(kWindowAppIcon_Property);
+ }
}
void NativeWidgetMus::InitModalType(ui::ModalType modal_type) {

Powered by Google App Engine
This is Rietveld 408576698