[stts-notifs] Move SharingMessageBridge to components/
This CL moves SharingMessageBridge to the components directory
and creates IOSSharingMessageBridgeFactory. SharingMessageBridge
will be used for the Send Tabs Push Notifications feature.
Bug: 343495515
Change-Id: Ideeda9b5a91b7972806965fecbe1aaad20dd10d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5597215
Reviewed-by: David Benjamin <[email protected]>
Reviewed-by: Colin Blundell <[email protected]>
Reviewed-by: Rushan Suleymanov <[email protected]>
Code-Coverage: [email protected] <[email protected]>
Commit-Queue: Colin Blundell <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1313861}
diff --git a/components/sharing_message/sharing_message_bridge.h b/components/sharing_message/sharing_message_bridge.h
new file mode 100644
index 0000000..af36be7
--- /dev/null
+++ b/components/sharing_message/sharing_message_bridge.h
@@ -0,0 +1,39 @@
+// Copyright 2020 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_SHARING_MESSAGE_SHARING_MESSAGE_BRIDGE_H_
+#define COMPONENTS_SHARING_MESSAGE_SHARING_MESSAGE_BRIDGE_H_
+
+#include <memory>
+
+#include "base/functional/callback.h"
+#include "base/memory/weak_ptr.h"
+#include "components/keyed_service/core/keyed_service.h"
+#include "components/sync/protocol/sharing_message_specifics.pb.h"
+
+namespace syncer {
+class ModelTypeControllerDelegate;
+} // namespace syncer
+
+// Class to provide an interface to send sharing messages using Sync.
+class SharingMessageBridge : public KeyedService {
+ public:
+ using CommitFinishedCallback =
+ base::OnceCallback<void(const sync_pb::SharingMessageCommitError&)>;
+
+ // Sends Sharing Message to Sync server. |on_commit_callback| will be called
+ // when commit attempt finishes (either successfully or unsuccessfully).
+ // TODO(crbug.com/40111980): take each parameter separately and construct
+ // specifics inside. Currently this method updates given |specifics| and
+ // fills in |message_id| field.
+ virtual void SendSharingMessage(
+ std::unique_ptr<sync_pb::SharingMessageSpecifics> specifics,
+ CommitFinishedCallback on_commit_callback) = 0;
+
+ // Returns the delegate for the controller, i.e. sync integration point.
+ virtual base::WeakPtr<syncer::ModelTypeControllerDelegate>
+ GetControllerDelegate() = 0;
+};
+
+#endif // COMPONENTS_SHARING_MESSAGE_SHARING_MESSAGE_BRIDGE_H_