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/command_line.h" | |
| 9 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
| 11 #include "base/mac/bundle_locations.h" | 12 #include "base/mac/bundle_locations.h" |
| 12 #include "base/mac/foundation_util.h" | 13 #include "base/mac/foundation_util.h" |
| 14 #include "base/mac/launch_services_util.h" | |
| 13 #include "base/mac/mac_logging.h" | 15 #include "base/mac/mac_logging.h" |
| 14 #include "base/mac/mac_util.h" | 16 #include "base/mac/mac_util.h" |
| 15 #include "base/mac/scoped_cftyperef.h" | 17 #include "base/mac/scoped_cftyperef.h" |
| 16 #include "base/memory/scoped_nsobject.h" | 18 #include "base/memory/scoped_nsobject.h" |
| 17 #include "base/strings/sys_string_conversions.h" | 19 #include "base/strings/sys_string_conversions.h" |
| 18 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
| 21 #include "chrome/common/chrome_switches.h" | |
|
tapted
2013/05/29 06:16:01
nit: don't think this is used
jackhou1
2013/05/29 07:36:06
Done.
| |
| 22 #include "chrome/browser/profiles/profile.h" | |
|
tapted
2013/05/29 06:16:01
or this
jackhou1
2013/05/29 07:36:06
Done.
| |
| 23 #include "chrome/browser/ui/web_applications/web_app_ui.h" | |
| 19 #include "chrome/browser/web_applications/web_app.h" | 24 #include "chrome/browser/web_applications/web_app.h" |
| 20 #include "chrome/common/chrome_paths_internal.h" | 25 #include "chrome/common/chrome_paths_internal.h" |
| 21 #include "chrome/common/mac/app_mode_common.h" | 26 #include "chrome/common/mac/app_mode_common.h" |
| 22 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 23 #include "grit/chromium_strings.h" | 28 #include "grit/chromium_strings.h" |
| 24 #include "skia/ext/skia_utils_mac.h" | 29 #include "skia/ext/skia_utils_mac.h" |
| 25 #include "third_party/icon_family/IconFamily.h" | 30 #include "third_party/icon_family/IconFamily.h" |
| 26 #include "ui/base/l10n/l10n_util_mac.h" | 31 #include "ui/base/l10n/l10n_util_mac.h" |
| 27 #include "ui/gfx/image/image_family.h" | 32 #include "ui/gfx/image/image_family.h" |
| 28 | 33 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 return bundle_id; | 286 return bundle_id; |
| 282 } | 287 } |
| 283 | 288 |
| 284 void WebAppShortcutCreator::RevealGeneratedBundleInFinder( | 289 void WebAppShortcutCreator::RevealGeneratedBundleInFinder( |
| 285 const base::FilePath& generated_bundle) const { | 290 const base::FilePath& generated_bundle) const { |
| 286 [[NSWorkspace sharedWorkspace] | 291 [[NSWorkspace sharedWorkspace] |
| 287 selectFile:base::mac::FilePathToNSString(generated_bundle) | 292 selectFile:base::mac::FilePathToNSString(generated_bundle) |
| 288 inFileViewerRootedAtPath:nil]; | 293 inFileViewerRootedAtPath:nil]; |
| 289 } | 294 } |
| 290 | 295 |
| 296 void LaunchShimOnFileThread(ShellIntegration::ShortcutInfo shortcut_info) { | |
|
tapted
2013/05/29 06:16:01
can this be a const-reference? I think the closure
jackhou1
2013/05/29 07:36:06
Done.
| |
| 297 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | |
| 298 base::FilePath shim_path = web_app::GetAppInstallPath(shortcut_info); | |
| 299 if (shim_path.empty()) | |
| 300 return; | |
| 301 | |
| 302 CommandLine command_line(CommandLine::NO_PROGRAM); | |
| 303 command_line.AppendSwitch(app_mode::kNoLaunchApp); | |
| 304 base::mac::OpenApplicationWithPath(shim_path, command_line, NULL); | |
| 305 } | |
| 306 | |
| 291 } // namespace | 307 } // namespace |
| 292 | 308 |
| 293 namespace web_app { | 309 namespace web_app { |
| 294 | 310 |
| 295 base::FilePath GetAppInstallPath( | 311 base::FilePath GetAppInstallPath( |
| 296 const ShellIntegration::ShortcutInfo& shortcut_info) { | 312 const ShellIntegration::ShortcutInfo& shortcut_info) { |
| 297 WebAppShortcutCreator shortcut_creator(base::FilePath(), | 313 WebAppShortcutCreator shortcut_creator(base::FilePath(), |
| 298 shortcut_info, | 314 shortcut_info, |
| 299 string16()); | 315 string16()); |
| 300 return shortcut_creator.GetShortcutPath(); | 316 return shortcut_creator.GetShortcutPath(); |
| 301 } | 317 } |
| 302 | 318 |
| 319 void MaybeLaunchShortcut(const ShellIntegration::ShortcutInfo& shortcut_info) { | |
| 320 content::BrowserThread::PostTask( | |
| 321 content::BrowserThread::FILE, FROM_HERE, | |
| 322 base::Bind(&LaunchShimOnFileThread, shortcut_info)); | |
| 323 } | |
| 324 | |
| 303 namespace internals { | 325 namespace internals { |
| 304 | 326 |
| 305 base::FilePath GetAppBundleByExtensionId(std::string extension_id) { | 327 base::FilePath GetAppBundleByExtensionId(std::string extension_id) { |
| 306 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 328 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
| 307 // This matches APP_MODE_APP_BUNDLE_ID in chrome/chrome.gyp. | 329 // This matches APP_MODE_APP_BUNDLE_ID in chrome/chrome.gyp. |
| 308 std::string bundle_id = | 330 std::string bundle_id = |
| 309 base::mac::BaseBundleID() + std::string(".app.") + extension_id; | 331 base::mac::BaseBundleID() + std::string(".app.") + extension_id; |
| 310 base::mac::ScopedCFTypeRef<CFStringRef> bundle_id_cf( | 332 base::mac::ScopedCFTypeRef<CFStringRef> bundle_id_cf( |
| 311 base::SysUTF8ToCFStringRef(bundle_id)); | 333 base::SysUTF8ToCFStringRef(bundle_id)); |
| 312 CFURLRef url_ref = NULL; | 334 CFURLRef url_ref = NULL; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 void UpdatePlatformShortcuts( | 366 void UpdatePlatformShortcuts( |
| 345 const base::FilePath& web_app_path, | 367 const base::FilePath& web_app_path, |
| 346 const ShellIntegration::ShortcutInfo& shortcut_info) { | 368 const ShellIntegration::ShortcutInfo& shortcut_info) { |
| 347 // TODO(benwells): Implement this when shortcuts / weblings are enabled on | 369 // TODO(benwells): Implement this when shortcuts / weblings are enabled on |
| 348 // mac. | 370 // mac. |
| 349 } | 371 } |
| 350 | 372 |
| 351 } // namespace internals | 373 } // namespace internals |
| 352 | 374 |
| 353 } // namespace web_app | 375 } // namespace web_app |
| OLD | NEW |