// Copyright 2026 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_SEND_TAB_TO_SELF_SEND_TAB_TO_SELF_UTIL_H_
#define CHROME_BROWSER_UI_SEND_TAB_TO_SELF_SEND_TAB_TO_SELF_UTIL_H_

#include <string_view>

#include "base/memory/weak_ptr.h"
#include "components/sync_device_info/device_info.h"
#include "url/gurl.h"

namespace content {
class WebContents;
}  // namespace content

namespace send_tab_to_self {

class SendTabToSelfEntry;
enum class SendTabToSelfResult;
enum class ShareActivatedEntryPoint;

}  // namespace send_tab_to_self

class Profile;

namespace send_tab_to_self {

// Marks the STTS entry matching `guid` as activated in the model.
void MarkEntryMatchingGuidActivated(Profile* profile,
                                    const std::string& guid,
                                    ShareActivatedEntryPoint entry_point);

// Opens the given `entry` in a new foreground tab for the given `profile`.
// Returns a weak pointer to the opened WebContents.
base::WeakPtr<content::WebContents> OpenEntryInNewForegroundTab(
    Profile* profile,
    const SendTabToSelfEntry& entry,
    ShareActivatedEntryPoint entry_point);

// Opens the given `entry` in a new background tab for the given `profile`.
// Returns a weak pointer to the opened WebContents.
base::WeakPtr<content::WebContents> OpenEntryInNewBackgroundTab(
    Profile* profile,
    const SendTabToSelfEntry& entry);

// Shows a success toast confirming that the tab was successfully sent, if
// `kSendTabToSelfPostSendToast` is enabled.
void ShowTabSentSuccessToast(content::WebContents* web_contents,
                             std::string_view device_name,
                             syncer::DeviceInfo::FormFactor form_factor);

// Shows a toast confirming that the tab was already sent to the device
// recently, if `kSendTabToSelfPostSendToast` is enabled.
void ShowTabSentThrottledToast(content::WebContents* web_contents,
                               std::string_view device_name,
                               syncer::DeviceInfo::FormFactor form_factor);

// Shows a failure toast (or notification if the feature flag is disabled)
// when the tab failed to send.
void ShowTabSentFailure(content::WebContents* web_contents,
                        SendTabToSelfResult result,
                        const GURL& url = GURL());

// Opens the "Manage account devices" page in a new foreground tab for
// `profile` (respecting any modifier keys in `event_flags`).
void OpenManageDevicesPage(Profile* profile, int event_flags);

}  // namespace send_tab_to_self

#endif  // CHROME_BROWSER_UI_SEND_TAB_TO_SELF_SEND_TAB_TO_SELF_UTIL_H_
