Commit 9df7c9f3 authored by Xiyuan Xia's avatar Xiyuan Xia Committed by Commit Bot

ws2: Show KSV app icon on shelf

KSV app registers ash specific window properties and sets up to
use MusPropertyMirrorAsh. ShelfWindowWatcher is then able to take
care of the rest.

Also make InternalAppWindowShelfController to ignore visibility
change for windows it does not observe. Otherwise, it crashes
when it attempts to manage the content window from KSV app.

Bug: 848884
Change-Id: Ib9c1e46eb3f39bdda4e66529d0497a4ef775b80f
Reviewed-on: https://chromium-review.googlesource.com/1091799Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Commit-Queue: Xiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565625}
parent 53e1a9c3
......@@ -6,12 +6,15 @@
#include "ash/components/shortcut_viewer/last_window_closed_observer.h"
#include "ash/components/shortcut_viewer/views/keyboard_shortcut_view.h"
#include "ash/public/cpp/mus_property_mirror_ash.h"
#include "ash/public/cpp/window_properties.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/service_manager/public/cpp/service_context.h"
#include "ui/events/devices/input_device_manager.h"
#include "ui/views/mus/aura_init.h"
#include "ui/views/mus/mus_client.h"
namespace keyboard_shortcut_viewer {
......@@ -38,6 +41,16 @@ void ShortcutViewerApplication::OnStart() {
return;
}
views::MusClient* mus_client = views::MusClient::Get();
aura::WindowTreeClientDelegate* delegate = mus_client;
// Registers ash specific window properties to be transported.
ash::RegisterWindowProperties(delegate->GetPropertyConverter());
// Setup property mirror between window and host.
mus_client->SetMusPropertyMirror(
std::make_unique<ash::MusPropertyMirrorAsh>());
// Quit the application when the window is closed.
last_window_closed_observer_ = std::make_unique<LastWindowClosedObserver>(
context()->CreateQuitClosure());
......
......@@ -44,8 +44,8 @@ void InternalAppWindowShelfController::OnWindowInitialized(
views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
if (!widget || !widget->is_top_level())
return;
observed_windows_.push_back(window);
observed_windows_.push_back(window);
window->AddObserver(this);
}
......@@ -73,6 +73,12 @@ void InternalAppWindowShelfController::OnWindowVisibilityChanged(
if (!visible)
return;
// Skip OnWindowVisibilityChanged for ancestors/descendants.
auto it =
std::find(observed_windows_.begin(), observed_windows_.end(), window);
if (it == observed_windows_.end())
return;
ash::ShelfID shelf_id =
ash::ShelfID::Deserialize(window->GetProperty(ash::kShelfIDKey));
if (shelf_id.IsNull() || !app_list::IsInternalApp(shelf_id.app_id))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment