| 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_frame/chrome_launcher.h" | 5 #include "chrome_frame/chrome_launcher.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 std::wstring command_line_with_program(L"dummy.exe "); | 83 std::wstring command_line_with_program(L"dummy.exe "); |
| 84 command_line_with_program += command_line; | 84 command_line_with_program += command_line; |
| 85 CommandLine original(L""); | 85 CommandLine original(L""); |
| 86 original.ParseFromString(command_line_with_program); | 86 original.ParseFromString(command_line_with_program); |
| 87 CommandLine sanitized(GetChromeExecutablePath()); | 87 CommandLine sanitized(GetChromeExecutablePath()); |
| 88 SanitizeCommandLine(original, &sanitized); | 88 SanitizeCommandLine(original, &sanitized); |
| 89 | 89 |
| 90 return base::LaunchApp(sanitized.command_line_string(), false, false, NULL); | 90 return base::LaunchApp(sanitized.command_line_string(), false, false, NULL); |
| 91 } | 91 } |
| 92 | 92 |
| 93 FilePath GetChromeExecutablePath() { | 93 std::wstring GetChromeExecutablePath() { |
| 94 FilePath cur_path; | 94 std::wstring cur_path; |
| 95 PathService::Get(base::DIR_MODULE, &cur_path); | 95 PathService::Get(base::DIR_MODULE, &cur_path); |
| 96 cur_path = cur_path.Append(chrome::kBrowserProcessExecutableName); | 96 file_util::AppendToPath(&cur_path, chrome::kBrowserProcessExecutableName); |
| 97 | 97 |
| 98 // The installation model for Chrome places the DLLs in a versioned | 98 // The installation model for Chrome places the DLLs in a versioned |
| 99 // sub-folder one down from the Chrome executable. If we fail to find | 99 // sub-folder one down from the Chrome executable. If we fail to find |
| 100 // chrome.exe in the current path, try looking one up and launching that | 100 // chrome.exe in the current path, try looking one up and launching that |
| 101 // instead. | 101 // instead. |
| 102 if (!file_util::PathExists(cur_path)) { | 102 if (!file_util::PathExists(cur_path)) { |
| 103 PathService::Get(base::DIR_MODULE, &cur_path); | 103 PathService::Get(base::DIR_MODULE, &cur_path); |
| 104 cur_path = cur_path.DirName().Append(chrome::kBrowserProcessExecutableName); | 104 file_util::UpOneDirectory(&cur_path); |
| 105 file_util::AppendToPath(&cur_path, chrome::kBrowserProcessExecutableName); |
| 105 } | 106 } |
| 106 | 107 |
| 107 return cur_path; | 108 return cur_path; |
| 108 } | 109 } |
| 109 | 110 |
| 110 } // namespace chrome_launcher | 111 } // namespace chrome_launcher |
| 111 | 112 |
| 112 // Entrypoint that implements the logic of chrome_launcher.exe. | 113 // Entrypoint that implements the logic of chrome_launcher.exe. |
| 113 int CALLBACK CfLaunchChrome() { | 114 int CALLBACK CfLaunchChrome() { |
| 114 if (chrome_launcher::SanitizeAndLaunchChrome(::GetCommandLine())) { | 115 if (chrome_launcher::SanitizeAndLaunchChrome(::GetCommandLine())) { |
| 115 return ERROR_SUCCESS; | 116 return ERROR_SUCCESS; |
| 116 } else { | 117 } else { |
| 117 return ERROR_OPEN_FAILED; | 118 return ERROR_OPEN_FAILED; |
| 118 } | 119 } |
| 119 } | 120 } |
| 120 | 121 |
| 121 // Compile-time check to see that the type CfLaunchChromeProc is correct. | 122 // Compile-time check to see that the type CfLaunchChromeProc is correct. |
| 122 #ifndef NODEBUG | 123 #ifndef NODEBUG |
| 123 namespace { | 124 namespace { |
| 124 chrome_launcher::CfLaunchChromeProc cf_launch_chrome = CfLaunchChrome; | 125 chrome_launcher::CfLaunchChromeProc cf_launch_chrome = CfLaunchChrome; |
| 125 } // namespace | 126 } // namespace |
| 126 #endif // NODEBUG | 127 #endif // NODEBUG |
| OLD | NEW |