#include "chrome/browser/ui/webui/side_panel/companion/companion_page_handler.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/companion/core/companion_metrics_logger.h"
#include "chrome/browser/companion/core/companion_permission_utils.h"
#include "chrome/browser/companion/core/companion_url_builder.h"
#include "chrome/browser/companion/core/features.h"
#include "chrome/browser/companion/core/promo_handler.h"
#include "chrome/browser/companion/core/utils.h"
#include "chrome/browser/companion/text_finder/text_finder_manager.h"
#include "chrome/browser/companion/text_finder/text_highlighter_manager.h"
#include "chrome/browser/companion/visual_query/visual_query_suggestions_service_factory.h"
#include "chrome/browser/content_extraction/inner_html.h"
#include "chrome/browser/feature_engagement/tracker_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/search.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/views/side_panel/companion/companion_side_panel_controller_utils.h"
#include "chrome/browser/ui/views/side_panel/companion/companion_tab_helper.h"
#include "chrome/browser/ui/views/side_panel/companion/companion_utils.h"
#include "chrome/browser/ui/views/side_panel/side_panel_enums.h"
#include "chrome/browser/ui/webui/side_panel/companion/companion_side_panel_untrusted_ui.h"
#include "chrome/browser/ui/webui/side_panel/companion/signin_delegate_impl.h"
#include "chrome/browser/unified_consent/unified_consent_service_factory.h"
#include "chrome/common/companion/visual_query/features.h"
#include "chrome/common/webui_url_constants.h"
#include "components/feature_engagement/public/event_constants.h"
#include "components/feature_engagement/public/feature_constants.h"
#include "components/feature_engagement/public/tracker.h"
#include "components/lens/buildflags.h"
#include "components/lens/lens_metrics.h"
#include "components/lens/lens_url_utils.h"
#include "components/prefs/pref_service.h"
#include "components/unified_consent/pref_names.h"
#include "components/unified_consent/unified_consent_service.h"
#include "components/unified_consent/url_keyed_data_collection_consent_helper.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "net/base/url_util.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "url/gurl.h"
namespace companion {
CompanionPageHandler::CompanionPageHandler(
mojo::PendingReceiver<side_panel::mojom::CompanionPageHandler> receiver,
mojo::PendingRemote<side_panel::mojom::CompanionPage> page,
CompanionSidePanelUntrustedUI* companion_untrusted_ui)
: … { … }
CompanionPageHandler::~CompanionPageHandler() { … }
void CompanionPageHandler::OnPrimaryAccountChanged(
const signin::PrimaryAccountChangeEvent& event_details) { … }
void CompanionPageHandler::OnErrorStateOfRefreshTokenUpdatedForAccount(
const CoreAccountInfo& account_info,
const GoogleServiceAuthError& error,
signin_metrics::SourceForRefreshTokenOperation token_operation_source) { … }
void CompanionPageHandler::OnUrlKeyedDataCollectionConsentStateChanged(
unified_consent::UrlKeyedDataCollectionConsentHelper* consent_helper) { … }
void CompanionPageHandler::OnPageContentPrefChanged() { … }
void CompanionPageHandler::DidFinishNavigation(
content::NavigationHandle* navigation_handle) { … }
void CompanionPageHandler::DidFinishLoad(
content::RenderFrameHost* render_frame_host,
const GURL& validated_url) { … }
void CompanionPageHandler::SendVisualQueryResult(
const visual_query::VisualSuggestionsResults& results) { … }
void CompanionPageHandler::HandleVisualQueryResult(
const visual_query::VisualSuggestionsResults results,
const VisualSuggestionsMetrics metrics) { … }
void CompanionPageHandler::HandleInnerHtmlResponse(
const std::optional<std::string>& result) { … }
void CompanionPageHandler::SendPageContent() { … }
void CompanionPageHandler::OnLoadingState(
side_panel::mojom::LoadingState loading_state) { … }
void CompanionPageHandler::ShowUI() { … }
bool CompanionPageHandler::OnSearchTextQuery() { … }
void CompanionPageHandler::NotifyURLChanged(bool is_full_reload) { … }
void CompanionPageHandler::NotifyLinkOpened(
GURL opened_url,
side_panel::mojom::LinkOpenMetadataPtr metadata) { … }
void CompanionPageHandler::OnImageQuery(
side_panel::mojom::ImageQuery image_query) { … }
void CompanionPageHandler::OnPromoAction(
side_panel::mojom::PromoType promo_type,
side_panel::mojom::PromoAction promo_action) { … }
void CompanionPageHandler::OnRegionSearchClicked() { … }
void CompanionPageHandler::OnExpsOptInStatusAvailable(bool is_exps_opted_in) { … }
void CompanionPageHandler::OnOpenInNewTabButtonURLChanged(
const GURL& url_to_open) { … }
void CompanionPageHandler::RecordUiSurfaceShown(
side_panel::mojom::UiSurface ui_surface,
int32_t ui_surface_position,
int32_t child_element_available_count,
int32_t child_element_shown_count) { … }
void CompanionPageHandler::RecordUiSurfaceClicked(
side_panel::mojom::UiSurface ui_surface,
int32_t click_position) { … }
void CompanionPageHandler::OnCqCandidatesAvailable(
const std::vector<std::string>& text_directives) { … }
void CompanionPageHandler::OnPhFeedback(
side_panel::mojom::PhFeedback ph_feedback) { … }
void CompanionPageHandler::OnCqJumptagClicked(
const std::string& text_directive) { … }
void CompanionPageHandler::OnServerSideUrlFilterEvent() { … }
void CompanionPageHandler::OpenUrlInBrowser(
const std::optional<GURL>& url_to_open,
bool use_new_tab) { … }
void CompanionPageHandler::RefreshCompanionPage() { … }
void CompanionPageHandler::OnNavigationError() { … }
Browser* CompanionPageHandler::GetBrowser() { … }
Profile* CompanionPageHandler::GetProfile() { … }
void CompanionPageHandler::DidFinishFindingCqTexts(
const std::vector<std::pair<std::string, bool>>& text_found_vec) { … }
void CompanionPageHandler::RegisterModalDialogManager(Browser* browser) { … }
}