Commit 225c5d4e authored by Alan Cutter's avatar Alan Cutter Committed by Commit Bot

Do not create app shims for sync'd PWAs on Mac

This CL ensures we do not spam the user's Application directory on Mac
when syncing down installed PWAs. This makes Mac behave the same as
Windows and Linux.

Bug: 929559
Change-Id: I31df57e7d8228b2a47cc362f258afeee2dc840ef
Reviewed-on: https://chromium-review.googlesource.com/c/1457698
Commit-Queue: Alan Cutter <alancutter@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Reviewed-by: default avatarBen Wells <benwells@chromium.org>
Cr-Commit-Position: refs/heads/master@{#629935}
parent f76169e4
...@@ -501,14 +501,6 @@ void BookmarkAppHelper::FinishInstallation(const Extension* extension) { ...@@ -501,14 +501,6 @@ void BookmarkAppHelper::FinishInstallation(const Extension* extension) {
const bool silent_install = const bool silent_install =
(chrome::FindBrowserWithWebContents(contents_) == nullptr); (chrome::FindBrowserWithWebContents(contents_) == nullptr);
// On Mac, shortcuts are automatically created for hosted apps when they are
// installed, so there is no need to create them again.
#if defined(OS_MACOSX)
if (!silent_install && !base::CommandLine::ForCurrentProcess()->HasSwitch(
::switches::kDisableHostedAppShimCreation)) {
web_app::RevealAppShimInFinderForApp(current_profile, extension);
}
#else
if (create_shortcuts_) { if (create_shortcuts_) {
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
web_app::ShortcutLocations creation_locations; web_app::ShortcutLocations creation_locations;
...@@ -532,13 +524,22 @@ void BookmarkAppHelper::FinishInstallation(const Extension* extension) { ...@@ -532,13 +524,22 @@ void BookmarkAppHelper::FinishInstallation(const Extension* extension) {
#endif // !defined(OS_CHROMEOS) #endif // !defined(OS_CHROMEOS)
} }
// Reparent the tab into an app window immediately when opening as a window. if (!silent_install) {
if (!silent_install && #if defined(OS_MACOSX)
base::FeatureList::IsEnabled(::features::kDesktopPWAWindowing) && // TODO(https://crbug.com/915571): Reparent the tab on Mac just like the
launch_type == LAUNCH_TYPE_WINDOW && !profile_->IsOffTheRecord()) { // other platforms.
ReparentWebContentsIntoAppBrowser(contents_, extension); if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
} ::switches::kDisableHostedAppShimCreation)) {
web_app::RevealAppShimInFinderForApp(current_profile, extension);
}
#else
// Reparent the tab into an app window immediately when opening as a window.
if (base::FeatureList::IsEnabled(::features::kDesktopPWAWindowing) &&
launch_type == LAUNCH_TYPE_WINDOW && !profile_->IsOffTheRecord()) {
ReparentWebContentsIntoAppBrowser(contents_, extension);
}
#endif // !defined(OS_MACOSX) #endif // !defined(OS_MACOSX)
}
callback_.Run(extension, web_app_info_); callback_.Run(extension, web_app_info_);
} }
......
...@@ -228,33 +228,16 @@ bool ShouldCreateShortcutFor(ShortcutCreationReason reason, ...@@ -228,33 +228,16 @@ bool ShouldCreateShortcutFor(ShortcutCreationReason reason,
return true; return true;
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
// A bookmark app installs itself as an extension, then automatically triggers if (extension->is_hosted_app() &&
// a shortcut request with SHORTCUT_CREATION_AUTOMATED. Allow this flow, but base::CommandLine::ForCurrentProcess()->HasSwitch(
// do not automatically create shortcuts for default-installed extensions, switches::kDisableHostedAppShimCreation)) {
// until it is explicitly requested by the user.
if (extension->was_installed_by_default() &&
reason == SHORTCUT_CREATION_AUTOMATED)
return false; return false;
if (extension->from_bookmark())
return true;
// Otherwise, don't create shortcuts for automated codepaths.
if (reason == SHORTCUT_CREATION_AUTOMATED)
return false;
if (extension->is_hosted_app()) {
return !base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableHostedAppShimCreation);
} }
#endif
// Only reached for "legacy" packaged apps. Default to false on Mac. // Allow shortcut creation if it was explicitly requested by the user (i.e. is
return false; // not automatic).
#else
// For other platforms, allow shortcut creation if it was explicitly
// requested by the user (i.e. is not automatic).
return reason == SHORTCUT_CREATION_BY_USER; return reason == SHORTCUT_CREATION_BY_USER;
#endif
} }
base::FilePath GetWebAppDataDirectory(const base::FilePath& profile_path, base::FilePath GetWebAppDataDirectory(const base::FilePath& profile_path,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment