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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
ash / birch / birch_coral_item.h [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.
#ifndef ASH_BIRCH_BIRCH_CORAL_ITEM_H_
#define ASH_BIRCH_BIRCH_CORAL_ITEM_H_
#include <string>
#include "ash/ash_export.h"
#include "ash/birch/birch_item.h"
#include "ash/birch/coral_constants.h"
#include "base/functional/callback_forward.h"
#include "base/json/json_writer.h"
#include "ui/base/models/image_model.h"
#include "url/gurl.h"
namespace ash {
class BirchChipButtonBase;
class ASH_EXPORT BirchCoralItem : public BirchItem {
public:
// The actions that perform to a coral group. These values are persisted to
// logs. Entries should not be renumbered and numeric values should never be
// reused.
enum class ActionType {
kRestore,
kLaunchToNewDesk,
kSaveAsDeskTemplate,
kMaxValue = kSaveAsDeskTemplate,
};
BirchCoralItem(const std::u16string& coral_title,
const std::u16string& coral_text,
CoralSource source,
const base::Token& group_id);
BirchCoralItem(BirchCoralItem&&);
BirchCoralItem(const BirchCoralItem&);
BirchCoralItem& operator=(const BirchCoralItem&);
bool operator==(const BirchCoralItem& rhs) const;
~BirchCoralItem() override;
// The callback function for the press on the given `birch_chip_button`.
void LaunchGroup(BirchChipButtonBase* birch_chip_button);
const base::Token& group_id() const { return group_id_; }
// BirchItem:
BirchItemType GetType() const override;
std::string ToString() const override;
void PerformAction() override;
void LoadIcon(LoadIconCallback callback) const override;
BirchAddonType GetAddonType() const override;
std::u16string GetAddonAccessibleName() const override;
base::Value::Dict ToCoralItemDetails() const;
private:
// Helper method that calls `birch_client` to retrieve the image from
// `favicon_service`, and passes the result back to `barrier_callback`.
void GetFaviconImageCoral(
const GURL& url,
base::OnceCallback<void(const ui::ImageModel&)> barrier_callback) const;
// Helper method that uses `saved_desk_delegate` to retrieve the app icon
// image, and passes the result back to `barrier_callback`.
void GetAppIconCoral(
const std::string& app_id,
base::OnceCallback<void(const ui::ImageModel&)> barrier_callback) const;
CoralSource source_;
base::Token group_id_;
};
} // namespace ash
#endif // ASH_BIRCH_BIRCH_CORAL_ITEM_H_