1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34

ash / birch / coral_item_remover.cc [blame]

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/birch/coral_item_remover.h"

#include "ash/birch/coral_util.h"

namespace ash {

CoralItemRemover::CoralItemRemover() = default;

CoralItemRemover::~CoralItemRemover() = default;

void CoralItemRemover::RemoveItem(const coral::mojom::EntityPtr& item) {
  RemoveItem(coral_util::GetIdentifier(item));
}

void CoralItemRemover::RemoveItem(const coral::mojom::Entity& item) {
  RemoveItem(coral_util::GetIdentifier(item));
}

void CoralItemRemover::RemoveItem(const std::string& item_identifier) {
  removed_content_items_.insert(item_identifier);
}

void CoralItemRemover::FilterRemovedItems(
    std::vector<coral::mojom::EntityPtr>* items) {
  std::erase_if(*items, [this](const coral::mojom::EntityPtr& item) {
    return removed_content_items_.contains(coral_util::GetIdentifier(*item));
  });
}

}  // namespace ash