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

Side by Side Diff: chrome/installer/launcher_support/chrome_launcher_support.cc

Issue 685103004: Refactor chrome_launcher_support::GetAnyChromePath. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix app_installer compile. Created 5 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/installer/launcher_support/chrome_launcher_support.h" 5 #include "chrome/installer/launcher_support/chrome_launcher_support.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 return exe_path; 106 return exe_path;
107 // By way of mild future proofing, look up one to see if there's a 107 // By way of mild future proofing, look up one to see if there's a
108 // |exe_file| in the version directory 108 // |exe_file| in the version directory
109 exe_path = setup_exe_path.DirName().DirName().Append(exe_file); 109 exe_path = setup_exe_path.DirName().DirName().Append(exe_file);
110 if (base::PathExists(exe_path)) 110 if (base::PathExists(exe_path))
111 return exe_path; 111 return exe_path;
112 } 112 }
113 return base::FilePath(); 113 return base::FilePath();
114 } 114 }
115 115
116 // Returns the path to an installed SxS chrome.exe at the specified level, if
117 // it can be found via the registry.
118 base::FilePath GetChromeSxSPathForInstallationLevel(InstallationLevel level) {
119 #if defined(GOOGLE_CHROME_BUILD)
120 return FindExeRelativeToSetupExe(
121 GetSetupExeFromRegistry(level, kSxSBrowserAppGuid), kChromeExe);
122 #else
123 // There is no SxS build for Chromium.
124 return base::FilePath();
125 #endif
126 }
127
128 } // namespace 116 } // namespace
129 117
130 base::FilePath GetChromePathForInstallationLevel(InstallationLevel level) { 118 base::FilePath GetChromePathForInstallationLevel(InstallationLevel level,
131 return FindExeRelativeToSetupExe( 119 bool is_sxs) {
132 GetSetupExeForInstallationLevel(level), kChromeExe); 120 if (is_sxs) {
121 #if defined(GOOGLE_CHROME_BUILD)
122 return FindExeRelativeToSetupExe(
123 GetSetupExeFromRegistry(level, kSxSBrowserAppGuid), kChromeExe);
124 #else
125 // There is no SxS build for Chromium.
126 return base::FilePath();
127 #endif
128 } else {
129 return FindExeRelativeToSetupExe(GetSetupExeForInstallationLevel(level),
130 kChromeExe);
131 }
133 } 132 }
134 133
135 base::FilePath GetAnyChromePath() { 134 base::FilePath GetAnyChromePath(bool is_sxs) {
136 base::FilePath chrome_path; 135 base::FilePath path;
137 if (chrome_path.empty()) 136 path = GetChromePathForInstallationLevel(SYSTEM_LEVEL_INSTALLATION, is_sxs);
138 chrome_path = GetChromePathForInstallationLevel(SYSTEM_LEVEL_INSTALLATION);
139 if (chrome_path.empty())
140 chrome_path = GetChromePathForInstallationLevel(USER_LEVEL_INSTALLATION);
141 return chrome_path;
142 }
143
144 base::FilePath GetAnyChromeSxSPath() {
145 base::FilePath path =
146 GetChromeSxSPathForInstallationLevel(USER_LEVEL_INSTALLATION);
147 if (path.empty()) 137 if (path.empty())
148 path = GetChromeSxSPathForInstallationLevel(SYSTEM_LEVEL_INSTALLATION); 138 path = GetChromePathForInstallationLevel(USER_LEVEL_INSTALLATION, is_sxs);
149 return path; 139 return path;
150 } 140 }
151 141
152 } // namespace chrome_launcher_support 142 } // namespace chrome_launcher_support
OLDNEW
« no previous file with comments | « chrome/installer/launcher_support/chrome_launcher_support.h ('k') | cloud_print/service/win/chrome_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698