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

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

Issue 2519583002: Add gfx::ImageSkia and icon support to aura::PropertyConverter. (Closed)
Patch Set: Fix ConvertPropertyForTransport; add unit test. Created 4 years, 1 month 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 | « ui/aura/mus/property_converter_unittest.cc ('k') | ui/views/mus/native_widget_mus_unittest.cc » ('j') | 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 f96f2a2c72be436167026e0693aae80fcd2b77ee..996c3aa3cf2a2750702b562a2aaaa493c7321057 100644
--- a/ui/views/mus/native_widget_mus.cc
+++ b/ui/views/mus/native_widget_mus.cc
@@ -337,17 +337,6 @@ 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();
-}
-
// Handles acknowledgment of an input event, either immediately when a nested
// message loop starts, or upon destruction.
class EventAckHandler : public base::MessageLoop::NestingObserver {
@@ -404,6 +393,18 @@ ui::mojom::ShowState GetShowState(const ui::Window* window) {
ui::mojom::WindowManager::kShowState_Property));
}
+// Set the app or window icon property for the window.
+void SetIconProperty(ui::Window* window,
+ const char* const property,
+ const gfx::ImageSkia& icon) {
+ // TODO(crbug.com/667566): Support additional scales or gfx::Image[Skia].
+ SkBitmap bitmap = icon.GetRepresentation(1.f).sk_bitmap();
+ if (!bitmap.isNull())
+ window->SetSharedProperty<SkBitmap>(property, bitmap);
+ else if (window->HasSharedProperty(property))
+ window->ClearSharedProperty(property);
+}
+
} // namespace
class NativeWidgetMus::MusWindowObserver : public ui::WindowObserver {
@@ -692,10 +693,22 @@ void NativeWidgetMus::ConfigurePropertiesForNewWindow(
mojo::ConvertTo<std::vector<uint8_t>>(
ResizeBehaviorFromDelegate(init_params.delegate));
}
- SkBitmap app_icon = AppIconFromDelegate(init_params.delegate);
- if (!app_icon.isNull()) {
- (*properties)[ui::mojom::WindowManager::kWindowAppIcon_Property] =
- mojo::ConvertTo<std::vector<uint8_t>>(app_icon);
+
+ if (init_params.delegate) {
+ // TODO(crbug.com/667566): Support additional scales or gfx::Image[Skia].
+ gfx::ImageSkia app_icon = init_params.delegate->GetWindowAppIcon();
+ SkBitmap app_bitmap = app_icon.GetRepresentation(1.f).sk_bitmap();
+ if (!app_bitmap.isNull()) {
+ (*properties)[ui::mojom::WindowManager::kAppIcon_Property] =
+ mojo::ConvertTo<std::vector<uint8_t>>(app_bitmap);
+ }
+ // TODO(crbug.com/667566): Support additional scales or gfx::Image[Skia].
+ gfx::ImageSkia window_icon = init_params.delegate->GetWindowIcon();
+ SkBitmap window_bitmap = window_icon.GetRepresentation(1.f).sk_bitmap();
+ if (!window_bitmap.isNull()) {
+ (*properties)[ui::mojom::WindowManager::kWindowIcon_Property] =
+ mojo::ConvertTo<std::vector<uint8_t>>(window_bitmap);
+ }
}
}
@@ -939,18 +952,10 @@ void NativeWidgetMus::SetWindowIcons(const gfx::ImageSkia& window_icon,
if (is_parallel_widget_in_window_manager())
return;
- const char* const kWindowAppIcon_Property =
- ui::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);
- }
+ SetIconProperty(window_, ui::mojom::WindowManager::kWindowIcon_Property,
+ window_icon);
+ SetIconProperty(window_, ui::mojom::WindowManager::kAppIcon_Property,
+ app_icon);
}
void NativeWidgetMus::InitModalType(ui::ModalType modal_type) {
« no previous file with comments | « ui/aura/mus/property_converter_unittest.cc ('k') | ui/views/mus/native_widget_mus_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698