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

Side by Side 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: more review comments 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 unified diff | Download patch
« no previous file with comments | « ui/views/mus/BUILD.gn ('k') | ui/views/mus/native_widget_mus_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/mus/native_widget_mus.h" 5 #include "ui/views/mus/native_widget_mus.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/thread_task_runner_handle.h" 8 #include "base/thread_task_runner_handle.h"
9 #include "components/mus/public/cpp/property_type_converters.h" 9 #include "components/mus/public/cpp/property_type_converters.h"
10 #include "components/mus/public/cpp/window.h" 10 #include "components/mus/public/cpp/window.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 int32_t behavior = mus::mojom::kResizeBehaviorNone; 189 int32_t behavior = mus::mojom::kResizeBehaviorNone;
190 if (delegate->CanResize()) 190 if (delegate->CanResize())
191 behavior |= mus::mojom::kResizeBehaviorCanResize; 191 behavior |= mus::mojom::kResizeBehaviorCanResize;
192 if (delegate->CanMaximize()) 192 if (delegate->CanMaximize())
193 behavior |= mus::mojom::kResizeBehaviorCanMaximize; 193 behavior |= mus::mojom::kResizeBehaviorCanMaximize;
194 if (delegate->CanMinimize()) 194 if (delegate->CanMinimize())
195 behavior |= mus::mojom::kResizeBehaviorCanMinimize; 195 behavior |= mus::mojom::kResizeBehaviorCanMinimize;
196 return behavior; 196 return behavior;
197 } 197 }
198 198
199 // Returns the 1x window app icon or an empty SkBitmap if no icon is available.
200 // TODO(jamescook): Support other scale factors.
201 SkBitmap AppIconFromDelegate(WidgetDelegate* delegate) {
202 if (!delegate)
203 return SkBitmap();
204 gfx::ImageSkia app_icon = delegate->GetWindowAppIcon();
205 if (app_icon.isNull())
206 return SkBitmap();
207 return app_icon.GetRepresentation(1.f).sk_bitmap();
208 }
209
199 } // namespace 210 } // namespace
200 211
201 class NativeWidgetMus::MusWindowObserver : public mus::WindowObserver { 212 class NativeWidgetMus::MusWindowObserver : public mus::WindowObserver {
202 public: 213 public:
203 explicit MusWindowObserver(NativeWidgetMus* native_widget_mus) 214 explicit MusWindowObserver(NativeWidgetMus* native_widget_mus)
204 : native_widget_mus_(native_widget_mus) { 215 : native_widget_mus_(native_widget_mus) {
205 native_widget_mus_->window_->AddObserver(this); 216 native_widget_mus_->window_->AddObserver(this);
206 } 217 }
207 218
208 ~MusWindowObserver() override { 219 ~MusWindowObserver() override {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 if (!Widget::RequiresNonClientView(init_params.type)) 356 if (!Widget::RequiresNonClientView(init_params.type))
346 return; 357 return;
347 358
348 (*properties)[mus::mojom::WindowManager::kWindowType_Property] = 359 (*properties)[mus::mojom::WindowManager::kWindowType_Property] =
349 mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert( 360 mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert(
350 static_cast<int32_t>( 361 static_cast<int32_t>(
351 mojo::ConvertTo<mus::mojom::WindowType>(init_params.type))); 362 mojo::ConvertTo<mus::mojom::WindowType>(init_params.type)));
352 (*properties)[mus::mojom::WindowManager::kResizeBehavior_Property] = 363 (*properties)[mus::mojom::WindowManager::kResizeBehavior_Property] =
353 mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert( 364 mojo::TypeConverter<const std::vector<uint8_t>, int32_t>::Convert(
354 ResizeBehaviorFromDelegate(init_params.delegate)); 365 ResizeBehaviorFromDelegate(init_params.delegate));
366 SkBitmap app_icon = AppIconFromDelegate(init_params.delegate);
367 if (!app_icon.isNull()) {
368 (*properties)[mus::mojom::WindowManager::kWindowAppIcon_Property] =
369 mojo::TypeConverter<const std::vector<uint8_t>, SkBitmap>::Convert(
370 app_icon);
371 }
355 } 372 }
356 373
357 //////////////////////////////////////////////////////////////////////////////// 374 ////////////////////////////////////////////////////////////////////////////////
358 // NativeWidgetMus, internal::NativeWidgetPrivate implementation: 375 // NativeWidgetMus, internal::NativeWidgetPrivate implementation:
359 376
360 NonClientFrameView* NativeWidgetMus::CreateNonClientFrameView() { 377 NonClientFrameView* NativeWidgetMus::CreateNonClientFrameView() {
361 return new ClientSideNonClientFrameView(GetWidget()); 378 return new ClientSideNonClientFrameView(GetWidget());
362 } 379 }
363 380
364 void NativeWidgetMus::InitNativeWidget(const Widget::InitParams& params) { 381 void NativeWidgetMus::InitNativeWidget(const Widget::InitParams& params) {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 ? window_->GetSharedProperty<base::string16>(kWindowTitle_Property) 552 ? window_->GetSharedProperty<base::string16>(kWindowTitle_Property)
536 : base::string16(); 553 : base::string16();
537 if (current_title == title) 554 if (current_title == title)
538 return false; 555 return false;
539 window_->SetSharedProperty<base::string16>(kWindowTitle_Property, title); 556 window_->SetSharedProperty<base::string16>(kWindowTitle_Property, title);
540 return true; 557 return true;
541 } 558 }
542 559
543 void NativeWidgetMus::SetWindowIcons(const gfx::ImageSkia& window_icon, 560 void NativeWidgetMus::SetWindowIcons(const gfx::ImageSkia& window_icon,
544 const gfx::ImageSkia& app_icon) { 561 const gfx::ImageSkia& app_icon) {
545 // NOTIMPLEMENTED(); 562 const char* const kWindowAppIcon_Property =
563 mus::mojom::WindowManager::kWindowAppIcon_Property;
564
565 if (!app_icon.isNull()) {
566 // Send the app icon 1x bitmap to the window manager.
567 // TODO(jamescook): Support other scale factors.
568 window_->SetSharedProperty<SkBitmap>(
569 kWindowAppIcon_Property, app_icon.GetRepresentation(1.f).sk_bitmap());
570 } else if (window_->HasSharedProperty(kWindowAppIcon_Property)) {
571 // Remove the existing icon.
572 window_->ClearSharedProperty(kWindowAppIcon_Property);
573 }
546 } 574 }
547 575
548 void NativeWidgetMus::InitModalType(ui::ModalType modal_type) { 576 void NativeWidgetMus::InitModalType(ui::ModalType modal_type) {
549 if (modal_type != ui::MODAL_TYPE_NONE) 577 if (modal_type != ui::MODAL_TYPE_NONE)
550 window_->SetModal(); 578 window_->SetModal();
551 } 579 }
552 580
553 gfx::Rect NativeWidgetMus::GetWindowBoundsInScreen() const { 581 gfx::Rect NativeWidgetMus::GetWindowBoundsInScreen() const {
554 return window_ ? window_->GetBoundsInRoot() : gfx::Rect(); 582 return window_ ? window_->GetBoundsInRoot() : gfx::Rect();
555 } 583 }
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 window_tree_host_->Show(); 1005 window_tree_host_->Show();
978 GetNativeWindow()->Show(); 1006 GetNativeWindow()->Show();
979 } else { 1007 } else {
980 window_tree_host_->Hide(); 1008 window_tree_host_->Hide();
981 GetNativeWindow()->Hide(); 1009 GetNativeWindow()->Hide();
982 } 1010 }
983 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible()); 1011 native_widget_delegate_->OnNativeWidgetVisibilityChanged(window->visible());
984 } 1012 }
985 1013
986 } // namespace views 1014 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/BUILD.gn ('k') | ui/views/mus/native_widget_mus_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698