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
79
80
81
82
83
84
85
86
87
88
89
90
ash / public / cpp / test / test_saved_desk_delegate.cc [blame]
// Copyright 2021 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/public/cpp/test/test_saved_desk_delegate.h"
#include "ash/public/cpp/desk_template.h"
#include "ash/public/cpp/window_properties.h"
#include "base/containers/contains.h"
#include "components/app_restore/app_launch_info.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
#include "ui/color/color_provider.h"
#include "ui/gfx/image/image_skia.h"
namespace ash {
TestSavedDeskDelegate::TestSavedDeskDelegate() = default;
TestSavedDeskDelegate::~TestSavedDeskDelegate() = default;
void TestSavedDeskDelegate::GetAppLaunchDataForSavedDesk(
aura::Window* window,
GetAppLaunchDataCallback callback) const {
if (window) {
if (const std::string* app_id = window->GetProperty(kAppIDKey)) {
if (app_ids_with_app_launch_info_.contains(*app_id)) {
std::move(callback).Run(std::make_unique<app_restore::AppLaunchInfo>(
*app_id, /*window_id=*/0));
return;
}
}
}
std::move(callback).Run({});
}
desks_storage::DeskModel* TestSavedDeskDelegate::GetDeskModel() {
return desk_model_;
}
desks_storage::AdminTemplateService*
TestSavedDeskDelegate::GetAdminTemplateService() {
return admin_template_service_;
}
bool TestSavedDeskDelegate::IsWindowPersistable(aura::Window* window) const {
return true;
}
std::optional<gfx::ImageSkia>
TestSavedDeskDelegate::MaybeRetrieveIconForSpecialIdentifier(
const std::string& identifier,
const ui::ColorProvider* color_provider) const {
return std::nullopt;
}
void TestSavedDeskDelegate::GetFaviconForUrl(
const std::string& page_url,
base::OnceCallback<void(const gfx::ImageSkia&)> callback,
base::CancelableTaskTracker* tracker) const {
std::move(callback).Run(gfx::ImageSkia());
}
void TestSavedDeskDelegate::GetIconForAppId(
const std::string& app_id,
int desired_icon_size,
base::OnceCallback<void(const gfx::ImageSkia&)> callback) const {
// `default_app_icon_` will be null if not set.
if (!default_app_icon_.isNull()) {
std::move(callback).Run(default_app_icon_);
}
}
void TestSavedDeskDelegate::LaunchAppsFromSavedDesk(
std::unique_ptr<DeskTemplate> saved_desk) {}
bool TestSavedDeskDelegate::IsWindowSupportedForSavedDesk(
aura::Window* window) const {
return DeskTemplate::IsAppTypeSupported(window);
}
std::string TestSavedDeskDelegate::GetAppShortName(const std::string& app_id) {
return std::string();
}
bool TestSavedDeskDelegate::IsAppAvailable(const std::string& app_id) const {
return !base::Contains(unavailable_app_ids_, app_id);
}
} // namespace ash