#include "chrome/browser/web_applications/extensions/web_app_extension_shortcut.h"
#include <utility>
#include <vector>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "base/metrics/histogram_functions.h"
#include "base/no_destructor.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/task_traits.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_ui_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/web_applications/os_integration/os_integration_manager.h"
#include "chrome/browser/web_applications/os_integration/os_integration_sub_manager.h"
#include "chrome/browser/web_applications/web_app_constants.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/browser/web_applications/web_app_registrar.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/webapps/common/web_app_id.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/image_loader.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest_handlers/icons_handler.h"
#include "ui/base/resource/resource_scale_factor.h"
#include "ui/gfx/image/image_skia.h"
#if BUILDFLAG(IS_WIN)
#include "chrome/browser/web_applications/os_integration/web_app_shortcut_win.h"
#endif
#if BUILDFLAG(IS_MAC)
#include "chrome/common/chrome_switches.h"
#endif
BrowserThread;
namespace web_app {
namespace {
void OnImageLoaded(std::unique_ptr<ShortcutInfo> shortcut_info,
ShortcutInfoCallback callback,
gfx::ImageFamily image_family) { … }
void UpdateAllShortcutsForShortcutInfo(
const std::u16string& old_app_title,
ResultCallback callback,
std::unique_ptr<ShortcutInfo> shortcut_info) { … }
AppCallbackMap;
AppCallbackMap& GetShortcutsDeletedCallbackMap() { … }
void ShortcutsDeleted(const webapps::AppId& app_id, bool ) { … }
}
void CreateShortcutsWithInfo(ShortcutCreationReason reason,
const ShortcutLocations& locations,
CreateShortcutsCallback callback,
std::unique_ptr<ShortcutInfo> shortcut_info) { … }
void GetShortcutInfoForApp(const extensions::Extension* extension,
Profile* profile,
ShortcutInfoCallback callback) { … }
std::unique_ptr<ShortcutInfo> ShortcutInfoForExtensionAndProfile(
const extensions::Extension* app,
Profile* profile) { … }
bool ShouldCreateShortcutFor(ShortcutCreationReason reason,
Profile* profile,
const extensions::Extension* extension) { … }
void CreateShortcuts(ShortcutCreationReason reason,
const ShortcutLocations& locations,
Profile* profile,
const extensions::Extension* app,
CreateShortcutsCallback callback) { … }
void DeleteAllShortcuts(Profile* profile, const extensions::Extension* app) { … }
void WaitForExtensionShortcutsDeleted(const webapps::AppId& app_id,
base::OnceClosure callback) { … }
void UpdateAllShortcuts(const std::u16string& old_app_title,
Profile* profile,
const extensions::Extension* app,
base::OnceClosure callback) { … }
#if !BUILDFLAG(IS_MAC)
void UpdateShortcutsForAllApps(Profile* profile, base::OnceClosure callback) { … }
#endif
#if BUILDFLAG(IS_WIN)
void UpdateRelaunchDetailsForApp(Profile* profile,
const extensions::Extension* extension,
HWND hwnd) {
GetShortcutInfoForApp(
extension, profile,
base::BindOnce(&internals::OnShortcutInfoLoadedForSetRelaunchDetails,
hwnd));
}
#endif
SynchronizeOsOptions ConvertShortcutLocationsToSynchronizeOptions(
const ShortcutLocations& locations,
ShortcutCreationReason reason) { … }
}