summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbenwells <benwells@chromium.org>2015-02-12 20:32:26 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-13 04:33:03 +0000
commita0e8eaaed65690d95e2b97aff2369c8a969bbacf (patch)
tree7457195ac005b417ee4924145d24ce7e02491e05
parent15439381be5c6b93dfc80ff0fec4a9d98823dba8 (diff)
downloadchromium_src-a0e8eaaed65690d95e2b97aff2369c8a969bbacf.zip
chromium_src-a0e8eaaed65690d95e2b97aff2369c8a969bbacf.tar.gz
chromium_src-a0e8eaaed65690d95e2b97aff2369c8a969bbacf.tar.bz2
Add bookmark apps to taskbar automatically.
The code to do this was present but broken. Now the code works on Windows. BUG=456650 Review URL: https://codereview.chromium.org/915973002 Cr-Commit-Position: refs/heads/master@{#316162}
-rw-r--r--chrome/browser/extensions/bookmark_app_helper.cc2
-rw-r--r--chrome/browser/web_applications/web_app.cc31
-rw-r--r--chrome/browser/web_applications/web_app.h3
-rw-r--r--chrome/browser/web_applications/web_app_mac.mm4
4 files changed, 26 insertions, 14 deletions
diff --git a/chrome/browser/extensions/bookmark_app_helper.cc b/chrome/browser/extensions/bookmark_app_helper.cc
index 5a7f39d..0954109 100644
--- a/chrome/browser/extensions/bookmark_app_helper.cc
+++ b/chrome/browser/extensions/bookmark_app_helper.cc
@@ -435,7 +435,7 @@ void BookmarkAppHelper::FinishInstallation(const Extension* extension) {
creation_locations.on_desktop = false;
#endif
creation_locations.applications_menu_location =
- web_app::APP_MENU_LOCATION_HIDDEN;
+ web_app::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS;
creation_locations.in_quick_launch_bar = true;
web_app::CreateShortcuts(web_app::SHORTCUT_CREATION_BY_USER,
creation_locations, current_profile, extension);
diff --git a/chrome/browser/web_applications/web_app.cc b/chrome/browser/web_applications/web_app.cc
index b80dfd8..abe41d0 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(
diff --git a/chrome/browser/web_applications/web_app.h b/chrome/browser/web_applications/web_app.h
index ff6b664..0b201ac 100644
--- a/chrome/browser/web_applications/web_app.h
+++ b/chrome/browser/web_applications/web_app.h
@@ -135,7 +135,8 @@ void GetShortcutInfoForApp(const extensions::Extension* extension,
const ShortcutInfoCallback& callback);
// Whether to create a shortcut for this type of extension.
-bool ShouldCreateShortcutFor(Profile* profile,
+bool ShouldCreateShortcutFor(web_app::ShortcutCreationReason reason,
+ Profile* profile,
const extensions::Extension* extension);
// Gets the user data directory for given web app. The path for the directory is
diff --git a/chrome/browser/web_applications/web_app_mac.mm b/chrome/browser/web_applications/web_app_mac.mm
index 1252d617..799407a 100644
--- a/chrome/browser/web_applications/web_app_mac.mm
+++ b/chrome/browser/web_applications/web_app_mac.mm
@@ -1103,8 +1103,10 @@ void UpdateShortcutsForAllApps(Profile* profile,
registry->GenerateInstalledExtensionsSet();
for (extensions::ExtensionSet::const_iterator it = everything->begin();
it != everything->end(); ++it) {
- if (web_app::ShouldCreateShortcutFor(profile, it->get()))
+ if (web_app::ShouldCreateShortcutFor(SHORTCUT_CREATION_AUTOMATED, profile,
+ it->get())) {
web_app::UpdateAllShortcuts(base::string16(), profile, it->get());
+ }
}
callback.Run();