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 typedef std::vector<base::FilePath::StringType>::const_reverse_iterator |
gab
2013/09/11 21:26:29
I would put the typedef right before the for loop
| |
372 ComponentsIterator; | |
373 std::vector<base::FilePath::StringType> components; | |
374 exe_dir.GetComponents(&components); | |
375 for (ComponentsIterator current = components.rbegin(), parent = current+1; | |
gab
2013/09/11 21:26:29
Need to check:
if (components.size() < 2)
retur
gab
2013/09/11 21:26:29
Spaces on each side of '+' sign.
| |
376 parent != components.rend(); current = parent++) { | |
377 if (base::FilePath::CompareEqualIgnoreCase(*current, | |
grt (UTC plus 2)
2013/09/11 21:39:34
move *current to next line as was done in uninstal
| |
378 installer::kInstallBinaryDir)) { | |
379 if (base::FilePath::CompareEqualIgnoreCase(*parent, chrome_sxs_dir)) | |
gab
2013/09/11 21:26:29
Use && instead of nesting ifs.
| |
380 return true; | |
381 } | |
382 } | |
383 | |
384 return false; | |
372 } | 385 } |
373 | 386 |
374 bool InstallUtil::IsChromeSxSProcess() { | 387 bool InstallUtil::IsChromeSxSProcess() { |
375 static bool sxs = CheckIsChromeSxSProcess(); | 388 static bool sxs = CheckIsChromeSxSProcess(); |
376 return sxs; | 389 return sxs; |
377 } | 390 } |
378 | 391 |
379 bool InstallUtil::GetSentinelFilePath(const base::FilePath::CharType* file, | 392 bool InstallUtil::GetSentinelFilePath(const base::FilePath::CharType* file, |
380 BrowserDistribution* dist, | 393 BrowserDistribution* dist, |
381 base::FilePath* path) { | 394 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. | 616 // Open the program and see if it references the expected file. |
604 base::win::ScopedHandle handle; | 617 base::win::ScopedHandle handle; |
605 BY_HANDLE_FILE_INFORMATION info = {}; | 618 BY_HANDLE_FILE_INFORMATION info = {}; |
606 | 619 |
607 return (OpenForInfo(path, &handle) && | 620 return (OpenForInfo(path, &handle) && |
608 GetInfo(handle, &info) && | 621 GetInfo(handle, &info) && |
609 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && | 622 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && |
610 info.nFileIndexHigh == file_info_.nFileIndexHigh && | 623 info.nFileIndexHigh == file_info_.nFileIndexHigh && |
611 info.nFileIndexLow == file_info_.nFileIndexLow); | 624 info.nFileIndexLow == file_info_.nFileIndexLow); |
612 } | 625 } |
OLD | NEW |