[go: nahoru, domu]

blob: de6c9fdeaeefcd78e26e805a87ad9591a9064766 [file] [log] [blame]
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_BIRCH_BIRCH_MODEL_H_
#define ASH_BIRCH_BIRCH_MODEL_H_
#include <optional>
#include <vector>
#include "ash/ash_export.h"
#include "ash/birch/birch_client.h"
#include "ash/birch/birch_item.h"
#include "base/observer_list.h"
namespace ash {
class BirchWeatherProvider;
// Birch model, which is used to aggregate and store relevant information from
// different providers.
class ASH_EXPORT BirchModel {
public:
// Birch Model Observers are notified when the list of items in the model
// has changed.
class Observer : public base::CheckedObserver {
public:
~Observer() override = default;
// TODO(b/305094143): Add a list of items to the model and call this
// function when the list of items changes.
virtual void OnItemsChanged() = 0;
};
BirchModel();
BirchModel(const BirchModel&) = delete;
BirchModel& operator=(const BirchModel&) = delete;
~BirchModel();
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
// Send a request to the birch keyed service to fetch data into the model.
void RequestBirchDataFetch();
void SetFileSuggestItems(std::vector<BirchFileItem> file_suggest_items);
void SetRecentTabItems(std::vector<BirchTabItem> recent_tab_items);
void SetWeatherItems(std::vector<BirchWeatherItem> weather_items);
void SetClient(BirchClient* client) { birch_client_ = client; }
const std::vector<BirchFileItem>& GetFileSuggestItemsForTest() const {
return file_suggest_items_;
}
const std::vector<BirchTabItem>& GetTabsForTest() const {
return recent_tab_items_;
}
const std::vector<BirchWeatherItem>& GetWeatherForTest() const {
return weather_items_;
}
private:
// A type-specific list of items for all file suggestion items.
std::vector<BirchFileItem> file_suggest_items_;
// A type-specific list of items for all tab items.
std::vector<BirchTabItem> recent_tab_items_;
// A type-specific list of weather items.
std::vector<BirchWeatherItem> weather_items_;
raw_ptr<BirchClient> birch_client_ = nullptr;
std::unique_ptr<BirchWeatherProvider> weather_provider_;
base::ObserverList<Observer> observers_;
};
} // namespace ash
#endif // ASH_BIRCH_BIRCH_MODEL_H_