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 // On Mac, one can't make shortcuts with command-line arguments. Instead, we | 5 // On Mac, one can't make shortcuts with command-line arguments. Instead, we |
6 // produce small app bundles which locate the Chromium framework and load it, | 6 // produce small app bundles which locate the Chromium framework and load it, |
7 // passing the appropriate data. This is the entry point into the framework for | 7 // passing the appropriate data. This is the entry point into the framework for |
8 // those app bundles. | 8 // those app bundles. |
9 | 9 |
10 #include <string> // TODO(viettrungluu): only needed for temporary hack | |
11 | |
12 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
13 #include "base/command_line.h" | 11 #include "base/command_line.h" |
14 #include "base/file_path.h" | 12 #include "base/file_path.h" |
15 #include "base/logging.h" | 13 #include "base/logging.h" |
16 #include "base/mac/bundle_locations.h" | 14 #include "base/mac/bundle_locations.h" |
| 15 #include "chrome/browser/shell_integration.h" |
17 #include "chrome/common/chrome_constants.h" | 16 #include "chrome/common/chrome_constants.h" |
18 #include "chrome/common/chrome_paths_internal.h" | 17 #include "chrome/common/chrome_paths_internal.h" |
19 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/common/mac/app_mode_common.h" | 19 #include "chrome/common/mac/app_mode_common.h" |
21 | 20 |
22 extern "C" { | 21 extern "C" { |
23 | 22 |
24 // |ChromeAppModeStart()| is the point of entry into the framework from the app | 23 // |ChromeAppModeStart()| is the point of entry into the framework from the app |
25 // mode loader. | 24 // mode loader. |
26 __attribute__((visibility("default"))) | 25 __attribute__((visibility("default"))) |
(...skipping 15 matching lines...) Expand all Loading... |
42 } | 41 } |
43 | 42 |
44 RAW_CHECK(!info->chrome_versioned_path.empty()); | 43 RAW_CHECK(!info->chrome_versioned_path.empty()); |
45 FilePath* chrome_versioned_path = new FilePath(info->chrome_versioned_path); | 44 FilePath* chrome_versioned_path = new FilePath(info->chrome_versioned_path); |
46 RAW_CHECK(!chrome_versioned_path->empty()); | 45 RAW_CHECK(!chrome_versioned_path->empty()); |
47 chrome::SetOverrideVersionedDirectory(chrome_versioned_path); | 46 chrome::SetOverrideVersionedDirectory(chrome_versioned_path); |
48 base::mac::SetOverrideOuterBundlePath(info->chrome_outer_bundle_path); | 47 base::mac::SetOverrideOuterBundlePath(info->chrome_outer_bundle_path); |
49 base::mac::SetOverrideFrameworkBundlePath( | 48 base::mac::SetOverrideFrameworkBundlePath( |
50 chrome_versioned_path->Append(chrome::kFrameworkName)); | 49 chrome_versioned_path->Append(chrome::kFrameworkName)); |
51 | 50 |
| 51 // This struct is used to communicate information to the Chrome code, prefer |
| 52 // this to modifying the command line below. |
| 53 struct ShellIntegration::AppModeInfo app_mode_info; |
| 54 ShellIntegration::SetAppModeInfo(&app_mode_info); |
| 55 |
52 CommandLine command_line(CommandLine::NO_PROGRAM); | 56 CommandLine command_line(CommandLine::NO_PROGRAM); |
53 command_line.AppendSwitch(info->argv[0]); | 57 command_line.AppendSwitch(info->argv[0]); |
54 | 58 |
55 RAW_CHECK(info->app_mode_id.size()); | 59 RAW_CHECK(info->app_mode_id.size()); |
56 command_line.AppendSwitchASCII(switches::kAppId, info->app_mode_id); | 60 command_line.AppendSwitchASCII(switches::kAppId, info->app_mode_id); |
57 command_line.AppendSwitchPath(switches::kUserDataDir, info->user_data_dir); | 61 command_line.AppendSwitchPath(switches::kUserDataDir, info->user_data_dir); |
58 // TODO(sail): Use a different flag that doesn't imply Location::LOAD for the | 62 // TODO(sail): Use a different flag that doesn't imply Location::LOAD for the |
59 // extension. | 63 // extension. |
60 command_line.AppendSwitchPath(switches::kLoadExtension, info->extension_path); | 64 command_line.AppendSwitchPath(switches::kLoadExtension, info->extension_path); |
61 | 65 |
62 int argc = command_line.argv().size(); | 66 int argc = command_line.argv().size(); |
63 char* argv[argc]; | 67 char* argv[argc]; |
64 for (int i = 0; i < argc; ++i) | 68 for (int i = 0; i < argc; ++i) |
65 argv[i] = const_cast<char*>(command_line.argv()[i].c_str()); | 69 argv[i] = const_cast<char*>(command_line.argv()[i].c_str()); |
66 | 70 |
67 return ChromeMain(argc, argv); | 71 return ChromeMain(argc, argv); |
68 } | 72 } |
OLD | NEW |