| Index: chrome/browser/web_applications/web_app_mac.mm
|
| diff --git a/chrome/browser/web_applications/web_app_mac.mm b/chrome/browser/web_applications/web_app_mac.mm
|
| index b46170c3685b58b879ae910c3d5b45e1dfc422c8..02f3f0dc7c14ead4c29c6e2e6b3ff23c5122760f 100644
|
| --- a/chrome/browser/web_applications/web_app_mac.mm
|
| +++ b/chrome/browser/web_applications/web_app_mac.mm
|
| @@ -20,14 +20,17 @@
|
| #include "base/process/process_handle.h"
|
| #include "base/strings/string16.h"
|
| #include "base/strings/string_number_conversions.h"
|
| +#include "base/strings/string_split.h"
|
| #include "base/strings/string_util.h"
|
| #include "base/strings/sys_string_conversions.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| +#include "chrome/browser/browser_process.h"
|
| #import "chrome/browser/mac/dock.h"
|
| #include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| #include "chrome/browser/shell_integration.h"
|
| +#include "chrome/browser/ui/app_list/app_list_service.h"
|
| #include "chrome/common/chrome_constants.h"
|
| #include "chrome/common/chrome_paths.h"
|
| #include "chrome/common/chrome_switches.h"
|
| @@ -214,8 +217,8 @@ bool HasSameUserDataDir(const base::FilePath& bundle_path) {
|
| true /* case_sensitive */);
|
| }
|
|
|
| -void LaunchShimOnFileThread(
|
| - const web_app::ShortcutInfo& shortcut_info) {
|
| +void LaunchShimOnFileThread(const web_app::ShortcutInfo& shortcut_info,
|
| + bool launched_after_rebuild) {
|
| DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
|
| base::FilePath shim_path = web_app::GetAppInstallPath(shortcut_info);
|
|
|
| @@ -236,6 +239,8 @@ void LaunchShimOnFileThread(
|
| command_line.AppendSwitchASCII(
|
| app_mode::kLaunchedByChromeProcessId,
|
| base::IntToString(base::GetCurrentProcId()));
|
| + if (launched_after_rebuild)
|
| + command_line.AppendSwitch(app_mode::kLaunchedAfterRebuild);
|
| // Launch without activating (kLSLaunchDontSwitch).
|
| base::mac::OpenApplicationWithPath(
|
| shim_path, command_line, kLSLaunchDefaults | kLSLaunchDontSwitch, NULL);
|
| @@ -246,6 +251,53 @@ base::FilePath GetAppLoaderPath() {
|
| base::mac::NSToCFCast(@"app_mode_loader.app"));
|
| }
|
|
|
| +void UpdateAndLaunchShimOnFileThread(
|
| + const web_app::ShortcutInfo& shortcut_info,
|
| + const extensions::FileHandlersInfo& file_handlers_info) {
|
| + base::FilePath shortcut_data_dir = web_app::GetWebAppDataDirectory(
|
| + shortcut_info.profile_path, shortcut_info.extension_id, GURL());
|
| + web_app::internals::UpdatePlatformShortcuts(
|
| + shortcut_data_dir, base::string16(), shortcut_info, file_handlers_info);
|
| + LaunchShimOnFileThread(shortcut_info, true);
|
| +}
|
| +
|
| +void UpdateAndLaunchShim(
|
| + const web_app::ShortcutInfo& shortcut_info,
|
| + const extensions::FileHandlersInfo& file_handlers_info) {
|
| + content::BrowserThread::PostTask(
|
| + content::BrowserThread::FILE,
|
| + FROM_HERE,
|
| + base::Bind(
|
| + &UpdateAndLaunchShimOnFileThread, shortcut_info, file_handlers_info));
|
| +}
|
| +
|
| +void RebuildAppAndLaunch(const web_app::ShortcutInfo& shortcut_info) {
|
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| + if (shortcut_info.extension_id == app_mode::kAppListModeId) {
|
| + AppListService* app_list_service =
|
| + AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE);
|
| + app_list_service->CreateShortcut();
|
| + app_list_service->Show();
|
| + return;
|
| + }
|
| +
|
| + ProfileManager* profile_manager = g_browser_process->profile_manager();
|
| + Profile* profile =
|
| + profile_manager->GetProfileByPath(shortcut_info.profile_path);
|
| + if (!profile || !profile_manager->IsValidProfile(profile))
|
| + return;
|
| +
|
| + extensions::ExtensionRegistry* registry =
|
| + extensions::ExtensionRegistry::Get(profile);
|
| + const extensions::Extension* extension = registry->GetExtensionById(
|
| + shortcut_info.extension_id, extensions::ExtensionRegistry::ENABLED);
|
| + if (!extension || !extension->is_platform_app())
|
| + return;
|
| +
|
| + web_app::internals::GetInfoForApp(
|
| + extension, profile, base::Bind(&UpdateAndLaunchShim));
|
| +}
|
| +
|
| base::FilePath GetLocalizableAppShortcutsSubdirName() {
|
| static const char kChromiumAppDirName[] = "Chromium Apps.localized";
|
| static const char kChromeAppDirName[] = "Chrome Apps.localized";
|
| @@ -875,8 +927,22 @@ void MaybeLaunchShortcut(const ShortcutInfo& shortcut_info) {
|
| }
|
|
|
| content::BrowserThread::PostTask(
|
| - content::BrowserThread::FILE, FROM_HERE,
|
| - base::Bind(&LaunchShimOnFileThread, shortcut_info));
|
| + content::BrowserThread::FILE,
|
| + FROM_HERE,
|
| + base::Bind(&LaunchShimOnFileThread, shortcut_info, false));
|
| +}
|
| +
|
| +bool MaybeRebuildShortcut(const CommandLine& command_line) {
|
| + if (!command_line.HasSwitch(app_mode::kAppShimError))
|
| + return false;
|
| +
|
| + base::PostTaskAndReplyWithResult(
|
| + content::BrowserThread::GetBlockingPool(),
|
| + FROM_HERE,
|
| + base::Bind(&BuildShortcutInfoFromBundle,
|
| + command_line.GetSwitchValuePath(app_mode::kAppShimError)),
|
| + base::Bind(&RebuildAppAndLaunch));
|
| + return true;
|
| }
|
|
|
| // Called when the app's ShortcutInfo (with icon) is loaded when creating app
|
|
|