Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_utils.h" | 5 #include "chrome_frame/chrome_launcher_utils.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" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/win/windows_version.h" | 13 #include "base/win/windows_version.h" |
| 14 #include "chrome/common/chrome_constants.h" | 14 #include "chrome/common/chrome_constants.h" |
| 15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome_frame/chrome_frame_automation.h" | 16 #include "chrome_frame/chrome_frame_automation.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 const char kUpdateCommandFlag[] = "--update-cmd"; | 20 const char kUpdateCommandFlag[] = "--update-cmd"; |
| 21 | 21 |
| 22 CommandLine* CreateChromeLauncherCommandLine() { | 22 CommandLine* CreateChromeLauncherCommandLine() { |
|
grt (UTC plus 2)
2011/09/23 13:40:05
boy do i wish this was:
void CreateChromeLauncherC
robertshield
2011/09/23 20:31:13
Yes, yes you are.
| |
| 23 // The launcher EXE will be in the same directory as the Chrome Frame DLL, | 23 // The launcher EXE will be in the same directory as the Chrome Frame DLL, |
| 24 // so create a full path to it based on this assumption. Since our unit | 24 // so create a full path to it based on this assumption. Since our unit |
| 25 // tests also use this function, and live in the directory above, we test | 25 // tests also use this function, and live in the directory above, we test |
| 26 // existence of the file and try the path that includes the /servers/ | 26 // existence of the file and try the path that includes the /servers/ |
|
grt (UTC plus 2)
2011/09/23 13:40:05
please update comment
robertshield
2011/09/23 20:31:13
Done.
| |
| 27 // directory if needed. | 27 // directory if needed. |
| 28 FilePath module_path; | 28 FilePath module_path; |
| 29 if (PathService::Get(base::FILE_MODULE, &module_path)) { | 29 if (PathService::Get(base::FILE_MODULE, &module_path)) { |
| 30 FilePath current_dir = module_path.DirName(); | 30 FilePath current_dir = module_path.DirName(); |
| 31 FilePath same_dir_path = current_dir.Append( | 31 FilePath chrome_launcher = current_dir.Append( |
| 32 chrome_launcher::kLauncherExeBaseName); | 32 chrome_launcher::kLauncherExeBaseName); |
| 33 if (file_util::PathExists(same_dir_path)) { | 33 if (file_util::PathExists(chrome_launcher)) { |
| 34 return new CommandLine(same_dir_path); | 34 return new CommandLine(chrome_launcher); |
| 35 } else { | |
| 36 FilePath servers_path = current_dir.Append(L"servers").Append( | |
| 37 chrome_launcher::kLauncherExeBaseName); | |
| 38 DCHECK(file_util::PathExists(servers_path)) << | |
| 39 "What module is this? It's not in 'servers' or main output dir."; | |
| 40 return new CommandLine(servers_path); | |
| 41 } | 35 } |
| 42 } else { | |
| 43 NOTREACHED(); | |
| 44 return NULL; | |
| 45 } | 36 } |
| 37 | |
| 38 NOTREACHED() << "Could not find " << chrome_launcher::kLauncherExeBaseName | |
| 39 << " in output dir."; | |
| 40 return NULL; | |
|
grt (UTC plus 2)
2011/09/23 13:40:05
this NULL will call callers to explode in release
robertshield
2011/09/23 20:31:13
Very well, I expect better cartwheels though.
| |
| 46 } | 41 } |
| 47 | 42 |
| 48 } // namespace | 43 } // namespace |
| 49 | 44 |
| 50 namespace chrome_launcher { | 45 namespace chrome_launcher { |
| 51 | 46 |
| 52 const wchar_t kLauncherExeBaseName[] = L"chrome_launcher.exe"; | 47 const wchar_t kLauncherExeBaseName[] = L"chrome_launcher.exe"; |
| 53 | 48 |
| 54 CommandLine* CreateUpdateCommandLine(const std::wstring& update_command) { | 49 CommandLine* CreateUpdateCommandLine(const std::wstring& update_command) { |
| 55 CommandLine* command_line = CreateChromeLauncherCommandLine(); | 50 CommandLine* command_line = CreateChromeLauncherCommandLine(); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 82 // instead. | 77 // instead. |
| 83 if (!file_util::PathExists(cur_path)) { | 78 if (!file_util::PathExists(cur_path)) { |
| 84 PathService::Get(base::DIR_MODULE, &cur_path); | 79 PathService::Get(base::DIR_MODULE, &cur_path); |
| 85 cur_path = cur_path.DirName().Append(chrome::kBrowserProcessExecutableName); | 80 cur_path = cur_path.DirName().Append(chrome::kBrowserProcessExecutableName); |
| 86 } | 81 } |
| 87 | 82 |
| 88 return cur_path; | 83 return cur_path; |
| 89 } | 84 } |
| 90 | 85 |
| 91 } // namespace chrome_launcher | 86 } // namespace chrome_launcher |
| OLD | NEW |