Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 1 | // Copyright 2020 The Chromium Authors |
Alan Cutter | eb525cd0 | 2020-06-20 03:12:42 | [diff] [blame] | 2 | // 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 Frias | 514cf67 | 2020-08-13 23:53:43 | [diff] [blame] | 10 | #include "chrome/browser/web_applications/proto/web_app.pb.h" |
Louise Brett | 2cc8f48 | 2023-05-16 15:15:29 | [diff] [blame^] | 11 | #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 Cutter | eb525cd0 | 2020-06-20 03:12:42 | [diff] [blame] | 13 | #include "chrome/browser/web_applications/web_app.h" |
| 14 | #include "components/sync/protocol/web_app_specifics.pb.h" |
Kasie Wang | ba02612 | 2023-01-19 21:58:59 | [diff] [blame] | 15 | #include "content/browser/background_fetch/background_fetch.pb.h" |
Anton Bikineev | 46bbb97 | 2021-05-15 17:53:53 | [diff] [blame] | 16 | #include "third_party/abseil-cpp/absl/types/optional.h" |
Louise Brett | 2cc8f48 | 2023-05-16 15:15:29 | [diff] [blame^] | 17 | #include "third_party/blink/public/common/url_pattern.h" |
Alan Cutter | eb525cd0 | 2020-06-20 03:12:42 | [diff] [blame] | 18 | |
Evan Stade | fbe5ca5 | 2021-08-19 00:51:43 | [diff] [blame] | 19 | namespace apps { |
| 20 | struct IconInfo; |
| 21 | } |
| 22 | |
Alan Cutter | eb525cd0 | 2020-06-20 03:12:42 | [diff] [blame] | 23 | namespace web_app { |
| 24 | |
Carlos Frias | 514cf67 | 2020-08-13 23:53:43 | [diff] [blame] | 25 | enum class RunOnOsLoginMode; |
| 26 | |
Alan Cutter | eb525cd0 | 2020-06-20 03:12:42 | [diff] [blame] | 27 | using RepeatedIconInfosProto = |
| 28 | const ::google::protobuf::RepeatedPtrField<::sync_pb::WebAppIconInfo>; |
| 29 | |
Kasie Wang | ba02612 | 2023-01-19 21:58:59 | [diff] [blame] | 30 | using RepeatedImageResourceProto = |
| 31 | const ::google::protobuf::RepeatedPtrField<content::proto::ImageResource>; |
| 32 | |
Evan Stade | fbe5ca5 | 2021-08-19 00:51:43 | [diff] [blame] | 33 | absl::optional<std::vector<apps::IconInfo>> ParseAppIconInfos( |
| 34 | const char* container_name_for_logging, |
Eric Willigers | 197ff88 | 2022-03-02 07:15:45 | [diff] [blame] | 35 | const RepeatedIconInfosProto& manifest_icons_proto); |
Evan Stade | fbe5ca5 | 2021-08-19 00:51:43 | [diff] [blame] | 36 | |
Kasie Wang | ba02612 | 2023-01-19 21:58:59 | [diff] [blame] | 37 | absl::optional<std::vector<blink::Manifest::ImageResource>> |
| 38 | ParseAppImageResource(const char* container_name_for_logging, |
| 39 | const RepeatedImageResourceProto& manifest_icons_proto); |
| 40 | |
Glen Robertson | 2c6387b | 2020-07-10 06:31:59 | [diff] [blame] | 41 | // Use the given |app| to populate a |WebAppSpecifics| sync proto. |
| 42 | sync_pb::WebAppSpecifics WebAppToSyncProto(const WebApp& app); |
| 43 | |
Glen Robertson | 2585e8a9 | 2020-07-29 08:33:08 | [diff] [blame] | 44 | // Use the given |icon_info| to populate a |WebAppIconInfo| sync proto. |
Evan Stade | fbe5ca5 | 2021-08-19 00:51:43 | [diff] [blame] | 45 | sync_pb::WebAppIconInfo AppIconInfoToSyncProto(const apps::IconInfo& icon_info); |
| 46 | |
Kasie Wang | ba02612 | 2023-01-19 21:58:59 | [diff] [blame] | 47 | // Use the given |image_resource| to populate a |ImageResource| proto. |
| 48 | content::proto::ImageResource AppImageResourceToProto( |
| 49 | const blink::Manifest::ImageResource& image_resource); |
| 50 | |
Anton Bikineev | 46bbb97 | 2021-05-15 17:53:53 | [diff] [blame] | 51 | absl::optional<WebApp::SyncFallbackData> ParseSyncFallbackDataStruct( |
Alan Cutter | eb525cd0 | 2020-06-20 03:12:42 | [diff] [blame] | 52 | const sync_pb::WebAppSpecifics& sync_proto); |
| 53 | |
Glen Robertson | 2c6387b | 2020-07-10 06:31:59 | [diff] [blame] | 54 | ::sync_pb::WebAppSpecifics::UserDisplayMode ToWebAppSpecificsUserDisplayMode( |
| 55 | DisplayMode user_display_mode); |
| 56 | |
Carlos Frias | 514cf67 | 2020-08-13 23:53:43 | [diff] [blame] | 57 | RunOnOsLoginMode ToRunOnOsLoginMode(WebAppProto::RunOnOsLoginMode mode); |
| 58 | |
| 59 | WebAppProto::RunOnOsLoginMode ToWebAppProtoRunOnOsLoginMode( |
| 60 | RunOnOsLoginMode mode); |
| 61 | |
Louise Brett | 2cc8f48 | 2023-05-16 15:15:29 | [diff] [blame^] | 62 | absl::optional<blink::UrlPattern> ToUrlPattern( |
| 63 | const proto::UrlPattern& proto_url_pattern); |
| 64 | |
| 65 | proto::UrlPattern ToUrlPatternProto(const blink::UrlPattern& url_pattern); |
| 66 | |
| 67 | absl::optional<TabStrip> ProtoToTabStrip(proto::TabStrip tab_strip_proto); |
| 68 | |
Alan Cutter | eb525cd0 | 2020-06-20 03:12:42 | [diff] [blame] | 69 | } // namespace web_app |
| 70 | |
| 71 | #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_PROTO_UTILS_H_ |