#include "components/sharing_message/sharing_service.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/favicon/core/favicon_service.h"
#include "components/favicon_base/favicon_types.h"
#include "components/send_tab_to_self/features.h"
#include "components/send_tab_to_self/send_tab_to_self_entry.h"
#include "components/send_tab_to_self/send_tab_to_self_model.h"
#include "components/sharing_message/features.h"
#include "components/sharing_message/sharing_constants.h"
#include "components/sharing_message/sharing_device_registration_result.h"
#include "components/sharing_message/sharing_device_source.h"
#include "components/sharing_message/sharing_fcm_handler.h"
#include "components/sharing_message/sharing_handler_registry.h"
#include "components/sharing_message/sharing_message_handler.h"
#include "components/sharing_message/sharing_metrics.h"
#include "components/sharing_message/sharing_sync_preference.h"
#include "components/sharing_message/sharing_target_device_info.h"
#include "components/sharing_message/sharing_utils.h"
#include "components/sharing_message/vapid_key_manager.h"
#include "components/strings/grit/components_strings.h"
#include "components/sync/protocol/unencrypted_sharing_message.pb.h"
#include "components/sync/service/sync_service.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
SharingService::SharingService(
std::unique_ptr<SharingSyncPreference> sync_prefs,
std::unique_ptr<VapidKeyManager> vapid_key_manager,
std::unique_ptr<SharingDeviceRegistration> sharing_device_registration,
std::unique_ptr<SharingMessageSender> message_sender,
std::unique_ptr<SharingDeviceSource> device_source,
std::unique_ptr<SharingHandlerRegistry> handler_registry,
std::unique_ptr<SharingFCMHandler> fcm_handler,
syncer::SyncService* sync_service,
favicon::FaviconService* favicon_service,
send_tab_to_self::SendTabToSelfModel* send_tab_model,
scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: … { … }
SharingService::~SharingService() { … }
std::optional<SharingTargetDeviceInfo> SharingService::GetDeviceByGuid(
const std::string& guid) const { … }
SharingService::SharingDeviceList SharingService::GetDeviceCandidates(
sync_pb::SharingSpecificFields::EnabledFeatures required_feature) const { … }
base::OnceClosure SharingService::SendMessageToDevice(
const SharingTargetDeviceInfo& device,
base::TimeDelta response_timeout,
components_sharing_message::SharingMessage message,
SharingMessageSender::ResponseCallback callback) { … }
base::OnceClosure SharingService::SendUnencryptedMessageToDevice(
const SharingTargetDeviceInfo& device,
sync_pb::UnencryptedSharingMessage message,
SharingMessageSender::ResponseCallback callback) { … }
void SharingService::RegisterSharingHandler(
std::unique_ptr<SharingMessageHandler> handler,
components_sharing_message::SharingMessage::PayloadCase payload_case) { … }
void SharingService::UnregisterSharingHandler(
components_sharing_message::SharingMessage::PayloadCase payload_case) { … }
void SharingService::SetNotificationActionHandler(
const std::string& notification_id,
NotificationActionCallback callback) { … }
SharingService::NotificationActionCallback
SharingService::GetNotificationActionHandler(
const std::string& notification_id) const { … }
SharingDeviceSource* SharingService::GetDeviceSource() const { … }
SharingService::State SharingService::GetStateForTesting() const { … }
SharingSyncPreference* SharingService::GetSyncPreferencesForTesting() const { … }
SharingFCMHandler* SharingService::GetFCMHandlerForTesting() const { … }
SharingMessageSender* SharingService::GetMessageSenderForTesting() const { … }
SharingMessageHandler* SharingService::GetSharingHandlerForTesting(
components_sharing_message::SharingMessage::PayloadCase payload_case)
const { … }
void SharingService::EntryAddedLocally(
const send_tab_to_self::SendTabToSelfEntry* entry) { … }
void SharingService::OnSyncShutdown(syncer::SyncService* sync) { … }
void SharingService::OnStateChanged(syncer::SyncService* sync) { … }
void SharingService::RefreshVapidKey() { … }
void SharingService::RegisterDevice() { … }
void SharingService::RegisterDeviceInTesting(
std::set<sync_pb::SharingSpecificFields_EnabledFeatures> enabled_features,
SharingDeviceRegistration::RegistrationCallback callback) { … }
void SharingService::UnregisterDevice() { … }
void SharingService::OnDeviceRegistered(
SharingDeviceRegistrationResult result) { … }
void SharingService::OnDeviceUnregistered(
SharingDeviceRegistrationResult result) { … }
void SharingService::SendNotificationForSendTabToSelfPush(
const send_tab_to_self::SendTabToSelfEntry& entry,
const favicon_base::FaviconImageResult& result) { … }