Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Side by Side Diff: chrome_frame/chrome_launcher_utils.cc

Issue 8013001: Remove the \servers build output directory and place Chrome Frame parts into the root output fold... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/path_service.h" 12 #include "base/path_service.h"
12 #include "base/string_util.h" 13 #include "base/string_util.h"
13 #include "base/win/windows_version.h" 14 #include "base/win/windows_version.h"
14 #include "chrome/common/chrome_constants.h" 15 #include "chrome/common/chrome_constants.h"
15 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
16 #include "chrome_frame/chrome_frame_automation.h" 17 #include "chrome_frame/chrome_frame_automation.h"
17 18
18 namespace { 19 namespace {
19 20
20 const char kUpdateCommandFlag[] = "--update-cmd"; 21 const char kUpdateCommandFlag[] = "--update-cmd";
21 22
22 CommandLine* CreateChromeLauncherCommandLine() { 23 // 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 // |command_line|.
26 bool CreateChromeLauncherCommandLine(scoped_ptr<CommandLine>* command_line) {
27 DCHECK(command_line);
28 bool success = false;
23 // The launcher EXE will be in the same directory as the Chrome Frame DLL, 29 // 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 30 // so create a full path to it based on this assumption.
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/
27 // directory if needed.
28 FilePath module_path; 31 FilePath module_path;
29 if (PathService::Get(base::FILE_MODULE, &module_path)) { 32 if (PathService::Get(base::FILE_MODULE, &module_path)) {
30 FilePath current_dir = module_path.DirName(); 33 FilePath current_dir = module_path.DirName();
31 FilePath same_dir_path = current_dir.Append( 34 FilePath chrome_launcher = current_dir.Append(
32 chrome_launcher::kLauncherExeBaseName); 35 chrome_launcher::kLauncherExeBaseName);
33 if (file_util::PathExists(same_dir_path)) { 36 if (file_util::PathExists(chrome_launcher)) {
34 return new CommandLine(same_dir_path); 37 command_line->reset(new CommandLine(chrome_launcher));
35 } else { 38 success = true;
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 } 39 }
42 } else {
43 NOTREACHED();
44 return NULL;
45 } 40 }
41
42 NOTREACHED() << "Could not find " << chrome_launcher::kLauncherExeBaseName
43 << " in output dir.";
44 return success;
46 } 45 }
47 46
48 } // namespace 47 } // namespace
49 48
50 namespace chrome_launcher { 49 namespace chrome_launcher {
51 50
52 const wchar_t kLauncherExeBaseName[] = L"chrome_launcher.exe"; 51 const wchar_t kLauncherExeBaseName[] = L"chrome_launcher.exe";
53 52
54 CommandLine* CreateUpdateCommandLine(const std::wstring& update_command) { 53 bool CreateUpdateCommandLine(const std::wstring& update_command,
55 CommandLine* command_line = CreateChromeLauncherCommandLine(); 54 scoped_ptr<CommandLine>* command_line) {
55 DCHECK(command_line);
56 bool success = false;
56 57
57 if (command_line) { 58 scoped_ptr<CommandLine> chrome_launcher_cmd;
grt (UTC plus 2) 2011/09/23 21:18:11 i don't see a problem with using |command_line| ra
robertshield 2011/09/26 16:35:24 Not meaningfully, removed.
58 command_line->AppendArg(kUpdateCommandFlag); 59 if (CreateChromeLauncherCommandLine(&chrome_launcher_cmd)) {
59 command_line->AppendArg(WideToASCII(update_command)); 60 chrome_launcher_cmd->AppendArg(kUpdateCommandFlag);
61 chrome_launcher_cmd->AppendArg(WideToASCII(update_command));
62
63 command_line->reset(chrome_launcher_cmd.release());
64 success = true;
60 } 65 }
61 66
62 return command_line; 67 return success;
63 } 68 }
64 69
65 CommandLine* CreateLaunchCommandLine() { 70 bool CreateLaunchCommandLine(scoped_ptr<CommandLine>* command_line) {
71 DCHECK(command_line);
72
66 // Shortcut for OS versions that don't need the integrity broker. 73 // Shortcut for OS versions that don't need the integrity broker.
67 if (base::win::GetVersion() < base::win::VERSION_VISTA) { 74 if (base::win::GetVersion() < base::win::VERSION_VISTA) {
68 return new CommandLine(GetChromeExecutablePath()); 75 command_line->reset(new CommandLine(GetChromeExecutablePath()));
76 return true;
69 } 77 }
70 78
71 return CreateChromeLauncherCommandLine(); 79 return CreateChromeLauncherCommandLine(command_line);
72 } 80 }
73 81
74 FilePath GetChromeExecutablePath() { 82 FilePath GetChromeExecutablePath() {
75 FilePath cur_path; 83 FilePath cur_path;
76 PathService::Get(base::DIR_MODULE, &cur_path); 84 PathService::Get(base::DIR_MODULE, &cur_path);
77 cur_path = cur_path.Append(chrome::kBrowserProcessExecutableName); 85 cur_path = cur_path.Append(chrome::kBrowserProcessExecutableName);
78 86
79 // The installation model for Chrome places the DLLs in a versioned 87 // The installation model for Chrome places the DLLs in a versioned
80 // sub-folder one down from the Chrome executable. If we fail to find 88 // sub-folder one down from the Chrome executable. If we fail to find
81 // chrome.exe in the current path, try looking one up and launching that 89 // chrome.exe in the current path, try looking one up and launching that
82 // instead. 90 // instead.
83 if (!file_util::PathExists(cur_path)) { 91 if (!file_util::PathExists(cur_path)) {
84 PathService::Get(base::DIR_MODULE, &cur_path); 92 PathService::Get(base::DIR_MODULE, &cur_path);
85 cur_path = cur_path.DirName().Append(chrome::kBrowserProcessExecutableName); 93 cur_path = cur_path.DirName().Append(chrome::kBrowserProcessExecutableName);
86 } 94 }
87 95
88 return cur_path; 96 return cur_path;
89 } 97 }
90 98
91 } // namespace chrome_launcher 99 } // namespace chrome_launcher
OLDNEW
« no previous file with comments | « chrome_frame/chrome_launcher_utils.h ('k') | chrome_frame/ready_mode/internal/registry_ready_mode_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698