Commit b0b3f579 authored by Ahmed Fakhry's avatar Ahmed Fakhry Committed by Commit Bot

Minor refactor of ShelfWindowWatcher

Get rid of an unused variable, and properly use OnWindowAdded()
instead of OnWindowHierarchyChanged() which can be triggered for
many events we're not interested in.

BUG=997102

Change-Id: If9f7677bdb6c7f73ddcfa455139149e4d7922ce8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2223367Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#773739}
parent 51f8ed4d
......@@ -17,6 +17,7 @@
#include "base/strings/string_util.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/display/types/display_constants.h"
#include "ui/resources/grit/ui_resources.h"
#include "ui/wm/public/activation_client.h"
......@@ -69,17 +70,12 @@ ShelfWindowWatcher::ContainerWindowObserver::ContainerWindowObserver(
ShelfWindowWatcher::ContainerWindowObserver::~ContainerWindowObserver() =
default;
// static
const char ShelfWindowWatcher::kDefaultShelfIdPrefix[] = "ShelfWindowWatcher";
void ShelfWindowWatcher::ContainerWindowObserver::OnWindowHierarchyChanged(
const HierarchyChangeParams& params) {
if (!params.old_parent && params.new_parent &&
desks_util::IsDeskContainer(params.new_parent)) {
// A new window was created in one of the desks' containers. Note that the
// shelf is globally showing all apps from all active and inactive desks.
window_watcher_->OnUserWindowAdded(params.target);
}
void ShelfWindowWatcher::ContainerWindowObserver::OnWindowAdded(
aura::Window* new_window) {
DCHECK(new_window);
DCHECK(new_window->parent());
DCHECK(desks_util::IsDeskContainer(new_window->parent()));
window_watcher_->OnUserWindowAdded(new_window);
}
void ShelfWindowWatcher::ContainerWindowObserver::OnWindowDestroying(
......
......@@ -27,8 +27,6 @@ class ShelfWindowWatcher : public ::wm::ActivationChangeObserver,
explicit ShelfWindowWatcher(ShelfModel* model);
~ShelfWindowWatcher() override;
static const char kDefaultShelfIdPrefix[];
private:
// Observes for windows being added to a root window's default container.
class ContainerWindowObserver : public aura::WindowObserver {
......@@ -38,7 +36,7 @@ class ShelfWindowWatcher : public ::wm::ActivationChangeObserver,
private:
// aura::WindowObserver:
void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override;
void OnWindowAdded(aura::Window* new_window) override;
void OnWindowDestroying(aura::Window* window) override;
ShelfWindowWatcher* window_watcher_;
......
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