Commit 5e832c90 authored by David Black's avatar David Black Committed by Commit Bot

Revert "Remove HoldingSpacePresenter."

This reverts commit 57e175db.

Reason for revert: Seems to break presubmit due to missing OWNERS file

Original change's description:
> Remove HoldingSpacePresenter.
> 
> No longer needed given evolution of feature requirements.
> 
> Bug: 1112469
> Change-Id: Ic31d2a02fcc624ddc101447f68089cfff9bd2660
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2377535
> Reviewed-by: Toni Baržić <tbarzic@chromium.org>
> Commit-Queue: David Black <dmblack@google.com>
> Cr-Commit-Position: refs/heads/master@{#801857}

TBR=tbarzic@chromium.org,dmblack@google.com

Change-Id: I6c7b1254e9af0ae662b8afc7d37db50dff5c312d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1112469
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2377654Reviewed-by: default avatarDavid Black <dmblack@google.com>
Commit-Queue: David Black <dmblack@google.com>
Cr-Commit-Position: refs/heads/master@{#801885}
parent 42ca7582
......@@ -443,6 +443,8 @@ component("ash") {
"highlighter/highlighter_result_view.h",
"highlighter/highlighter_view.cc",
"highlighter/highlighter_view.h",
"holding_space/holding_space_presenter.cc",
"holding_space/holding_space_presenter.h",
"home_screen/drag_window_from_shelf_controller.cc",
"home_screen/drag_window_from_shelf_controller.h",
"home_screen/home_launcher_gesture_handler.cc",
......@@ -1885,6 +1887,7 @@ test("ash_unittests") {
"frame/non_client_frame_view_ash_unittest.cc",
"highlighter/highlighter_controller_unittest.cc",
"highlighter/highlighter_gesture_util_unittest.cc",
"holding_space/holding_space_presenter_unittest.cc",
"home_screen/drag_window_from_shelf_controller_test_api.cc",
"home_screen/drag_window_from_shelf_controller_test_api.h",
"home_screen/drag_window_from_shelf_controller_unittest.cc",
......
# Metadata information for this directory.
#
# For more information on DIR_METADATA files, see:
# https://source.chromium.org/chromium/infra/infra/+/master:go/src/infra/tools/dirmd/README.md
#
# For the schema of this file, see Metadata message:
# https://source.chromium.org/chromium/infra/infra/+/master:go/src/infra/tools/dirmd/proto/dir_metadata.proto
monorail {
component: "UI>Shell>HoldingSpace"
}
\ No newline at end of file
tbarzic@chromium.org
newcomer@chromium.org
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "ash/holding_space/holding_space_presenter.h"
#include "ash/public/cpp/holding_space/holding_space_item.h"
#include "base/stl_util.h"
namespace ash {
HoldingSpacePresenter::HoldingSpacePresenter() {
HoldingSpaceController* const controller = HoldingSpaceController::Get();
controller_observer_.Add(controller);
if (controller->model())
HandleNewModel(controller->model());
}
HoldingSpacePresenter::~HoldingSpacePresenter() = default;
void HoldingSpacePresenter::OnHoldingSpaceModelAttached(
HoldingSpaceModel* model) {
HandleNewModel(model);
}
void HoldingSpacePresenter::OnHoldingSpaceModelDetached(
HoldingSpaceModel* model) {
model_observer_.Remove(model);
item_ids_.clear();
}
void HoldingSpacePresenter::OnHoldingSpaceItemAdded(
const HoldingSpaceItem* item) {
item_ids_[item->type()].push_back(item->id());
}
void HoldingSpacePresenter::OnHoldingSpaceItemRemoved(
const HoldingSpaceItem* item) {
base::Erase(item_ids_[item->type()], item->id());
}
const std::vector<std::string>& HoldingSpacePresenter::GetItemIds(
HoldingSpaceItem::Type type) const {
const auto& item_list_it = item_ids_.find(type);
if (item_list_it == item_ids_.end()) {
static std::vector<std::string> empty_list;
return empty_list;
}
return item_list_it->second;
}
void HoldingSpacePresenter::HandleNewModel(HoldingSpaceModel* model) {
model_observer_.Add(model);
for (auto& item : model->items())
item_ids_[item->type()].push_back(item->id());
}
} // namespace ash
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#ifndef ASH_HOLDING_SPACE_HOLDING_SPACE_PRESENTER_H_
#define ASH_HOLDING_SPACE_HOLDING_SPACE_PRESENTER_H_
#include <string>
#include <vector>
#include "ash/ash_export.h"
#include "ash/public/cpp/holding_space/holding_space_controller.h"
#include "ash/public/cpp/holding_space/holding_space_controller_observer.h"
#include "ash/public/cpp/holding_space/holding_space_item.h"
#include "ash/public/cpp/holding_space/holding_space_model.h"
#include "ash/public/cpp/holding_space/holding_space_model_observer.h"
#include "base/containers/flat_map.h"
#include "base/scoped_observer.h"
namespace ash {
class HoldingSpaceItem;
// Manages the temporary holding space UI for a root window.
// The main job of the class is
// * to observe the holding space model and update item representations in the
// holding space UI.
// * to handle user actions within the holding space UI, and updates the
// holding space model accordingly.
// NOTE: Currently this class only tracks the list of items within the active
// holding space model.
class ASH_EXPORT HoldingSpacePresenter : public HoldingSpaceControllerObserver,
public HoldingSpaceModelObserver {
public:
HoldingSpacePresenter();
HoldingSpacePresenter(const HoldingSpacePresenter& other) = delete;
HoldingSpacePresenter& operator=(const HoldingSpacePresenter& other) = delete;
~HoldingSpacePresenter() override;
// HoldingSpaceControllerObserver:
void OnHoldingSpaceModelAttached(HoldingSpaceModel* model) override;
void OnHoldingSpaceModelDetached(HoldingSpaceModel* model) override;
// HoldingSpaceModelObserver:
void OnHoldingSpaceItemAdded(const HoldingSpaceItem* item) override;
void OnHoldingSpaceItemRemoved(const HoldingSpaceItem* item) override;
const std::vector<std::string>& GetItemIds(HoldingSpaceItem::Type type) const;
private:
// Handles the items from the model, and starts observing the model.
void HandleNewModel(HoldingSpaceModel* model);
// IDs of items in the active holding space model, as observed by the holding
// space presenter.
base::flat_map<HoldingSpaceItem::Type, std::vector<std::string>> item_ids_;
ScopedObserver<HoldingSpaceController, HoldingSpaceControllerObserver>
controller_observer_{this};
ScopedObserver<HoldingSpaceModel, HoldingSpaceModelObserver> model_observer_{
this};
};
} // namespace ash
#endif // ASH_HOLDING_SPACE_HOLDING_SPACE_PRESENTER_H_
This diff is collapsed.
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