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

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: Sync and rebase 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/common/chrome_switches.h"
22 #include "chrome/browser/profiles/profile.h"
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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 namespace web_app { 298 namespace web_app {
294 299
295 base::FilePath GetAppInstallPath( 300 base::FilePath GetAppInstallPath(
296 const ShellIntegration::ShortcutInfo& shortcut_info) { 301 const ShellIntegration::ShortcutInfo& shortcut_info) {
297 WebAppShortcutCreator shortcut_creator(base::FilePath(), 302 WebAppShortcutCreator shortcut_creator(base::FilePath(),
298 shortcut_info, 303 shortcut_info,
299 string16()); 304 string16());
300 return shortcut_creator.GetShortcutPath(); 305 return shortcut_creator.GetShortcutPath();
301 } 306 }
302 307
308 void LaunchShimOnFileThread(Profile* profile,
tapted 2013/05/29 04:20:30 can you move this to an anonymous namespace?
jackhou1 2013/05/29 05:53:04 Done.
309 const extensions::Extension* extension) {
310 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
311 base::FilePath shim_path = GetAppInstallPath(
312 web_app::ShortcutInfoForExtensionAndProfile(extension, profile));
313 if (shim_path.empty())
314 return;
315
316 CommandLine command_line(CommandLine::NO_PROGRAM);
317 command_line.AppendSwitch(app_mode::kNoLaunchApp);
318 base::mac::OpenApplicationWithPath(shim_path, command_line, NULL);
319 }
320
321 void MaybeLaunchShortcut(Profile* profile,
322 const extensions::Extension* extension) {
323 content::BrowserThread::PostTask(
324 content::BrowserThread::FILE, FROM_HERE,
325 base::Bind(&LaunchShimOnFileThread, profile, extension));
tapted 2013/05/29 04:20:30 I've just realised.. posting Extension pointers to
jackhou1 2013/05/29 05:53:04 Done. Changed MaybeCreateShortcut since chrome/br
326 }
327
303 namespace internals { 328 namespace internals {
304 329
305 base::FilePath GetAppBundleByExtensionId(std::string extension_id) { 330 base::FilePath GetAppBundleByExtensionId(std::string extension_id) {
306 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 331 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
307 // This matches APP_MODE_APP_BUNDLE_ID in chrome/chrome.gyp. 332 // This matches APP_MODE_APP_BUNDLE_ID in chrome/chrome.gyp.
308 std::string bundle_id = 333 std::string bundle_id =
309 base::mac::BaseBundleID() + std::string(".app.") + extension_id; 334 base::mac::BaseBundleID() + std::string(".app.") + extension_id;
310 base::mac::ScopedCFTypeRef<CFStringRef> bundle_id_cf( 335 base::mac::ScopedCFTypeRef<CFStringRef> bundle_id_cf(
311 base::SysUTF8ToCFStringRef(bundle_id)); 336 base::SysUTF8ToCFStringRef(bundle_id));
312 CFURLRef url_ref = NULL; 337 CFURLRef url_ref = NULL;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 void UpdatePlatformShortcuts( 369 void UpdatePlatformShortcuts(
345 const base::FilePath& web_app_path, 370 const base::FilePath& web_app_path,
346 const ShellIntegration::ShortcutInfo& shortcut_info) { 371 const ShellIntegration::ShortcutInfo& shortcut_info) {
347 // TODO(benwells): Implement this when shortcuts / weblings are enabled on 372 // TODO(benwells): Implement this when shortcuts / weblings are enabled on
348 // mac. 373 // mac.
349 } 374 }
350 375
351 } // namespace internals 376 } // namespace internals
352 377
353 } // namespace web_app 378 } // namespace web_app
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698