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 std::wstring GetChromeExecutablePath() { | 93 FilePath GetChromeExecutablePath() { |
94 std::wstring cur_path; | 94 FilePath cur_path; |
95 PathService::Get(base::DIR_MODULE, &cur_path); | 95 PathService::Get(base::DIR_MODULE, &cur_path); |
96 file_util::AppendToPath(&cur_path, chrome::kBrowserProcessExecutableName); | 96 cur_path = cur_path.Append(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 file_util::UpOneDirectory(&cur_path); | 104 cur_path = cur_path.DirName().Append(chrome::kBrowserProcessExecutableName); |
105 file_util::AppendToPath(&cur_path, chrome::kBrowserProcessExecutableName); | |
106 } | 105 } |
107 | 106 |
108 return cur_path; | 107 return cur_path; |
109 } | 108 } |
110 | 109 |
111 } // namespace chrome_launcher | 110 } // namespace chrome_launcher |
112 | 111 |
113 // Entrypoint that implements the logic of chrome_launcher.exe. | 112 // Entrypoint that implements the logic of chrome_launcher.exe. |
114 int CALLBACK CfLaunchChrome() { | 113 int CALLBACK CfLaunchChrome() { |
115 if (chrome_launcher::SanitizeAndLaunchChrome(::GetCommandLine())) { | 114 if (chrome_launcher::SanitizeAndLaunchChrome(::GetCommandLine())) { |
116 return ERROR_SUCCESS; | 115 return ERROR_SUCCESS; |
117 } else { | 116 } else { |
118 return ERROR_OPEN_FAILED; | 117 return ERROR_OPEN_FAILED; |
119 } | 118 } |
120 } | 119 } |
121 | 120 |
122 // Compile-time check to see that the type CfLaunchChromeProc is correct. | 121 // Compile-time check to see that the type CfLaunchChromeProc is correct. |
123 #ifndef NODEBUG | 122 #ifndef NODEBUG |
124 namespace { | 123 namespace { |
125 chrome_launcher::CfLaunchChromeProc cf_launch_chrome = CfLaunchChrome; | 124 chrome_launcher::CfLaunchChromeProc cf_launch_chrome = CfLaunchChrome; |
126 } // namespace | 125 } // namespace |
127 #endif // NODEBUG | 126 #endif // NODEBUG |
OLD | NEW |