Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 // This file implements the common entry point shared by all Chromoting Host | 5 // This file implements the common entry point shared by all Chromoting Host |
| 6 // processes. | 6 // processes. |
| 7 | 7 |
| 8 #include "remoting/host/host_main.h" | 8 #include "remoting/host/host_main.h" |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 | 227 |
| 228 // Assume the host process by default. | 228 // Assume the host process by default. |
| 229 std::string process_type = kProcessTypeHost; | 229 std::string process_type = kProcessTypeHost; |
| 230 if (command_line->HasSwitch(kProcessTypeSwitchName)) { | 230 if (command_line->HasSwitch(kProcessTypeSwitchName)) { |
| 231 process_type = command_line->GetSwitchValueASCII(kProcessTypeSwitchName); | 231 process_type = command_line->GetSwitchValueASCII(kProcessTypeSwitchName); |
| 232 } else { | 232 } else { |
| 233 // Assume that it is the native messaging host starting if "--type" is | 233 // Assume that it is the native messaging host starting if "--type" is |
| 234 // missing and the first argument looks like an origin that represents | 234 // missing and the first argument looks like an origin that represents |
| 235 // an extension. | 235 // an extension. |
| 236 CommandLine::StringVector args = command_line->GetArgs(); | 236 CommandLine::StringVector args = command_line->GetArgs(); |
| 237 if (!args.empty()) { | |
|
Sergey Ulanov
2013/08/13 23:33:38
I think you fixed this in a separate CL.
rmsousa
2013/08/14 02:13:12
Yup, had to merge it here for testing while it was
| |
| 237 #if defined(OS_WIN) | 238 #if defined(OS_WIN) |
| 238 std::string origin = UTF16ToUTF8(args[0]); | 239 std::string origin = UTF16ToUTF8(args[0]); |
| 239 #else | 240 #else |
| 240 std::string origin = args[0]; | 241 std::string origin = args[0]; |
| 241 #endif | 242 #endif |
| 242 if (!args.empty() && | 243 if (StartsWithASCII(origin, kExtensionOriginPrefix, true)) { |
| 243 StartsWithASCII(origin, kExtensionOriginPrefix, true)) { | 244 process_type = kProcessTypeNativeMessagingHost; |
| 244 process_type = kProcessTypeNativeMessagingHost; | 245 } |
| 245 } | 246 } |
| 246 } | 247 } |
| 247 | 248 |
| 248 MainRoutineFn main_routine = SelectMainRoutine(process_type); | 249 MainRoutineFn main_routine = SelectMainRoutine(process_type); |
| 249 if (!main_routine) { | 250 if (!main_routine) { |
| 250 fprintf(stderr, "Unknown process type '%s' specified.", | 251 fprintf(stderr, "Unknown process type '%s' specified.", |
| 251 process_type.c_str()); | 252 process_type.c_str()); |
| 252 Usage(command_line->GetProgram()); | 253 Usage(command_line->GetProgram()); |
| 253 return kUsageExitCode; | 254 return kUsageExitCode; |
| 254 } | 255 } |
| 255 | 256 |
| 256 remoting::LoadResources(""); | 257 remoting::LoadResources(""); |
| 257 | 258 |
| 258 // Invoke the entry point. | 259 // Invoke the entry point. |
| 259 int exit_code = main_routine(); | 260 int exit_code = main_routine(); |
| 260 if (exit_code == kUsageExitCode) { | 261 if (exit_code == kUsageExitCode) { |
| 261 Usage(command_line->GetProgram()); | 262 Usage(command_line->GetProgram()); |
| 262 } | 263 } |
| 263 | 264 |
| 264 remoting::UnloadResources(); | 265 remoting::UnloadResources(); |
| 265 | 266 |
| 266 return exit_code; | 267 return exit_code; |
| 267 } | 268 } |
| 268 | 269 |
| 269 } // namespace remoting | 270 } // namespace remoting |
| OLD | NEW |