| 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 531a232c6d3df49fbd3f468256f9d150618f6161..8e6d4ba01829132c7e9e4e2346accc111ba32250 100644
|
| --- a/chrome/browser/web_applications/web_app_mac.mm
|
| +++ b/chrome/browser/web_applications/web_app_mac.mm
|
| @@ -21,18 +21,23 @@
|
| #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/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"
|
| #include "chrome/common/chrome_version_info.h"
|
| #import "chrome/common/mac/app_mode_common.h"
|
| #include "content/public/browser/browser_thread.h"
|
| +#include "extensions/browser/extension_registry.h"
|
| #include "extensions/common/extension.h"
|
| #include "grit/chrome_unscaled_resources.h"
|
| #include "grit/chromium_strings.h"
|
| @@ -236,6 +241,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);
|
| +}
|
| +
|
| +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";
|
| @@ -845,6 +897,19 @@ void MaybeLaunchShortcut(const web_app::ShortcutInfo& shortcut_info) {
|
| base::Bind(&LaunchShimOnFileThread, shortcut_info));
|
| }
|
|
|
| +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
|
| // shortcuts.
|
| void CreateAppShortcutInfoLoaded(
|
|
|