OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/browser/utility_process_host.h" | 5 #include "chrome/browser/utility_process_host.h" |
6 | 6 |
7 #include "app/app_switches.h" | 7 #include "app/app_switches.h" |
8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 Send(new UtilityMsg_ParseUpdateManifest(xml)); | 60 Send(new UtilityMsg_ParseUpdateManifest(xml)); |
61 return true; | 61 return true; |
62 } | 62 } |
63 | 63 |
64 FilePath UtilityProcessHost::GetUtilityProcessCmd() { | 64 FilePath UtilityProcessHost::GetUtilityProcessCmd() { |
65 return GetChildPath(); | 65 return GetChildPath(); |
66 } | 66 } |
67 | 67 |
68 bool UtilityProcessHost::StartProcess(const FilePath& exposed_dir) { | 68 bool UtilityProcessHost::StartProcess(const FilePath& exposed_dir) { |
69 #if defined(OS_POSIX) | 69 #if defined(OS_POSIX) |
70 // TODO(port): We should not reach here on linux (crbug.com/22703) or | 70 // TODO(port): We should not reach here on Linux (crbug.com/22703). |
71 // MacOS (crbug.com/8102) until problems related to autoupdate are fixed. | 71 // (crbug.com/23837) covers enabling this on Linux/OS X. |
72 NOTREACHED(); | 72 NOTREACHED(); |
73 return false; | 73 return false; |
74 #endif | 74 #endif |
75 | 75 |
76 // Name must be set or metrics_service will crash in any test which | 76 // Name must be set or metrics_service will crash in any test which |
77 // launches a UtilityProcessHost. | 77 // launches a UtilityProcessHost. |
78 set_name(L"utility process"); | 78 set_name(L"utility process"); |
79 | 79 |
80 if (!CreateChannel()) | 80 if (!CreateChannel()) |
81 return false; | 81 return false; |
(...skipping 19 matching lines...) Expand all Loading... |
101 #if defined(OS_WIN) | 101 #if defined(OS_WIN) |
102 if (!UseSandbox()) { | 102 if (!UseSandbox()) { |
103 // Don't use the sandbox during unit tests. | 103 // Don't use the sandbox during unit tests. |
104 base::LaunchApp(cmd_line, false, false, &process); | 104 base::LaunchApp(cmd_line, false, false, &process); |
105 } else if (exposed_dir.empty()) { | 105 } else if (exposed_dir.empty()) { |
106 process = sandbox::StartProcess(&cmd_line); | 106 process = sandbox::StartProcess(&cmd_line); |
107 } else { | 107 } else { |
108 process = sandbox::StartProcessWithAccess(&cmd_line, exposed_dir); | 108 process = sandbox::StartProcessWithAccess(&cmd_line, exposed_dir); |
109 } | 109 } |
110 #else | 110 #else |
111 // TODO(port): Sandbox this on Linux/Mac. Also, zygote this to work with | 111 // TODO(port): Sandbox this on Linux. Also, zygote this to work with |
112 // Linux updating. | 112 // Linux updating. |
113 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 113 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
114 bool has_cmd_prefix = browser_command_line.HasSwitch( | 114 bool has_cmd_prefix = browser_command_line.HasSwitch( |
115 switches::kUtilityCmdPrefix); | 115 switches::kUtilityCmdPrefix); |
116 if (has_cmd_prefix) { | 116 if (has_cmd_prefix) { |
117 // launch the utility child process with some prefix (usually "xterm -e gdb | 117 // launch the utility child process with some prefix (usually "xterm -e gdb |
118 // --args"). | 118 // --args"). |
119 cmd_line.PrependWrapper(browser_command_line.GetSwitchValue( | 119 cmd_line.PrependWrapper(browser_command_line.GetSwitchValue( |
120 switches::kUtilityCmdPrefix)); | 120 switches::kUtilityCmdPrefix)); |
121 } | 121 } |
122 | 122 |
| 123 cmd_line.AppendSwitchWithValue(switches::kUtilityProcessAllowedDir, |
| 124 exposed_dir.value().c_str()); |
| 125 |
123 // This code is duplicated with browser_render_process_host.cc and | 126 // This code is duplicated with browser_render_process_host.cc and |
124 // plugin_process_host.cc, but there's not a good place to de-duplicate it. | 127 // plugin_process_host.cc, but there's not a good place to de-duplicate it. |
125 // Maybe we can merge this into sandbox::StartProcess which will set up | 128 // Maybe we can merge this into sandbox::StartProcess which will set up |
126 // everything before calling LaunchApp? | 129 // everything before calling LaunchApp? |
127 base::file_handle_mapping_vector fds_to_map; | 130 base::file_handle_mapping_vector fds_to_map; |
128 const int ipcfd = channel().GetClientFileDescriptor(); | 131 const int ipcfd = channel().GetClientFileDescriptor(); |
129 if (ipcfd > -1) | 132 if (ipcfd > -1) |
130 fds_to_map.push_back(std::pair<int, int>( | 133 fds_to_map.push_back(std::pair<int, int>( |
131 ipcfd, kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor)); | 134 ipcfd, kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor)); |
132 base::LaunchApp(cmd_line.argv(), fds_to_map, false, &process); | 135 base::LaunchApp(cmd_line.argv(), fds_to_map, false, &process); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 IPC_MESSAGE_HANDLER(UtilityHostMsg_UnpackWebResource_Succeeded, | 167 IPC_MESSAGE_HANDLER(UtilityHostMsg_UnpackWebResource_Succeeded, |
165 Client::OnUnpackWebResourceSucceeded) | 168 Client::OnUnpackWebResourceSucceeded) |
166 IPC_MESSAGE_HANDLER(UtilityHostMsg_UnpackWebResource_Failed, | 169 IPC_MESSAGE_HANDLER(UtilityHostMsg_UnpackWebResource_Failed, |
167 Client::OnUnpackWebResourceFailed) | 170 Client::OnUnpackWebResourceFailed) |
168 IPC_MESSAGE_HANDLER(UtilityHostMsg_ParseUpdateManifest_Succeeded, | 171 IPC_MESSAGE_HANDLER(UtilityHostMsg_ParseUpdateManifest_Succeeded, |
169 Client::OnParseUpdateManifestSucceeded) | 172 Client::OnParseUpdateManifestSucceeded) |
170 IPC_MESSAGE_HANDLER(UtilityHostMsg_ParseUpdateManifest_Failed, | 173 IPC_MESSAGE_HANDLER(UtilityHostMsg_ParseUpdateManifest_Failed, |
171 Client::OnParseUpdateManifestFailed) | 174 Client::OnParseUpdateManifestFailed) |
172 IPC_END_MESSAGE_MAP_EX() | 175 IPC_END_MESSAGE_MAP_EX() |
173 } | 176 } |
OLD | NEW |