Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/web_applications/web_app_mac.h" | 5 #import "chrome/browser/web_applications/web_app_mac.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/callback.h" | |
| 10 #include "base/command_line.h" | |
| 9 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 11 #include "base/mac/bundle_locations.h" | 13 #include "base/mac/bundle_locations.h" |
| 12 #include "base/mac/foundation_util.h" | 14 #include "base/mac/foundation_util.h" |
| 15 #include "base/mac/launch_services_util.h" | |
| 13 #include "base/mac/mac_logging.h" | 16 #include "base/mac/mac_logging.h" |
| 14 #include "base/mac/mac_util.h" | 17 #include "base/mac/mac_util.h" |
| 15 #include "base/mac/scoped_cftyperef.h" | 18 #include "base/mac/scoped_cftyperef.h" |
| 16 #include "base/memory/scoped_nsobject.h" | 19 #include "base/memory/scoped_nsobject.h" |
| 17 #include "base/strings/sys_string_conversions.h" | 20 #include "base/strings/sys_string_conversions.h" |
| 18 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
| 22 #include "chrome/common/chrome_switches.h" | |
| 23 #include "chrome/browser/profiles/profile.h" | |
| 24 #include "chrome/browser/ui/web_applications/web_app_ui.h" | |
| 19 #include "chrome/browser/web_applications/web_app.h" | 25 #include "chrome/browser/web_applications/web_app.h" |
| 20 #include "chrome/common/chrome_paths_internal.h" | 26 #include "chrome/common/chrome_paths_internal.h" |
| 21 #include "chrome/common/mac/app_mode_common.h" | 27 #include "chrome/common/mac/app_mode_common.h" |
| 22 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
| 23 #include "grit/chromium_strings.h" | 29 #include "grit/chromium_strings.h" |
| 24 #include "skia/ext/skia_utils_mac.h" | 30 #include "skia/ext/skia_utils_mac.h" |
| 25 #include "third_party/icon_family/IconFamily.h" | 31 #include "third_party/icon_family/IconFamily.h" |
| 26 #include "ui/base/l10n/l10n_util_mac.h" | 32 #include "ui/base/l10n/l10n_util_mac.h" |
| 27 #include "ui/gfx/image/image_family.h" | 33 #include "ui/gfx/image/image_family.h" |
| 28 | 34 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 if (base::mac::GetUserDirectory(NSApplicationDirectory, &path)) | 100 if (base::mac::GetUserDirectory(NSApplicationDirectory, &path)) |
| 95 return path; | 101 return path; |
| 96 return base::FilePath(); | 102 return base::FilePath(); |
| 97 } | 103 } |
| 98 | 104 |
| 99 } // namespace | 105 } // namespace |
| 100 | 106 |
| 101 | 107 |
| 102 namespace web_app { | 108 namespace web_app { |
| 103 | 109 |
| 104 const char kChromeAppDirName[] = "Chrome Apps.localized"; | 110 const char kChromeAppDirName[] = "Chrome Apps.localized"; |
|
jackhou1
2013/05/17 05:49:33
Should this be split into:
Chrome Apps
Chromium Ap
benwells
2013/05/17 05:59:41
Yes, and it should be coming from the sources file
| |
| 105 | 111 |
| 106 WebAppShortcutCreator::WebAppShortcutCreator( | 112 WebAppShortcutCreator::WebAppShortcutCreator( |
| 107 const base::FilePath& user_data_dir, | 113 const base::FilePath& user_data_dir, |
| 108 const ShellIntegration::ShortcutInfo& shortcut_info, | 114 const ShellIntegration::ShortcutInfo& shortcut_info, |
| 109 const string16& chrome_bundle_id) | 115 const string16& chrome_bundle_id) |
| 110 : user_data_dir_(user_data_dir), | 116 : user_data_dir_(user_data_dir), |
| 111 info_(shortcut_info), | 117 info_(shortcut_info), |
| 112 chrome_bundle_id_(chrome_bundle_id) { | 118 chrome_bundle_id_(chrome_bundle_id) { |
| 113 } | 119 } |
| 114 | 120 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 namespace web_app { | 299 namespace web_app { |
| 294 | 300 |
| 295 base::FilePath GetAppInstallPath( | 301 base::FilePath GetAppInstallPath( |
| 296 const ShellIntegration::ShortcutInfo& shortcut_info) { | 302 const ShellIntegration::ShortcutInfo& shortcut_info) { |
| 297 WebAppShortcutCreator shortcut_creator(base::FilePath(), | 303 WebAppShortcutCreator shortcut_creator(base::FilePath(), |
| 298 shortcut_info, | 304 shortcut_info, |
| 299 string16()); | 305 string16()); |
| 300 return shortcut_creator.GetShortcutPath(); | 306 return shortcut_creator.GetShortcutPath(); |
| 301 } | 307 } |
| 302 | 308 |
| 309 void LaunchShimOnFileThread(Profile* profile, | |
| 310 const extensions::Extension* extension, | |
| 311 base::Callback<void(bool)> completed) { | |
|
tapted
2013/05/17 06:44:00
Is there only one entrypoint now? It looks like |c
jackhou1
2013/05/21 03:13:22
Done.
| |
| 312 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | |
| 313 base::FilePath shim_path = GetAppInstallPath( | |
| 314 web_app::ShortcutInfoForExtensionAndProfile(extension, profile)); | |
| 315 if (shim_path.empty()) { | |
| 316 content::BrowserThread::PostTask( | |
| 317 content::BrowserThread::UI, FROM_HERE, base::Bind(completed, false)); | |
| 318 return; | |
| 319 } | |
| 320 CommandLine command_line(CommandLine::NO_PROGRAM); | |
| 321 command_line.AppendSwitch(app_mode::kNoLaunchApp); | |
| 322 base::mac::OpenApplicationWithPath(shim_path, command_line, NULL); | |
| 323 content::BrowserThread::PostTask( | |
| 324 content::BrowserThread::UI, FROM_HERE, base::Bind(completed, true)); | |
| 325 } | |
| 326 | |
| 327 void LaunchShim(Profile* profile, | |
|
tapted
2013/05/17 06:44:00
I think this should first check with the shim mana
jackhou1
2013/05/21 03:13:22
ATM the shim manager doesn't keep track of shims a
| |
| 328 const extensions::Extension* extension, | |
| 329 base::Callback<void(bool)> completed) { | |
| 330 content::BrowserThread::PostTask( | |
| 331 content::BrowserThread::FILE, FROM_HERE, | |
| 332 base::Bind(&LaunchShimOnFileThread, profile, extension, completed)); | |
| 333 } | |
| 334 | |
| 303 namespace internals { | 335 namespace internals { |
| 304 | 336 |
| 305 base::FilePath GetAppBundleByExtensionId(std::string extension_id) { | 337 base::FilePath GetAppBundleByExtensionId(std::string extension_id) { |
| 306 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 338 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
| 307 // This matches APP_MODE_APP_BUNDLE_ID in chrome/chrome.gyp. | 339 // This matches APP_MODE_APP_BUNDLE_ID in chrome/chrome.gyp. |
| 308 std::string bundle_id = | 340 std::string bundle_id = |
| 309 base::mac::BaseBundleID() + std::string(".app.") + extension_id; | 341 base::mac::BaseBundleID() + std::string(".app.") + extension_id; |
| 310 base::mac::ScopedCFTypeRef<CFStringRef> bundle_id_cf( | 342 base::mac::ScopedCFTypeRef<CFStringRef> bundle_id_cf( |
| 311 base::SysUTF8ToCFStringRef(bundle_id)); | 343 base::SysUTF8ToCFStringRef(bundle_id)); |
| 312 CFURLRef url_ref = NULL; | 344 CFURLRef url_ref = NULL; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 void UpdatePlatformShortcuts( | 376 void UpdatePlatformShortcuts( |
| 345 const base::FilePath& web_app_path, | 377 const base::FilePath& web_app_path, |
| 346 const ShellIntegration::ShortcutInfo& shortcut_info) { | 378 const ShellIntegration::ShortcutInfo& shortcut_info) { |
| 347 // TODO(benwells): Implement this when shortcuts / weblings are enabled on | 379 // TODO(benwells): Implement this when shortcuts / weblings are enabled on |
| 348 // mac. | 380 // mac. |
| 349 } | 381 } |
| 350 | 382 |
| 351 } // namespace internals | 383 } // namespace internals |
| 352 | 384 |
| 353 } // namespace web_app | 385 } // namespace web_app |
| OLD | NEW |