#include "chrome/browser/ui/extensions/application_launch.h"
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "apps/launcher.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/apps/app_service/app_launch_params.h"
#include "chrome/browser/apps/app_service/launch_utils.h"
#include "chrome/browser/apps/platform_apps/platform_app_launch.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/file_handlers/file_handling_launch_utils.h"
#include "chrome/browser/extensions/launch_util.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/extensions/extension_enable_flow.h"
#include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h"
#include "chrome/browser/ui/extensions/web_file_handlers/multiclient_util.h"
#include "chrome/browser/ui/tabs/tab_strip_user_gesture_details.h"
#include "chrome/browser/ui/web_applications/web_app_launch_utils.h"
#include "chrome/browser/web_applications/web_app_helpers.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "chrome/common/url_constants.h"
#include "components/services/app_service/public/cpp/app_launch_util.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/features/feature.h"
#include "extensions/common/features/feature_provider.h"
#include "extensions/common/manifest_handlers/options_page_info.h"
#include "extensions/common/manifest_handlers/web_file_handlers_info.h"
#include "third_party/blink/public/common/features.h"
#include "ui/base/window_open_disposition.h"
#include "ui/display/scoped_display_for_new_windows.h"
#include "ui/gfx/geometry/rect.h"
WebContents;
Extension;
ExtensionPrefs;
ExtensionRegistry;
ExtensionService;
namespace {
class EnableViaDialogFlow : public ExtensionEnableFlowDelegate { … };
const Extension* GetExtension(Profile* profile,
const apps::AppLaunchParams& params) { … }
bool IsAllowedToOverrideURL(const extensions::Extension* extension,
const GURL& override_url) { … }
GURL UrlForExtension(const extensions::Extension* extension,
Profile* profile,
const apps::AppLaunchParams& params) { … }
ui::WindowShowState DetermineWindowShowState(Profile* profile,
apps::LaunchContainer container,
const Extension* extension) { … }
WebContents* OpenApplicationTab(Profile* profile,
const apps::AppLaunchParams& launch_params,
const GURL& url) { … }
WebContents* OpenEnabledApplicationHelper(Profile* profile,
const apps::AppLaunchParams& params,
const Extension& extension) { … }
WebContents* OpenEnabledApplication(Profile* profile,
const apps::AppLaunchParams& params) { … }
Browser* FindBrowserForApp(Profile* profile, const std::string& app_id) { … }
}
WebContents* OpenApplication(Profile* profile, apps::AppLaunchParams&& params) { … }
Browser* CreateApplicationWindow(Profile* profile,
const apps::AppLaunchParams& params,
const GURL& url) { … }
WebContents* NavigateApplicationWindow(Browser* browser,
const apps::AppLaunchParams& params,
const GURL& url,
WindowOpenDisposition disposition) { … }
WebContents* OpenApplicationWindow(Profile* profile,
const apps::AppLaunchParams& params,
const GURL& url) { … }
void OpenApplicationWithReenablePrompt(Profile* profile,
apps::AppLaunchParams&& params) { … }
WebContents* OpenAppShortcutWindow(Profile* profile, const GURL& url) { … }
bool CanLaunchViaEvent(const extensions::Extension* extension) { … }
void LaunchAppWithCallback(
Profile* profile,
const std::string& app_id,
const base::CommandLine& command_line,
const base::FilePath& current_directory,
base::OnceCallback<void(Browser* browser, apps::LaunchContainer container)>
callback) { … }
#if BUILDFLAG(IS_CHROMEOS_LACROS)
bool ShowBrowserForProfile(Profile* profile,
const apps::AppLaunchParams& params) {
Browser* browser = chrome::FindTabbedBrowser(
profile, false, params.display_id);
if (browser) {
browser->window()->Show();
browser->window()->Activate();
return true;
}
if (Browser::GetCreationStatusForProfile(profile) ==
Browser::CreationStatus::kOk) {
browser = Browser::Create(
Browser::CreateParams(Browser::TYPE_NORMAL, profile, true));
browser->window()->Show();
return true;
}
return false;
}
#endif