OLD | NEW |
---|---|
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 // See the corresponding header file for description of the functions in this | 5 // See the corresponding header file for description of the functions in this |
6 // file. | 6 // file. |
7 | 7 |
8 #include "chrome/installer/util/install_util.h" | 8 #include "chrome/installer/util/install_util.h" |
9 | 9 |
10 #include <shellapi.h> | 10 #include <shellapi.h> |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
358 CHECK(command_line); | 358 CHECK(command_line); |
359 | 359 |
360 if (command_line->HasSwitch(installer::switches::kChromeSxS)) | 360 if (command_line->HasSwitch(installer::switches::kChromeSxS)) |
361 return true; | 361 return true; |
362 | 362 |
363 // Also return true if we are running from Chrome SxS installed path. | 363 // Also return true if we are running from Chrome SxS installed path. |
364 base::FilePath exe_dir; | 364 base::FilePath exe_dir; |
365 PathService::Get(base::DIR_EXE, &exe_dir); | 365 PathService::Get(base::DIR_EXE, &exe_dir); |
366 string16 chrome_sxs_dir(installer::kGoogleChromeInstallSubDir2); | 366 string16 chrome_sxs_dir(installer::kGoogleChromeInstallSubDir2); |
367 chrome_sxs_dir.append(installer::kSxSSuffix); | 367 chrome_sxs_dir.append(installer::kSxSSuffix); |
368 return base::FilePath::CompareEqualIgnoreCase( | 368 |
369 exe_dir.BaseName().value(), installer::kInstallBinaryDir) && | 369 // This is SxS if current EXE is in or under (possibly multiple levels under) |
370 base::FilePath::CompareEqualIgnoreCase( | 370 // |chrome_sxs_dir|\|installer::kInstallBinaryDir| |
371 exe_dir.DirName().BaseName().value(), chrome_sxs_dir); | 371 std::vector<base::FilePath::StringType> components; |
372 exe_dir.GetComponents(&components); | |
373 // We need at least 1 element in the array for the behavior of the following | |
374 // loop to be defined. This should always be true, since we're splitting the | |
375 // path to our executable. | |
grt (UTC plus 2)
2013/09/12 14:04:53
this is splitting the dir containing the executabl
gab
2013/09/13 02:02:36
zturner:
| |
376 DCHECK(!components.empty()); | |
377 typedef std::vector<base::FilePath::StringType>::const_reverse_iterator | |
378 ComponentsIterator; | |
379 for (ComponentsIterator current = components.rbegin(), parent = current + 1; | |
380 parent != components.rend(); current = parent++) { | |
381 if (base::FilePath::CompareEqualIgnoreCase( | |
382 *current, installer::kInstallBinaryDir) && | |
383 base::FilePath::CompareEqualIgnoreCase(*parent, chrome_sxs_dir)) | |
grt (UTC plus 2)
2013/09/12 14:04:53
nit: use braces for multi-line conditional.
gab
2013/09/13 02:02:36
ping on this.
| |
384 return true; | |
385 } | |
386 | |
387 return false; | |
372 } | 388 } |
373 | 389 |
374 bool InstallUtil::IsChromeSxSProcess() { | 390 bool InstallUtil::IsChromeSxSProcess() { |
375 static bool sxs = CheckIsChromeSxSProcess(); | 391 static bool sxs = CheckIsChromeSxSProcess(); |
376 return sxs; | 392 return sxs; |
377 } | 393 } |
378 | 394 |
379 bool InstallUtil::GetSentinelFilePath(const base::FilePath::CharType* file, | 395 bool InstallUtil::GetSentinelFilePath(const base::FilePath::CharType* file, |
380 BrowserDistribution* dist, | 396 BrowserDistribution* dist, |
381 base::FilePath* path) { | 397 base::FilePath* path) { |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
603 // Open the program and see if it references the expected file. | 619 // Open the program and see if it references the expected file. |
604 base::win::ScopedHandle handle; | 620 base::win::ScopedHandle handle; |
605 BY_HANDLE_FILE_INFORMATION info = {}; | 621 BY_HANDLE_FILE_INFORMATION info = {}; |
606 | 622 |
607 return (OpenForInfo(path, &handle) && | 623 return (OpenForInfo(path, &handle) && |
608 GetInfo(handle, &info) && | 624 GetInfo(handle, &info) && |
609 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && | 625 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && |
610 info.nFileIndexHigh == file_info_.nFileIndexHigh && | 626 info.nFileIndexHigh == file_info_.nFileIndexHigh && |
611 info.nFileIndexLow == file_info_.nFileIndexLow); | 627 info.nFileIndexLow == file_info_.nFileIndexLow); |
612 } | 628 } |
OLD | NEW |