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" | |
tapted
2013/05/21 08:33:25
drop?
jackhou1
2013/05/28 06:50:33
Done.
| |
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 264 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 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | |
312 base::FilePath shim_path = GetAppInstallPath( | |
313 web_app::ShortcutInfoForExtensionAndProfile(extension, profile)); | |
314 if (shim_path.empty()) | |
315 return; | |
316 | |
317 CommandLine command_line(CommandLine::NO_PROGRAM); | |
318 command_line.AppendSwitch(app_mode::kNoLaunchApp); | |
319 base::mac::OpenApplicationWithPath(shim_path, command_line, NULL); | |
320 } | |
321 | |
322 void MaybeLaunchShortcut(Profile* profile, | |
323 const extensions::Extension* extension) { | |
324 content::BrowserThread::PostTask( | |
325 content::BrowserThread::FILE, FROM_HERE, | |
326 base::Bind(&LaunchShimOnFileThread, profile, extension)); | |
327 } | |
328 | |
303 namespace internals { | 329 namespace internals { |
304 | 330 |
305 base::FilePath GetAppBundleByExtensionId(std::string extension_id) { | 331 base::FilePath GetAppBundleByExtensionId(std::string extension_id) { |
306 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 332 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
307 // This matches APP_MODE_APP_BUNDLE_ID in chrome/chrome.gyp. | 333 // This matches APP_MODE_APP_BUNDLE_ID in chrome/chrome.gyp. |
308 std::string bundle_id = | 334 std::string bundle_id = |
309 base::mac::BaseBundleID() + std::string(".app.") + extension_id; | 335 base::mac::BaseBundleID() + std::string(".app.") + extension_id; |
310 base::mac::ScopedCFTypeRef<CFStringRef> bundle_id_cf( | 336 base::mac::ScopedCFTypeRef<CFStringRef> bundle_id_cf( |
311 base::SysUTF8ToCFStringRef(bundle_id)); | 337 base::SysUTF8ToCFStringRef(bundle_id)); |
312 CFURLRef url_ref = NULL; | 338 CFURLRef url_ref = NULL; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
344 void UpdatePlatformShortcuts( | 370 void UpdatePlatformShortcuts( |
345 const base::FilePath& web_app_path, | 371 const base::FilePath& web_app_path, |
346 const ShellIntegration::ShortcutInfo& shortcut_info) { | 372 const ShellIntegration::ShortcutInfo& shortcut_info) { |
347 // TODO(benwells): Implement this when shortcuts / weblings are enabled on | 373 // TODO(benwells): Implement this when shortcuts / weblings are enabled on |
348 // mac. | 374 // mac. |
349 } | 375 } |
350 | 376 |
351 } // namespace internals | 377 } // namespace internals |
352 | 378 |
353 } // namespace web_app | 379 } // namespace web_app |
OLD | NEW |