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

Unified Diff: components/exo/shell_surface.cc

Issue 2900783003: Handle app custom icon via aura::Window property. (Closed)
Patch Set: cleanup 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
Index: components/exo/shell_surface.cc
diff --git a/components/exo/shell_surface.cc b/components/exo/shell_surface.cc
index e4fff6f17a71d2ddb9ce98a97105c2dec3b6f52f..d576f80ad4357fd4095a7906c03f51b1dc5af97a 100644
--- a/components/exo/shell_surface.cc
+++ b/components/exo/shell_surface.cc
@@ -48,6 +48,8 @@
#include "chromeos/audio/chromeos_sounds.h"
#endif
+DECLARE_UI_CLASS_PROPERTY_TYPE(exo::ShellSurface*)
+
namespace exo {
namespace {
@@ -312,6 +314,7 @@ ShellSurface::ScopedAnimationsDisabled::~ScopedAnimationsDisabled() {
// ShellSurface, public:
DEFINE_LOCAL_UI_CLASS_PROPERTY_KEY(Surface*, kMainSurfaceKey, nullptr)
+DEFINE_LOCAL_UI_CLASS_PROPERTY_KEY(ShellSurface*, kThisSurfaceKey, nullptr)
ShellSurface::ShellSurface(Surface* surface,
ShellSurface* parent,
@@ -572,6 +575,20 @@ void ShellSurface::SetApplicationId(const std::string& application_id) {
SetApplicationId(widget_->GetNativeWindow(), application_id);
}
+// static
+void ShellSurface::SetAppIcon(aura::Window* window,
+ const gfx::ImageSkia& icon) {
+ DCHECK(!GetApplicationId(window).empty());
+ ShellSurface* this_surface = window->GetProperty(kThisSurfaceKey);
+ if (this_surface) {
+ this_surface->icon_ = icon;
+ this_surface->widget_->UpdateWindowIcon();
+ } else {
+ // Support unit test case.
+ window->SetProperty(aura::client::kAppIconKey, new gfx::ImageSkia(icon));
+ }
+}
+
void ShellSurface::Move() {
TRACE_EVENT0("exo", "ShellSurface::Move");
@@ -857,6 +874,10 @@ base::string16 ShellSurface::GetWindowTitle() const {
return title_;
}
+gfx::ImageSkia ShellSurface::GetWindowIcon() {
+ return icon_;
+}
+
void ShellSurface::SaveWindowPlacement(const gfx::Rect& bounds,
ui::WindowShowState show_state) {
if (bounds_mode_ != BoundsMode::CLIENT)
@@ -1201,6 +1222,7 @@ void ShellSurface::CreateShellSurfaceWidget(ui::WindowShowState show_state) {
window->SetEventTargeter(base::WrapUnique(new CustomWindowTargeter(widget_)));
SetApplicationId(window, application_id_);
SetMainSurface(window, surface_);
+ window->SetProperty(kThisSurfaceKey, this);
// Start tracking changes to window bounds and window state.
window->AddObserver(this);

Powered by Google App Engine
This is Rietveld 408576698