Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Unified Diff: chrome/browser/web_applications/web_app.cc

Issue 915973002: Add bookmark apps to taskbar automatically. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/web_applications/web_app.h ('k') | chrome/browser/web_applications/web_app_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/web_applications/web_app.cc
diff --git a/chrome/browser/web_applications/web_app.cc b/chrome/browser/web_applications/web_app.cc
index b80dfd8b30324d7228ee540859e97261dc0d1e40..abe41d0f2c8ac903463f038c6fbe78f8a64239ab 100644
--- a/chrome/browser/web_applications/web_app.cc
+++ b/chrome/browser/web_applications/web_app.cc
@@ -283,23 +283,32 @@ void GetShortcutInfoForApp(const extensions::Extension* extension,
extension, profile, base::Bind(&IgnoreFileHandlersInfo, callback));
}
-bool ShouldCreateShortcutFor(Profile* profile,
+bool ShouldCreateShortcutFor(web_app::ShortcutCreationReason reason,
+ Profile* profile,
const extensions::Extension* extension) {
- bool app_type_requires_shortcut = extension->is_platform_app();
+ // Shortcuts should never be created for component apps, or for apps that
+ // cannot be shown in the launcher.
+ if (extension->location() == extensions::Manifest::COMPONENT ||
+ !extensions::ui_util::CanDisplayInAppLauncher(extension, profile)) {
+ return false;
+ }
+
+ // Otherwise, always create shortcuts for v2 packaged apps.
+ if (extension->is_platform_app())
+ return true;
-// An additional check here for OS X. We need app shims to be
-// able to show them in the dock.
#if defined(OS_MACOSX)
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableHostedAppShimCreation)) {
- app_type_requires_shortcut =
- app_type_requires_shortcut || extension->is_hosted_app();
+ return extension->is_hosted_app();
}
-#endif
- return (app_type_requires_shortcut &&
- extension->location() != extensions::Manifest::COMPONENT &&
- extensions::ui_util::CanDisplayInAppLauncher(extension, profile));
+ return false;
+#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;
+#endif
}
base::FilePath GetWebAppDataDirectory(const base::FilePath& profile_path,
@@ -407,7 +416,7 @@ void CreateShortcuts(ShortcutCreationReason reason,
const extensions::Extension* app) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- if (!ShouldCreateShortcutFor(profile, app))
+ if (!ShouldCreateShortcutFor(reason, profile, app))
return;
GetInfoForApp(
« no previous file with comments | « chrome/browser/web_applications/web_app.h ('k') | chrome/browser/web_applications/web_app_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698