blob: 70f01aab21a81ee79296238ef570aa05deb7e14a [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2020 The Chromium Authors
Alan Cuttereb525cd02020-06-20 03:12:422// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_PROTO_UTILS_H_
6#define CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_PROTO_UTILS_H_
7
8#include <vector>
9
Carlos Frias514cf672020-08-13 23:53:4310#include "chrome/browser/web_applications/proto/web_app.pb.h"
Louise Brett2cc8f482023-05-16 15:15:2911#include "chrome/browser/web_applications/proto/web_app_tab_strip.pb.h"
12#include "chrome/browser/web_applications/proto/web_app_url_pattern.pb.h"
Alan Cuttereb525cd02020-06-20 03:12:4213#include "chrome/browser/web_applications/web_app.h"
14#include "components/sync/protocol/web_app_specifics.pb.h"
Kasie Wangba026122023-01-19 21:58:5915#include "content/browser/background_fetch/background_fetch.pb.h"
Anton Bikineev46bbb972021-05-15 17:53:5316#include "third_party/abseil-cpp/absl/types/optional.h"
Louise Brett2cc8f482023-05-16 15:15:2917#include "third_party/blink/public/common/url_pattern.h"
Alan Cuttereb525cd02020-06-20 03:12:4218
Evan Stadefbe5ca52021-08-19 00:51:4319namespace apps {
20struct IconInfo;
21}
22
Alan Cuttereb525cd02020-06-20 03:12:4223namespace web_app {
24
Carlos Frias514cf672020-08-13 23:53:4325enum class RunOnOsLoginMode;
26
Alan Cuttereb525cd02020-06-20 03:12:4227using RepeatedIconInfosProto =
28 const ::google::protobuf::RepeatedPtrField<::sync_pb::WebAppIconInfo>;
29
Kasie Wangba026122023-01-19 21:58:5930using RepeatedImageResourceProto =
31 const ::google::protobuf::RepeatedPtrField<content::proto::ImageResource>;
32
Evan Stadefbe5ca52021-08-19 00:51:4333absl::optional<std::vector<apps::IconInfo>> ParseAppIconInfos(
34 const char* container_name_for_logging,
Eric Willigers197ff882022-03-02 07:15:4535 const RepeatedIconInfosProto& manifest_icons_proto);
Evan Stadefbe5ca52021-08-19 00:51:4336
Kasie Wangba026122023-01-19 21:58:5937absl::optional<std::vector<blink::Manifest::ImageResource>>
38ParseAppImageResource(const char* container_name_for_logging,
39 const RepeatedImageResourceProto& manifest_icons_proto);
40
Glen Robertson2c6387b2020-07-10 06:31:5941// Use the given |app| to populate a |WebAppSpecifics| sync proto.
42sync_pb::WebAppSpecifics WebAppToSyncProto(const WebApp& app);
43
Glen Robertson2585e8a92020-07-29 08:33:0844// Use the given |icon_info| to populate a |WebAppIconInfo| sync proto.
Evan Stadefbe5ca52021-08-19 00:51:4345sync_pb::WebAppIconInfo AppIconInfoToSyncProto(const apps::IconInfo& icon_info);
46
Kasie Wangba026122023-01-19 21:58:5947// Use the given |image_resource| to populate a |ImageResource| proto.
48content::proto::ImageResource AppImageResourceToProto(
49 const blink::Manifest::ImageResource& image_resource);
50
Anton Bikineev46bbb972021-05-15 17:53:5351absl::optional<WebApp::SyncFallbackData> ParseSyncFallbackDataStruct(
Alan Cuttereb525cd02020-06-20 03:12:4252 const sync_pb::WebAppSpecifics& sync_proto);
53
Glen Robertson2c6387b2020-07-10 06:31:5954::sync_pb::WebAppSpecifics::UserDisplayMode ToWebAppSpecificsUserDisplayMode(
55 DisplayMode user_display_mode);
56
Carlos Frias514cf672020-08-13 23:53:4357RunOnOsLoginMode ToRunOnOsLoginMode(WebAppProto::RunOnOsLoginMode mode);
58
59WebAppProto::RunOnOsLoginMode ToWebAppProtoRunOnOsLoginMode(
60 RunOnOsLoginMode mode);
61
Louise Brett2cc8f482023-05-16 15:15:2962absl::optional<blink::UrlPattern> ToUrlPattern(
63 const proto::UrlPattern& proto_url_pattern);
64
65proto::UrlPattern ToUrlPatternProto(const blink::UrlPattern& url_pattern);
66
67absl::optional<TabStrip> ProtoToTabStrip(proto::TabStrip tab_strip_proto);
68
Alan Cuttereb525cd02020-06-20 03:12:4269} // namespace web_app
70
71#endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_PROTO_UTILS_H_