Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: chrome/browser/web_applications/web_app_mac.mm

Issue 14579006: Start app shim when app launched. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/browser/ui/web_applications/web_app_ui.h"
19 #include "chrome/browser/web_applications/web_app.h" 22 #include "chrome/browser/web_applications/web_app.h"
20 #include "chrome/common/chrome_paths_internal.h" 23 #include "chrome/common/chrome_paths_internal.h"
21 #include "chrome/common/mac/app_mode_common.h" 24 #include "chrome/common/mac/app_mode_common.h"
22 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
23 #include "grit/chromium_strings.h" 26 #include "grit/chromium_strings.h"
24 #include "skia/ext/skia_utils_mac.h" 27 #include "skia/ext/skia_utils_mac.h"
25 #include "third_party/icon_family/IconFamily.h" 28 #include "third_party/icon_family/IconFamily.h"
26 #include "ui/base/l10n/l10n_util_mac.h" 29 #include "ui/base/l10n/l10n_util_mac.h"
27 #include "ui/gfx/image/image_family.h" 30 #include "ui/gfx/image/image_family.h"
28 31
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 return bundle_id; 284 return bundle_id;
282 } 285 }
283 286
284 void WebAppShortcutCreator::RevealGeneratedBundleInFinder( 287 void WebAppShortcutCreator::RevealGeneratedBundleInFinder(
285 const base::FilePath& generated_bundle) const { 288 const base::FilePath& generated_bundle) const {
286 [[NSWorkspace sharedWorkspace] 289 [[NSWorkspace sharedWorkspace]
287 selectFile:base::mac::FilePathToNSString(generated_bundle) 290 selectFile:base::mac::FilePathToNSString(generated_bundle)
288 inFileViewerRootedAtPath:nil]; 291 inFileViewerRootedAtPath:nil];
289 } 292 }
290 293
294 void LaunchShimOnFileThread(
295 const ShellIntegration::ShortcutInfo& shortcut_info) {
296 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
297 base::FilePath shim_path = web_app::GetAppInstallPath(shortcut_info);
298 if (shim_path.empty())
299 return;
300
301 CommandLine command_line(CommandLine::NO_PROGRAM);
302 command_line.AppendSwitch(app_mode::kNoLaunchApp);
303 base::mac::OpenApplicationWithPath(shim_path, command_line, NULL);
304 }
305
291 } // namespace 306 } // namespace
292 307
293 namespace web_app { 308 namespace web_app {
294 309
295 base::FilePath GetAppInstallPath( 310 base::FilePath GetAppInstallPath(
296 const ShellIntegration::ShortcutInfo& shortcut_info) { 311 const ShellIntegration::ShortcutInfo& shortcut_info) {
297 WebAppShortcutCreator shortcut_creator(base::FilePath(), 312 WebAppShortcutCreator shortcut_creator(base::FilePath(),
298 shortcut_info, 313 shortcut_info,
299 string16()); 314 string16());
300 return shortcut_creator.GetShortcutPath(); 315 return shortcut_creator.GetShortcutPath();
301 } 316 }
302 317
318 void MaybeLaunchShortcut(const ShellIntegration::ShortcutInfo& shortcut_info) {
319 content::BrowserThread::PostTask(
320 content::BrowserThread::FILE, FROM_HERE,
321 base::Bind(&LaunchShimOnFileThread, shortcut_info));
322 }
323
303 namespace internals { 324 namespace internals {
304 325
305 base::FilePath GetAppBundleByExtensionId(std::string extension_id) { 326 base::FilePath GetAppBundleByExtensionId(std::string extension_id) {
306 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 327 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
307 // This matches APP_MODE_APP_BUNDLE_ID in chrome/chrome.gyp. 328 // This matches APP_MODE_APP_BUNDLE_ID in chrome/chrome.gyp.
308 std::string bundle_id = 329 std::string bundle_id =
309 base::mac::BaseBundleID() + std::string(".app.") + extension_id; 330 base::mac::BaseBundleID() + std::string(".app.") + extension_id;
310 base::mac::ScopedCFTypeRef<CFStringRef> bundle_id_cf( 331 base::mac::ScopedCFTypeRef<CFStringRef> bundle_id_cf(
311 base::SysUTF8ToCFStringRef(bundle_id)); 332 base::SysUTF8ToCFStringRef(bundle_id));
312 CFURLRef url_ref = NULL; 333 CFURLRef url_ref = NULL;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 void UpdatePlatformShortcuts( 365 void UpdatePlatformShortcuts(
345 const base::FilePath& web_app_path, 366 const base::FilePath& web_app_path,
346 const ShellIntegration::ShortcutInfo& shortcut_info) { 367 const ShellIntegration::ShortcutInfo& shortcut_info) {
347 // TODO(benwells): Implement this when shortcuts / weblings are enabled on 368 // TODO(benwells): Implement this when shortcuts / weblings are enabled on
348 // mac. 369 // mac.
349 } 370 }
350 371
351 } // namespace internals 372 } // namespace internals
352 373
353 } // namespace web_app 374 } // namespace web_app
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698