-
Notifications
You must be signed in to change notification settings - Fork 6.7k
/
test_app_registrar.h
104 lines (91 loc) · 4.3 KB
/
test_app_registrar.h
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Copyright 2019 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 CHROME_BROWSER_WEB_APPLICATIONS_TEST_TEST_APP_REGISTRAR_H_
#define CHROME_BROWSER_WEB_APPLICATIONS_TEST_TEST_APP_REGISTRAR_H_
#include <map>
#include <set>
#include <string>
#include <vector>
#include "base/optional.h"
#include "chrome/browser/web_applications/components/app_registrar.h"
#include "chrome/browser/web_applications/components/web_app_constants.h"
#include "chrome/browser/web_applications/components/web_app_id.h"
#include "chrome/browser/web_applications/components/web_application_info.h"
#include "components/services/app_service/public/cpp/url_handler_info.h"
#include "url/gurl.h"
namespace base {
class Time;
}
namespace web_app {
// Deprecated. Please use TestWebAppRegistryController instead.
class TestAppRegistrar : public AppRegistrar {
public:
struct AppInfo {
GURL install_url;
ExternalInstallSource source = ExternalInstallSource::kExternalDefault;
GURL launch_url;
};
TestAppRegistrar();
~TestAppRegistrar() override;
// Adds |url| to the map of installed apps and returns the generated AppId.
void AddExternalApp(const AppId& app_id, const AppInfo& info);
// Removes an app from the map of installed apps.
void RemoveExternalApp(const AppId& app_id);
void RemoveExternalAppByInstallUrl(const GURL& install_url);
// AppRegistrar
bool IsInstalled(const AppId& app_id) const override;
bool IsLocallyInstalled(const AppId& app_id) const override;
bool WasInstalledByUser(const AppId& app_id) const override;
bool WasInstalledByOem(const AppId& app_id) const override;
std::map<AppId, GURL> GetExternallyInstalledApps(
ExternalInstallSource install_source) const override;
base::Optional<AppId> LookupExternalAppId(
const GURL& install_url) const override;
bool HasExternalAppWithInstallSource(
const AppId& app_id,
ExternalInstallSource install_source) const override;
int CountUserInstalledApps() const override;
std::string GetAppShortName(const AppId& app_id) const override;
std::string GetAppDescription(const AppId& app_id) const override;
base::Optional<SkColor> GetAppThemeColor(const AppId& app_id) const override;
base::Optional<SkColor> GetAppBackgroundColor(
const AppId& app_id) const override;
const GURL& GetAppStartUrl(const AppId& app_id) const override;
const std::string* GetAppLaunchQueryParams(
const AppId& app_id) const override;
const apps::ShareTarget* GetAppShareTarget(
const AppId& app_id) const override;
blink::mojom::CaptureLinks GetAppCaptureLinks(
const AppId& app_id) const override;
const apps::FileHandlers* GetAppFileHandlers(
const AppId& app_id) const override;
bool IsAppFileHandlerPermissionBlocked(
const web_app::AppId& app_id) const override;
base::Optional<GURL> GetAppScopeInternal(const AppId& app_id) const override;
DisplayMode GetAppDisplayMode(const AppId& app_id) const override;
DisplayMode GetAppUserDisplayMode(const AppId& app_id) const override;
std::vector<DisplayMode> GetAppDisplayModeOverride(
const AppId& app_id) const override;
apps::UrlHandlers GetAppUrlHandlers(const AppId& app_id) const override;
GURL GetAppManifestUrl(const AppId& app_id) const override;
base::Time GetAppLastBadgingTime(const AppId& app_id) const override;
base::Time GetAppLastLaunchTime(const AppId& app_id) const override;
base::Time GetAppInstallTime(const AppId& app_id) const override;
std::vector<WebApplicationIconInfo> GetAppIconInfos(
const AppId& app_id) const override;
SortedSizesPx GetAppDownloadedIconSizesAny(
const AppId& app_id) const override;
std::vector<WebApplicationShortcutsMenuItemInfo> GetAppShortcutsMenuItemInfos(
const AppId& app_id) const override;
std::vector<IconSizes> GetAppDownloadedShortcutsMenuIconsSizes(
const AppId& app_id) const override;
RunOnOsLoginMode GetAppRunOnOsLoginMode(const AppId& app_id) const override;
std::vector<AppId> GetAppIds() const override;
WebAppRegistrar* AsWebAppRegistrar() override;
const WebAppRegistrar* AsWebAppRegistrar() const override;
private:
std::map<AppId, AppInfo> installed_apps_;
};
} // namespace web_app
#endif // CHROME_BROWSER_WEB_APPLICATIONS_TEST_TEST_APP_REGISTRAR_H_