Index: chrome/installer/util/install_util.cc |
diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc |
index c8c037df823364a081b3ebac240cb974244d3e27..f1eb705d3763c8ca5308e26eaea8e086000ed97d 100644 |
--- a/chrome/installer/util/install_util.cc |
+++ b/chrome/installer/util/install_util.cc |
@@ -365,10 +365,31 @@ bool CheckIsChromeSxSProcess() { |
PathService::Get(base::DIR_EXE, &exe_dir); |
string16 chrome_sxs_dir(installer::kGoogleChromeInstallSubDir2); |
chrome_sxs_dir.append(installer::kSxSSuffix); |
- return base::FilePath::CompareEqualIgnoreCase( |
- exe_dir.BaseName().value(), installer::kInstallBinaryDir) && |
- base::FilePath::CompareEqualIgnoreCase( |
- exe_dir.DirName().BaseName().value(), chrome_sxs_dir); |
+ |
+ // This is SxS if current EXE is in or under (possibly multiple levels under) |
+ // |chrome_sxs_dir|\|installer::kInstallBinaryDir| |
+ std::vector<base::FilePath::StringType> components; |
+ exe_dir.GetComponents(&components); |
+ auto iter = components.begin(); |
+ while (iter != components.end()) { |
gab
2013/09/06 18:40:08
I would say it's faster (and perhaps slightly more
zturner
2013/09/06 20:53:16
Done.
|
+ if (!base::FilePath::CompareEqualIgnoreCase(*iter, chrome_sxs_dir)) { |
+ ++iter; |
+ continue; |
+ } |
+ |
+ if (++iter == components.end()) |
+ return false; |
+ |
+ if (base::FilePath::CompareEqualIgnoreCase(*iter, |
+ installer::kInstallBinaryDir)) |
+ return true; |
+ |
+ // Don't increment the iterator here. It's theoretically possible to have |
+ // a path that looks like "Chrome SxS\Chrome SxS\Application" which should |
+ // still be treated as a SxS installation. |
gab
2013/09/06 18:40:08
This case is safer with the reverse iteration prop
zturner
2013/09/06 20:53:16
Done.
|
+ } |
+ |
+ return false; |
} |
bool InstallUtil::IsChromeSxSProcess() { |