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/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/win/windows_version.h" | 14 #include "base/win/windows_version.h" |
15 #include "chrome/common/chrome_constants.h" | 15 #include "chrome/common/chrome_constants.h" |
16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
17 #include "chrome_frame/chrome_frame_automation.h" | 17 #include "chrome_frame/chrome_frame_automation.h" |
| 18 #include "chrome_frame/policy_settings.h" |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 const char kUpdateCommandFlag[] = "--update-cmd"; | 22 const char kUpdateCommandFlag[] = "--update-cmd"; |
22 | 23 |
23 // 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 |
24 // 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 |
25 // |command_line|. | 26 // |command_line|. |
26 bool CreateChromeLauncherCommandLine(scoped_ptr<CommandLine>* command_line) { | 27 bool CreateChromeLauncherCommandLine(scoped_ptr<CommandLine>* command_line) { |
27 DCHECK(command_line); | 28 DCHECK(command_line); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 67 |
67 return success; | 68 return success; |
68 } | 69 } |
69 | 70 |
70 bool CreateLaunchCommandLine(scoped_ptr<CommandLine>* command_line) { | 71 bool CreateLaunchCommandLine(scoped_ptr<CommandLine>* command_line) { |
71 DCHECK(command_line); | 72 DCHECK(command_line); |
72 | 73 |
73 // Shortcut for OS versions that don't need the integrity broker. | 74 // Shortcut for OS versions that don't need the integrity broker. |
74 if (base::win::GetVersion() < base::win::VERSION_VISTA) { | 75 if (base::win::GetVersion() < base::win::VERSION_VISTA) { |
75 command_line->reset(new CommandLine(GetChromeExecutablePath())); | 76 command_line->reset(new CommandLine(GetChromeExecutablePath())); |
| 77 |
| 78 // When we do not use the Chrome Launcher, we need to add the optional extra |
| 79 // parameters from the group policy here (this is normally done by the |
| 80 // chrome launcher). We don't do this when we use the launcher as the |
| 81 // optional arguments could trip off sanitization checks and prevent Chrome |
| 82 // from being launched. |
| 83 const CommandLine& additional_params = |
| 84 PolicySettings::GetInstance()->AdditionalLaunchParameters(); |
| 85 command_line->get()->AppendArguments(additional_params, false); |
76 return true; | 86 return true; |
77 } | 87 } |
78 | 88 |
79 return CreateChromeLauncherCommandLine(command_line); | 89 return CreateChromeLauncherCommandLine(command_line); |
80 } | 90 } |
81 | 91 |
82 FilePath GetChromeExecutablePath() { | 92 FilePath GetChromeExecutablePath() { |
83 FilePath cur_path; | 93 FilePath cur_path; |
84 PathService::Get(base::DIR_MODULE, &cur_path); | 94 PathService::Get(base::DIR_MODULE, &cur_path); |
85 cur_path = cur_path.Append(chrome::kBrowserProcessExecutableName); | 95 cur_path = cur_path.Append(chrome::kBrowserProcessExecutableName); |
86 | 96 |
87 // The installation model for Chrome places the DLLs in a versioned | 97 // The installation model for Chrome places the DLLs in a versioned |
88 // 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 |
89 // 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 |
90 // instead. | 100 // instead. |
91 if (!file_util::PathExists(cur_path)) { | 101 if (!file_util::PathExists(cur_path)) { |
92 PathService::Get(base::DIR_MODULE, &cur_path); | 102 PathService::Get(base::DIR_MODULE, &cur_path); |
93 cur_path = cur_path.DirName().Append(chrome::kBrowserProcessExecutableName); | 103 cur_path = cur_path.DirName().Append(chrome::kBrowserProcessExecutableName); |
94 } | 104 } |
95 | 105 |
96 return cur_path; | 106 return cur_path; |
97 } | 107 } |
98 | 108 |
99 } // namespace chrome_launcher | 109 } // namespace chrome_launcher |
OLD | NEW |