#include "chrome/browser/ui/views/side_panel/search_companion/companion_side_panel_controller.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/companion/core/features.h"
#include "chrome/browser/companion/core/utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window/public/browser_window_features.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/side_panel/companion/companion_tab_helper.h"
#include "chrome/browser/ui/views/side_panel/companion_side_panel_web_view.h"
#include "chrome/browser/ui/views/side_panel/search_companion/search_companion_side_panel_coordinator.h"
#include "chrome/browser/ui/views/side_panel/side_panel_coordinator.h"
#include "chrome/browser/ui/views/side_panel/side_panel_entry.h"
#include "chrome/browser/ui/views/side_panel/side_panel_enums.h"
#include "chrome/browser/ui/views/side_panel/side_panel_registry.h"
#include "chrome/browser/ui/views/side_panel/side_panel_util.h"
#include "chrome/browser/ui/webui/side_panel/companion/companion_page_handler.h"
#include "chrome/browser/ui/webui/side_panel/companion/companion_side_panel_untrusted_ui.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/webui_url_constants.h"
#include "components/google/core/common/google_util.h"
#include "components/lens/buildflags.h"
#include "components/lens/lens_url_utils.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "third_party/blink/public/mojom/frame/user_activation_notification_type.mojom.h"
#include "ui/views/layout/flex_layout_types.h"
#include "ui/views/layout/flex_layout_view.h"
#include "ui/webui/webui_allowlist.h"
#if BUILDFLAG(ENABLE_LENS_DESKTOP_GOOGLE_BRANDED_FEATURES)
#include "chrome/browser/ui/views/side_panel/lens/lens_unified_side_panel_view.h"
#endif
namespace companion {
CompanionSidePanelController::CompanionSidePanelController(
content::WebContents* web_contents)
: … { … }
CompanionSidePanelController::~CompanionSidePanelController() { … }
void CompanionSidePanelController::CreateAndRegisterEntry() { … }
void CompanionSidePanelController::DeregisterEntry() { … }
void CompanionSidePanelController::ShowCompanionSidePanel(
SidePanelOpenTrigger side_panel_open_trigger) { … }
void CompanionSidePanelController::UpdateNewTabButton(GURL url_to_open) { … }
void CompanionSidePanelController::OnCompanionSidePanelClosed() { … }
bool CompanionSidePanelController::IsCompanionShowing() { … }
void CompanionSidePanelController::SetCompanionAsActiveEntry(
content::WebContents* contents) { … }
content::WebContents*
CompanionSidePanelController::GetCompanionWebContentsForTesting() { … }
void CompanionSidePanelController::OnEntryShown(SidePanelEntry* entry) { … }
void CompanionSidePanelController::OnEntryHidden(SidePanelEntry* entry) { … }
void CompanionSidePanelController::AddObserver() { … }
void CompanionSidePanelController::RemoveObserver() { … }
std::unique_ptr<views::View>
CompanionSidePanelController::CreateCompanionWebView() { … }
GURL CompanionSidePanelController::GetOpenInNewTabUrl() { … }
bool CompanionSidePanelController::IsSiteTrusted(const GURL& url) { … }
void CompanionSidePanelController::DidOpenRequestedURL(
content::WebContents* new_contents,
content::RenderFrameHost* source_render_frame_host,
const GURL& url,
const content::Referrer& referrer,
WindowOpenDisposition disposition,
ui::PageTransition transition,
bool started_from_context_menu,
bool renderer_initiated) { … }
void CompanionSidePanelController::FrameSizeChanged(
content::RenderFrameHost* render_frame_host,
const gfx::Size& frame_size) { … }
void CompanionSidePanelController::NotifyLinkClick(
GURL opened_url,
side_panel::mojom::LinkOpenMetadataPtr metadata,
content::WebContents* main_tab_contents) { … }
void CompanionSidePanelController::AddCompanionFinishedLoadingCallback(
CompanionTabHelper::CompanionLoadedCallback callback) { … }
void CompanionSidePanelController::DidFinishLoad(
content::RenderFrameHost* render_frame_host,
const GURL& validated_url) { … }
void CompanionSidePanelController::OpenContextualLensView(
const content::OpenURLParams& params) { … }
std::unique_ptr<views::View>
CompanionSidePanelController::CreateContextualLensView(
const content::OpenURLParams& params) { … }
GURL CompanionSidePanelController::GetLensOpenInNewTabButtonURL() { … }
void CompanionSidePanelController::UpdateNewTabButtonState() { … }
content::WebContents*
CompanionSidePanelController::GetLensViewWebContentsForTesting() { … }
bool CompanionSidePanelController::IsLensLaunchButtonEnabledForTesting() { … }
bool CompanionSidePanelController::OpenLensResultsInNewTabForTesting() { … }
}