blob: 9463f00087bb85445588da1b168d514c77e83262 [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
Arthur Sonzognife132ee2024-01-15 11:01:048#include <optional>
Alan Cuttereb525cd02020-06-20 03:12:429#include <vector>
10
Carlos Frias514cf672020-08-13 23:53:4311#include "chrome/browser/web_applications/proto/web_app.pb.h"
Louise Brett2cc8f482023-05-16 15:15:2912#include "chrome/browser/web_applications/proto/web_app_tab_strip.pb.h"
13#include "chrome/browser/web_applications/proto/web_app_url_pattern.pb.h"
Alan Cuttereb525cd02020-06-20 03:12:4214#include "chrome/browser/web_applications/web_app.h"
15#include "components/sync/protocol/web_app_specifics.pb.h"
Kasie Wangba026122023-01-19 21:58:5916#include "content/browser/background_fetch/background_fetch.pb.h"
Yoshisato Yanagisawa51abed9c2023-06-28 23:30:1717#include "third_party/blink/public/common/safe_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
Arthur Sonzognife132ee2024-01-15 11:01:0433std::optional<std::vector<apps::IconInfo>> ParseAppIconInfos(
Evan Stadefbe5ca52021-08-19 00:51:4334 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
Arthur Sonzognife132ee2024-01-15 11:01:0437std::optional<std::vector<blink::Manifest::ImageResource>>
Kasie Wangba026122023-01-19 21:58:5938ParseAppImageResource(const char* container_name_for_logging,
39 const RepeatedImageResourceProto& manifest_icons_proto);
40
Glen Robertson2585e8a92020-07-29 08:33:0841// Use the given |icon_info| to populate a |WebAppIconInfo| sync proto.
Evan Stadefbe5ca52021-08-19 00:51:4342sync_pb::WebAppIconInfo AppIconInfoToSyncProto(const apps::IconInfo& icon_info);
43
Kasie Wangba026122023-01-19 21:58:5944// Use the given |image_resource| to populate a |ImageResource| proto.
45content::proto::ImageResource AppImageResourceToProto(
46 const blink::Manifest::ImageResource& image_resource);
47
Daniel Murphyadf553062025-03-10 16:46:3548RunOnOsLoginMode ToRunOnOsLoginMode(proto::WebApp::RunOnOsLoginMode mode);
Carlos Frias514cf672020-08-13 23:53:4349
Daniel Murphyadf553062025-03-10 16:46:3550proto::WebApp::RunOnOsLoginMode ToWebAppProtoRunOnOsLoginMode(
Carlos Frias514cf672020-08-13 23:53:4351 RunOnOsLoginMode mode);
52
Arthur Sonzognife132ee2024-01-15 11:01:0453std::optional<blink::SafeUrlPattern> ToUrlPattern(
Louise Brett2cc8f482023-05-16 15:15:2954 const proto::UrlPattern& proto_url_pattern);
55
Yoshisato Yanagisawa51abed9c2023-06-28 23:30:1756proto::UrlPattern ToUrlPatternProto(const blink::SafeUrlPattern& url_pattern);
Louise Brett2cc8f482023-05-16 15:15:2957
Arthur Sonzognife132ee2024-01-15 11:01:0458std::optional<TabStrip> ProtoToTabStrip(proto::TabStrip tab_strip_proto);
Louise Brett2cc8f482023-05-16 15:15:2959
Glen Robertsonf429224d2024-05-03 02:44:3260// Compute the relative manifest ID path as used in the sync proto.
61std::string RelativeManifestIdPath(webapps::ManifestId manifest_id);
62
Alan Cuttereb525cd02020-06-20 03:12:4263} // namespace web_app
64
65#endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_PROTO_UTILS_H_