Index: chrome/browser/ui/app_list/app_list_view_delegate.cc |
diff --git a/chrome/browser/ui/app_list/app_list_view_delegate.cc b/chrome/browser/ui/app_list/app_list_view_delegate.cc |
index 4c24cb262784ad1b0aaa3321ac49834b2de908c2..7b59b98f77fd6631d34ba5e7c347ada5dfb5f160 100644 |
--- a/chrome/browser/ui/app_list/app_list_view_delegate.cc |
+++ b/chrome/browser/ui/app_list/app_list_view_delegate.cc |
@@ -4,6 +4,8 @@ |
#include "chrome/browser/ui/app_list/app_list_view_delegate.h" |
+#include "base/callback.h" |
+#include "base/files/file_path.h" |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/extensions/extension_service.h" |
#include "chrome/browser/feedback/feedback_util.h" |
@@ -16,8 +18,11 @@ |
#include "chrome/browser/ui/browser_finder.h" |
#include "chrome/browser/ui/chrome_pages.h" |
#include "chrome/browser/ui/host_desktop.h" |
+#include "chrome/browser/ui/web_applications/web_app_ui.h" |
+#include "chrome/browser/web_applications/web_app.h" |
#include "chrome/common/extensions/extension_constants.h" |
#include "chrome/common/url_constants.h" |
+#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/page_navigator.h" |
#include "content/public/browser/user_metrics.h" |
@@ -25,6 +30,27 @@ |
#include "chrome/browser/ui/ash/app_list/app_sync_ui_state_watcher.h" |
#endif |
+#if defined(OS_WIN) |
+#include "chrome/browser/web_applications/web_app_win.h" |
+#endif |
+ |
+namespace { |
+ |
+#if defined(OS_WIN) |
+void CreateShortcutInWebAppDir( |
+ const base::FilePath& app_data_dir, |
+ base::Callback<void(const base::FilePath&)> callback, |
+ const ShellIntegration::ShortcutInfo& info) { |
+ content::BrowserThread::PostTaskAndReplyWithResult( |
+ content::BrowserThread::FILE, |
+ FROM_HERE, |
+ base::Bind(web_app::CreateShortcutInWebAppDir, app_data_dir, info), |
+ callback); |
+} |
+#endif |
+ |
+} // namespace |
+ |
AppListViewDelegate::AppListViewDelegate(AppListControllerDelegate* controller, |
Profile* profile) |
: controller_(controller), |
@@ -68,6 +94,30 @@ void AppListViewDelegate::ActivateAppListItem( |
static_cast<ChromeAppListItem*>(item)->Activate(event_flags); |
} |
+void AppListViewDelegate::GetShortcutPathForApp( |
+ const std::string& app_id, |
+ const base::Callback<void(const base::FilePath&)>& callback) { |
+#if defined(OS_WIN) |
+ ExtensionService* service = profile_->GetExtensionService(); |
+ DCHECK(service); |
+ const extensions::Extension* extension = |
+ service->GetInstalledExtension(app_id); |
+ DCHECK(extension); |
+ |
+ base::FilePath app_data_dir( |
+ web_app::GetWebAppDataDirectory(profile_->GetPath(), |
+ extension->id(), |
+ GURL())); |
+ |
+ web_app::UpdateShortcutInfoAndIconForApp( |
+ *extension, |
+ profile_, |
+ base::Bind(CreateShortcutInWebAppDir, app_data_dir, callback)); |
+#else |
+ callback.Run(base::FilePath()); |
+#endif |
+} |
+ |
void AppListViewDelegate::StartSearch() { |
if (search_controller_.get()) |
search_controller_->Start(); |