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 6da97950ee5a5e139698734de2e44b03c3bafc7a..51ab1b9e1cd6220b3dd9f70e4c3213c04e1f1423 100644 |
--- a/chrome/browser/web_applications/web_app_mac.mm |
+++ b/chrome/browser/web_applications/web_app_mac.mm |
@@ -6,16 +6,22 @@ |
#import <Cocoa/Cocoa.h> |
+#include "base/callback.h" |
+#include "base/command_line.h" |
#include "base/file_util.h" |
#include "base/files/scoped_temp_dir.h" |
#include "base/mac/bundle_locations.h" |
#include "base/mac/foundation_util.h" |
+#include "base/mac/launch_services_util.h" |
#include "base/mac/mac_logging.h" |
#include "base/mac/mac_util.h" |
#include "base/mac/scoped_cftyperef.h" |
#include "base/memory/scoped_nsobject.h" |
#include "base/strings/sys_string_conversions.h" |
#include "base/utf_string_conversions.h" |
+#include "chrome/common/chrome_switches.h" |
+#include "chrome/browser/profiles/profile.h" |
+#include "chrome/browser/ui/web_applications/web_app_ui.h" |
#include "chrome/browser/web_applications/web_app.h" |
#include "chrome/common/chrome_paths_internal.h" |
#include "chrome/common/mac/app_mode_common.h" |
@@ -101,6 +107,8 @@ base::FilePath GetWritableApplicationsDirectory() { |
namespace web_app { |
+const char kNoLaunchApp[] = "no-launch-app"; |
tapted
2013/05/16 04:51:00
we can't have this in 2 places
|
+ |
const char kChromeAppDirName[] = "Chrome Apps.localized"; |
tapted
2013/05/16 04:51:00
this either
|
WebAppShortcutCreator::WebAppShortcutCreator( |
@@ -115,6 +123,15 @@ WebAppShortcutCreator::WebAppShortcutCreator( |
WebAppShortcutCreator::~WebAppShortcutCreator() { |
} |
+base::FilePath WebAppShortcutCreator::GetShortcutPath() const { |
+ base::FilePath dst_path = GetDestinationPath(); |
+ if (dst_path.empty()) |
+ return dst_path; |
+ |
+ base::FilePath app_name = internals::GetSanitizedFileName(info_.title); |
+ return dst_path.Append(app_name.ReplaceExtension("app")); |
+} |
+ |
bool WebAppShortcutCreator::CreateShortcut() { |
base::FilePath app_name = internals::GetSanitizedFileName(info_.title); |
base::FilePath app_file_name = app_name.ReplaceExtension("app"); |
@@ -331,6 +348,37 @@ void UpdatePlatformShortcuts( |
// mac. |
} |
+void LaunchShimOnFileThread(Profile* profile, |
+ const extensions::Extension* extension, |
+ base::Callback<void(bool)> completed) { |
+ WebAppShortcutCreator shortcut_creator( |
+ CommandLine::ForCurrentProcess()-> |
+ GetSwitchValuePath(switches::kUserDataDir), |
+ web_app::ShortcutInfoForExtensionAndProfile(extension, profile), |
+ UTF8ToUTF16(base::mac::BaseBundleID())); |
+ |
+ base::FilePath shim_path = shortcut_creator.GetShortcutPath(); |
tapted
2013/05/16 04:51:00
can this logic be merged with the logic in FindAnd
|
+ LOG(INFO) << "LaunchShimOnFileThread " << shim_path.value(); |
+ if (shim_path.empty()) { |
+ content::BrowserThread::PostTask( |
+ content::BrowserThread::UI, FROM_HERE, base::Bind(completed, false)); |
+ return; |
+ } |
+ CommandLine command_line(CommandLine::NO_PROGRAM); |
+ command_line.AppendSwitch(kNoLaunchApp); |
+ base::mac::OpenApplicationWithPath(shim_path, command_line, NULL); |
+ content::BrowserThread::PostTask( |
+ content::BrowserThread::UI, FROM_HERE, base::Bind(completed, true)); |
+} |
+ |
+void LaunchShim(Profile* profile, |
+ const extensions::Extension* extension, |
+ base::Callback<void(bool)> completed) { |
+ content::BrowserThread::PostTask( |
+ content::BrowserThread::FILE, FROM_HERE, |
+ base::Bind(&LaunchShimOnFileThread, profile, extension, completed)); |
+} |
+ |
} // namespace internals |
} // namespace web_app |