#include "chrome/browser/ui/intent_picker_tab_helper.h"
#include <optional>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/task/sequenced_task_runner.h"
#include "build/build_config.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/apps/intent_helper/intent_chip_display_prefs.h"
#include "chrome/browser/apps/link_capturing/apps_intent_picker_delegate.h"
#include "chrome/browser/apps/link_capturing/intent_picker_info.h"
#include "chrome/browser/apps/link_capturing/link_capturing_features.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/preloading/prefetch/no_state_prefetch/chrome_no_state_prefetch_contents_delegate.h"
#include "chrome/browser/profiles/profile.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/layout_constants.h"
#include "chrome/browser/ui/page_action/page_action_icon_type.h"
#include "chrome/browser/ui/web_applications/web_app_launch_utils.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/browser/web_applications/web_app_utils.h"
#include "components/services/app_service/public/cpp/app_types.h"
#include "components/services/app_service/public/cpp/icon_types.h"
#include "content/public/browser/navigation_handle.h"
#include "ui/base/models/image_model.h"
#include "ui/gfx/favicon_size.h"
#include "ui/gfx/image/image.h"
#include "url/origin.h"
#if BUILDFLAG(IS_CHROMEOS)
#include "chrome/browser/apps/link_capturing/chromeos_apps_intent_picker_delegate.h"
#include "chrome/browser/apps/link_capturing/metrics/intent_handling_metrics.h"
#else
#include "chrome/browser/apps/link_capturing/web_apps_intent_picker_delegate.h"
#endif
namespace {
web_app::WebAppRegistrar* MaybeGetWebAppRegistrar(
content::WebContents* web_contents) { … }
web_app::WebAppInstallManager* MaybeGetWebAppInstallManager(
content::WebContents* web_contents) { … }
bool IsNavigatingToNewSite(content::NavigationHandle* navigation_handle) { … }
bool IsValidWebContentsForIntentPicker(content::WebContents* web_contents) { … }
void ShowIntentPickerBubbleForApps(
content::WebContents* web_contents,
bool show_stay_in_chrome,
bool show_remember_selection,
IntentPickerResponse callback,
std::vector<apps::IntentPickerAppInfo> apps) { … }
bool IsShuttingDown(content::WebContents* web_contents) { … }
}
IntentPickerTabHelper::~IntentPickerTabHelper() = default;
void IntentPickerTabHelper::MaybeShowIntentPickerIcon() { … }
void IntentPickerTabHelper::ShowIntentPickerBubbleOrLaunchApp(const GURL& url) { … }
void IntentPickerTabHelper::ShowOrHideIcon(content::WebContents* web_contents,
bool should_show_icon) { … }
int IntentPickerTabHelper::GetIntentPickerBubbleIconSize() { … }
void IntentPickerTabHelper::MaybeShowIconForApps(
std::vector<apps::IntentPickerAppInfo> apps) { … }
IntentPickerTabHelper::IntentPickerTabHelper(content::WebContents* web_contents)
: … { … }
void IntentPickerTabHelper::OnAppIconLoaded(
std::vector<apps::IntentPickerAppInfo> apps,
IntentPickerIconLoaderCallback callback,
size_t index,
ui::ImageModel app_icon) { … }
void IntentPickerTabHelper::LoadAppIcon(
std::vector<apps::IntentPickerAppInfo> apps,
size_t index,
IntentPickerIconLoaderCallback callback) { … }
void IntentPickerTabHelper::UpdateExpandedState(bool should_show_icon) { … }
void IntentPickerTabHelper::OnAppIconLoadedForChip(const std::string& app_id,
ui::ImageModel app_icon) { … }
void IntentPickerTabHelper::ShowIconForLinkIntent(bool should_show_icon) { … }
void IntentPickerTabHelper::ShowOrHideIconInternal(bool should_show_icon) { … }
void IntentPickerTabHelper::ShowIntentPickerOrLaunchAppImpl(
const GURL& url,
std::vector<apps::IntentPickerAppInfo> apps) { … }
void IntentPickerTabHelper::OnIntentPickerClosedMaybeLaunch(
const GURL& url,
const std::string& launch_name,
apps::PickerEntryType entry_type,
apps::IntentPickerCloseReason close_reason,
bool should_persist) { … }
void IntentPickerTabHelper::SetIconUpdateCallbackForTesting(
base::OnceClosure callback,
bool include_latest_navigation) { … }
void IntentPickerTabHelper::DidStartNavigation(
content::NavigationHandle* navigation_handle) { … }
void IntentPickerTabHelper::DidFinishNavigation(
content::NavigationHandle* navigation_handle) { … }
void IntentPickerTabHelper::OnWebAppWillBeUninstalled(
const webapps::AppId& app_id) { … }
void IntentPickerTabHelper::OnWebAppInstallManagerDestroyed() { … }
WEB_CONTENTS_USER_DATA_KEY_IMPL(IntentPickerTabHelper);