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" |
(...skipping 11 matching lines...) Expand all Loading... |
22 const char kUpdateCommandFlag[] = "--update-cmd"; | 22 const char kUpdateCommandFlag[] = "--update-cmd"; |
23 | 23 |
24 // Searches for the path to chrome_launcher.exe. Will return false if this | 24 // Searches for the path to chrome_launcher.exe. Will return false if this |
25 // executable cannot be found, otherwise the command line will be placed in | 25 // executable cannot be found, otherwise the command line will be placed in |
26 // |command_line|. | 26 // |command_line|. |
27 bool CreateChromeLauncherCommandLine(scoped_ptr<CommandLine>* command_line) { | 27 bool CreateChromeLauncherCommandLine(scoped_ptr<CommandLine>* command_line) { |
28 DCHECK(command_line); | 28 DCHECK(command_line); |
29 bool success = false; | 29 bool success = false; |
30 // The launcher EXE will be in the same directory as the Chrome Frame DLL, | 30 // The launcher EXE will be in the same directory as the Chrome Frame DLL, |
31 // so create a full path to it based on this assumption. | 31 // so create a full path to it based on this assumption. |
32 FilePath module_path; | 32 base::FilePath module_path; |
33 if (PathService::Get(base::FILE_MODULE, &module_path)) { | 33 if (PathService::Get(base::FILE_MODULE, &module_path)) { |
34 FilePath current_dir = module_path.DirName(); | 34 base::FilePath current_dir = module_path.DirName(); |
35 FilePath chrome_launcher = current_dir.Append( | 35 base::FilePath chrome_launcher = current_dir.Append( |
36 chrome_launcher::kLauncherExeBaseName); | 36 chrome_launcher::kLauncherExeBaseName); |
37 if (file_util::PathExists(chrome_launcher)) { | 37 if (file_util::PathExists(chrome_launcher)) { |
38 command_line->reset(new CommandLine(chrome_launcher)); | 38 command_line->reset(new CommandLine(chrome_launcher)); |
39 success = true; | 39 success = true; |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 if (!success) { | 43 if (!success) { |
44 NOTREACHED() << "Could not find " << chrome_launcher::kLauncherExeBaseName | 44 NOTREACHED() << "Could not find " << chrome_launcher::kLauncherExeBaseName |
45 << " in output dir."; | 45 << " in output dir."; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // from being launched. | 82 // from being launched. |
83 const CommandLine& additional_params = | 83 const CommandLine& additional_params = |
84 PolicySettings::GetInstance()->AdditionalLaunchParameters(); | 84 PolicySettings::GetInstance()->AdditionalLaunchParameters(); |
85 command_line->get()->AppendArguments(additional_params, false); | 85 command_line->get()->AppendArguments(additional_params, false); |
86 return true; | 86 return true; |
87 } | 87 } |
88 | 88 |
89 return CreateChromeLauncherCommandLine(command_line); | 89 return CreateChromeLauncherCommandLine(command_line); |
90 } | 90 } |
91 | 91 |
92 FilePath GetChromeExecutablePath() { | 92 base::FilePath GetChromeExecutablePath() { |
93 FilePath cur_path; | 93 base::FilePath cur_path; |
94 PathService::Get(base::DIR_MODULE, &cur_path); | 94 PathService::Get(base::DIR_MODULE, &cur_path); |
95 cur_path = cur_path.Append(chrome::kBrowserProcessExecutableName); | 95 cur_path = cur_path.Append(chrome::kBrowserProcessExecutableName); |
96 | 96 |
97 // The installation model for Chrome places the DLLs in a versioned | 97 // The installation model for Chrome places the DLLs in a versioned |
98 // sub-folder one down from the Chrome executable. If we fail to find | 98 // sub-folder one down from the Chrome executable. If we fail to find |
99 // chrome.exe in the current path, try looking one up and launching that | 99 // chrome.exe in the current path, try looking one up and launching that |
100 // instead. | 100 // instead. |
101 if (!file_util::PathExists(cur_path)) { | 101 if (!file_util::PathExists(cur_path)) { |
102 PathService::Get(base::DIR_MODULE, &cur_path); | 102 PathService::Get(base::DIR_MODULE, &cur_path); |
103 cur_path = cur_path.DirName().Append(chrome::kBrowserProcessExecutableName); | 103 cur_path = cur_path.DirName().Append(chrome::kBrowserProcessExecutableName); |
104 } | 104 } |
105 | 105 |
106 return cur_path; | 106 return cur_path; |
107 } | 107 } |
108 | 108 |
109 } // namespace chrome_launcher | 109 } // namespace chrome_launcher |
OLD | NEW |