| 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" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "chrome/common/chrome_constants.h" | 12 #include "chrome/common/chrome_constants.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome_frame/chrome_frame_automation.h" | 14 #include "chrome_frame/chrome_frame_automation.h" |
| 15 #include "chrome_frame/crash_report.h" | 15 #include "chrome_frame/crash_report.h" |
| 16 | 16 |
| 17 namespace chrome_launcher { | 17 namespace chrome_launcher { |
| 18 | 18 |
| 19 const wchar_t kLauncherExeBaseName[] = L"chrome_launcher.exe"; | 19 const wchar_t kLauncherExeBaseName[] = L"chrome_launcher.exe"; |
| 20 | 20 |
| 21 // These are the switches we will allow (along with their values) in the | 21 // These are the switches we will allow (along with their values) in the |
| 22 // safe-for-Low-Integrity version of the Chrome command line. | 22 // safe-for-Low-Integrity version of the Chrome command line. |
| 23 const wchar_t* kAllowedSwitches[] = { | 23 const wchar_t* kAllowedSwitches[] = { |
| 24 switches::kAutomationClientChannelID, | 24 switches::kAutomationClientChannelID, |
| 25 switches::kDisableMetrics, | 25 switches::kDisableMetrics, |
| 26 switches::kNoFirstRun, | 26 switches::kNoFirstRun, |
| 27 switches::kUserDataDir, | 27 switches::kUserDataDir, |
| 28 switches::kLoadExtension, | 28 switches::kLoadExtension, |
| 29 switches::kEnableRendererAccessibility, |
| 29 }; | 30 }; |
| 30 | 31 |
| 31 CommandLine* CreateLaunchCommandLine() { | 32 CommandLine* CreateLaunchCommandLine() { |
| 32 // TODO(joi) As optimization, could launch Chrome directly when running at | 33 // TODO(joi) As optimization, could launch Chrome directly when running at |
| 33 // medium integrity. (Requires bringing in code to read SIDs, etc.) | 34 // medium integrity. (Requires bringing in code to read SIDs, etc.) |
| 34 | 35 |
| 35 // The launcher EXE will be in the same directory as the npchrome_tab DLL, | 36 // The launcher EXE will be in the same directory as the npchrome_tab DLL, |
| 36 // so create a full path to it based on this assumption. Since our unit | 37 // so create a full path to it based on this assumption. Since our unit |
| 37 // tests also use this function, and live in the directory above, we test | 38 // tests also use this function, and live in the directory above, we test |
| 38 // existence of the file and try the path that includes the /servers/ | 39 // existence of the file and try the path that includes the /servers/ |
| 39 // directory if needed. | 40 // directory if needed. |
| 40 FilePath module_path; | 41 FilePath module_path; |
| 41 if (PathService::Get(base::FILE_MODULE, &module_path)) { | 42 if (PathService::Get(base::FILE_MODULE, &module_path)) { |
| 42 FilePath current_dir = module_path.DirName(); | 43 FilePath current_dir = module_path.DirName(); |
| 43 FilePath same_dir_path = current_dir.Append(kLauncherExeBaseName); | 44 FilePath same_dir_path = current_dir.Append(kLauncherExeBaseName); |
| 44 if (file_util::PathExists(same_dir_path)) { | 45 if (file_util::PathExists(same_dir_path)) { |
| 45 return new CommandLine(same_dir_path.ToWStringHack()); | 46 return new CommandLine(same_dir_path.ToWStringHack()); |
| 46 } else { | 47 } else { |
| 47 FilePath servers_path = | 48 FilePath servers_path = |
| 48 current_dir.Append(L"servers").Append(kLauncherExeBaseName); | 49 current_dir.Append(L"servers").Append(kLauncherExeBaseName); |
| 49 DCHECK(file_util::PathExists(servers_path)) << | 50 DCHECK(file_util::PathExists(servers_path)) << |
| 50 "What module is this? It's not in 'servers' or main output dir."; | 51 "What module is this? It's not in 'servers' or main output dir."; |
| 51 return new CommandLine(servers_path.ToWStringHack()); | 52 return new CommandLine(servers_path.ToWStringHack()); |
| 52 } | 53 } |
| 53 } else { | 54 } else { |
| 54 NOTREACHED(); | 55 NOTREACHED(); |
| 55 return NULL; | 56 return NULL; |
| 56 } | 57 } |
| 57 } | 58 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 return ERROR_OPEN_FAILED; | 117 return ERROR_OPEN_FAILED; |
| 117 } | 118 } |
| 118 } | 119 } |
| 119 | 120 |
| 120 // Compile-time check to see that the type CfLaunchChromeProc is correct. | 121 // Compile-time check to see that the type CfLaunchChromeProc is correct. |
| 121 #ifndef NODEBUG | 122 #ifndef NODEBUG |
| 122 namespace { | 123 namespace { |
| 123 chrome_launcher::CfLaunchChromeProc cf_launch_chrome = CfLaunchChrome; | 124 chrome_launcher::CfLaunchChromeProc cf_launch_chrome = CfLaunchChrome; |
| 124 } // namespace | 125 } // namespace |
| 125 #endif // NODEBUG | 126 #endif // NODEBUG |
| OLD | NEW |