#include "chrome/browser/ui/tab_sharing/tab_sharing_infobar_delegate.h"
#include <string>
#include <utility>
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/page_info/page_info_dialog.h"
#include "chrome/browser/ui/tab_sharing/tab_sharing_ui.h"
#include "chrome/grit/generated_resources.h"
#include "components/infobars/content/content_infobar_manager.h"
#include "components/infobars/core/confirm_infobar_delegate.h"
#include "components/infobars/core/infobar.h"
#include "components/page_load_metrics/browser/metrics_web_contents_observer.h"
#include "components/strings/grit/components_strings.h"
#include "components/url_formatter/elide_url.h"
#include "components/vector_icons/vector_icons.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/content_features.h"
#include "net/base/url_util.h"
#include "third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/strings/grit/ui_strings.h"
namespace {
TabRole;
constexpr int kCapturedSurfaceControlIndicatorButtonIconHeight = …;
}
class TabSharingInfoBarDelegate::TabSharingInfoBarDelegateButton { … };
TabSharingInfoBarDelegateButton;
class TabSharingInfoBarDelegate::StopButton
: public TabSharingInfoBarDelegateButton { … };
class TabSharingInfoBarDelegate::ShareTabInsteadButton
: public TabSharingInfoBarDelegateButton { … };
class TabSharingInfoBarDelegate::SwitchToTabButton
: public TabSharingInfoBarDelegateButton { … };
class TabSharingInfoBarDelegate::CscIndicatorButton
: public TabSharingInfoBarDelegateButton { … };
namespace {
std::u16string GetMessageTextCastingNoSinkName(
bool shared_tab,
const std::u16string& shared_tab_name) { … }
std::u16string GetMessageTextCasting(bool shared_tab,
const std::u16string& shared_tab_name,
const std::u16string& sink_name) { … }
std::u16string GetMessageTextCapturing(bool shared_tab,
const std::u16string& shared_tab_name,
const std::u16string& app_name) { … }
bool IsCapturedTab(TabRole role) { … }
}
infobars::InfoBar* TabSharingInfoBarDelegate::Create(
infobars::ContentInfoBarManager* infobar_manager,
infobars::InfoBar* old_infobar,
const std::u16string& shared_tab_name,
const std::u16string& capturer_name,
content::WebContents* web_contents,
TabRole role,
ButtonState share_this_tab_instead_button_state,
std::optional<FocusTarget> focus_target,
bool captured_surface_control_active,
TabSharingUI* ui,
TabShareType capture_type,
bool favicons_used_for_switch_to_tab_button) { … }
TabSharingInfoBarDelegate::TabSharingInfoBarDelegate(
std::u16string shared_tab_name,
std::u16string capturer_name,
content::WebContents* web_contents,
TabRole role,
ButtonState share_this_tab_instead_button_state,
std::optional<FocusTarget> focus_target,
bool captured_surface_control_active,
TabSharingUI* ui,
TabShareType capture_type,
bool favicons_used_for_switch_to_tab_button)
: … { … }
TabSharingInfoBarDelegate::~TabSharingInfoBarDelegate() = default;
bool TabSharingInfoBarDelegate::EqualsDelegate(
InfoBarDelegate* delegate) const { … }
bool TabSharingInfoBarDelegate::ShouldExpire(
const NavigationDetails& details) const { … }
infobars::InfoBarDelegate::InfoBarIdentifier
TabSharingInfoBarDelegate::GetIdentifier() const { … }
std::u16string TabSharingInfoBarDelegate::GetMessageText() const { … }
std::u16string TabSharingInfoBarDelegate::GetButtonLabel(
TabSharingInfoBarButton button) const { … }
ui::ImageModel TabSharingInfoBarDelegate::GetButtonImage(
TabSharingInfoBarButton button) const { … }
bool TabSharingInfoBarDelegate::IsButtonEnabled(
TabSharingInfoBarButton button) const { … }
std::u16string TabSharingInfoBarDelegate::GetButtonTooltip(
TabSharingInfoBarButton button) const { … }
int TabSharingInfoBarDelegate::GetButtons() const { … }
void TabSharingInfoBarDelegate::Stop() { … }
void TabSharingInfoBarDelegate::ShareThisTabInstead() { … }
void TabSharingInfoBarDelegate::QuickNav() { … }
void TabSharingInfoBarDelegate::
OnCapturedSurfaceControlActivityIndicatorPressed() { … }
bool TabSharingInfoBarDelegate::IsCloseable() const { … }
const gfx::VectorIcon& TabSharingInfoBarDelegate::GetVectorIcon() const { … }
const TabSharingInfoBarDelegateButton& TabSharingInfoBarDelegate::GetButton(
TabSharingInfoBarButton button) const { … }
TabSharingInfoBarDelegateButton& TabSharingInfoBarDelegate::GetButton(
TabSharingInfoBarButton button) { … }