| 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 <Carbon/Carbon.h> | 7 #import <Carbon/Carbon.h> |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 11 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 12 #include "base/mac/bundle_locations.h" | 13 #include "base/mac/bundle_locations.h" |
| 13 #include "base/mac/foundation_util.h" | 14 #include "base/mac/foundation_util.h" |
| 15 #include "base/mac/launch_services_util.h" |
| 14 #include "base/mac/mac_logging.h" | 16 #include "base/mac/mac_logging.h" |
| 15 #include "base/mac/mac_util.h" | 17 #include "base/mac/mac_util.h" |
| 16 #include "base/mac/scoped_cftyperef.h" | 18 #include "base/mac/scoped_cftyperef.h" |
| 17 #include "base/memory/scoped_nsobject.h" | 19 #include "base/memory/scoped_nsobject.h" |
| 18 #include "base/strings/sys_string_conversions.h" | 20 #include "base/strings/sys_string_conversions.h" |
| 19 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
| 22 #include "chrome/browser/ui/web_applications/web_app_ui.h" |
| 20 #include "chrome/browser/web_applications/web_app.h" | 23 #include "chrome/browser/web_applications/web_app.h" |
| 21 #include "chrome/common/chrome_paths_internal.h" | 24 #include "chrome/common/chrome_paths_internal.h" |
| 22 #include "chrome/common/mac/app_mode_common.h" | 25 #include "chrome/common/mac/app_mode_common.h" |
| 23 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 24 #include "grit/chromium_strings.h" | 27 #include "grit/chromium_strings.h" |
| 25 #include "skia/ext/skia_utils_mac.h" | 28 #include "skia/ext/skia_utils_mac.h" |
| 26 #include "third_party/skia/include/core/SkBitmap.h" | 29 #include "third_party/skia/include/core/SkBitmap.h" |
| 27 #include "third_party/skia/include/core/SkColor.h" | 30 #include "third_party/skia/include/core/SkColor.h" |
| 28 #include "ui/base/l10n/l10n_util_mac.h" | 31 #include "ui/base/l10n/l10n_util_mac.h" |
| 29 #include "ui/gfx/image/image_family.h" | 32 #include "ui/gfx/image/image_family.h" |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 return bundle_id; | 312 return bundle_id; |
| 310 } | 313 } |
| 311 | 314 |
| 312 void WebAppShortcutCreator::RevealGeneratedBundleInFinder( | 315 void WebAppShortcutCreator::RevealGeneratedBundleInFinder( |
| 313 const base::FilePath& generated_bundle) const { | 316 const base::FilePath& generated_bundle) const { |
| 314 [[NSWorkspace sharedWorkspace] | 317 [[NSWorkspace sharedWorkspace] |
| 315 selectFile:base::mac::FilePathToNSString(generated_bundle) | 318 selectFile:base::mac::FilePathToNSString(generated_bundle) |
| 316 inFileViewerRootedAtPath:nil]; | 319 inFileViewerRootedAtPath:nil]; |
| 317 } | 320 } |
| 318 | 321 |
| 322 void LaunchShimOnFileThread( |
| 323 const ShellIntegration::ShortcutInfo& shortcut_info) { |
| 324 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
| 325 base::FilePath shim_path = web_app::GetAppInstallPath(shortcut_info); |
| 326 if (shim_path.empty()) |
| 327 return; |
| 328 |
| 329 CommandLine command_line(CommandLine::NO_PROGRAM); |
| 330 command_line.AppendSwitch(app_mode::kNoLaunchApp); |
| 331 base::mac::OpenApplicationWithPath(shim_path, command_line, NULL); |
| 332 } |
| 333 |
| 319 } // namespace | 334 } // namespace |
| 320 | 335 |
| 321 namespace web_app { | 336 namespace web_app { |
| 322 | 337 |
| 323 base::FilePath GetAppInstallPath( | 338 base::FilePath GetAppInstallPath( |
| 324 const ShellIntegration::ShortcutInfo& shortcut_info) { | 339 const ShellIntegration::ShortcutInfo& shortcut_info) { |
| 325 WebAppShortcutCreator shortcut_creator(base::FilePath(), | 340 WebAppShortcutCreator shortcut_creator(base::FilePath(), |
| 326 shortcut_info, | 341 shortcut_info, |
| 327 string16()); | 342 string16()); |
| 328 return shortcut_creator.GetShortcutPath(); | 343 return shortcut_creator.GetShortcutPath(); |
| 329 } | 344 } |
| 330 | 345 |
| 346 void MaybeLaunchShortcut(const ShellIntegration::ShortcutInfo& shortcut_info) { |
| 347 content::BrowserThread::PostTask( |
| 348 content::BrowserThread::FILE, FROM_HERE, |
| 349 base::Bind(&LaunchShimOnFileThread, shortcut_info)); |
| 350 } |
| 351 |
| 331 namespace internals { | 352 namespace internals { |
| 332 | 353 |
| 333 base::FilePath GetAppBundleByExtensionId(std::string extension_id) { | 354 base::FilePath GetAppBundleByExtensionId(std::string extension_id) { |
| 334 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 355 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
| 335 // This matches APP_MODE_APP_BUNDLE_ID in chrome/chrome.gyp. | 356 // This matches APP_MODE_APP_BUNDLE_ID in chrome/chrome.gyp. |
| 336 std::string bundle_id = | 357 std::string bundle_id = |
| 337 base::mac::BaseBundleID() + std::string(".app.") + extension_id; | 358 base::mac::BaseBundleID() + std::string(".app.") + extension_id; |
| 338 base::mac::ScopedCFTypeRef<CFStringRef> bundle_id_cf( | 359 base::mac::ScopedCFTypeRef<CFStringRef> bundle_id_cf( |
| 339 base::SysUTF8ToCFStringRef(bundle_id)); | 360 base::SysUTF8ToCFStringRef(bundle_id)); |
| 340 CFURLRef url_ref = NULL; | 361 CFURLRef url_ref = NULL; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 const base::FilePath& web_app_path, | 394 const base::FilePath& web_app_path, |
| 374 const string16& old_app_title, | 395 const string16& old_app_title, |
| 375 const ShellIntegration::ShortcutInfo& shortcut_info) { | 396 const ShellIntegration::ShortcutInfo& shortcut_info) { |
| 376 // TODO(benwells): Implement this when shortcuts / weblings are enabled on | 397 // TODO(benwells): Implement this when shortcuts / weblings are enabled on |
| 377 // mac. | 398 // mac. |
| 378 } | 399 } |
| 379 | 400 |
| 380 } // namespace internals | 401 } // namespace internals |
| 381 | 402 |
| 382 } // namespace web_app | 403 } // namespace web_app |
| OLD | NEW |