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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 // Suss out the exe portion of the value, which is expected to be a command | 562 // Suss out the exe portion of the value, which is expected to be a command |
563 // line kinda (or exactly) like: | 563 // line kinda (or exactly) like: |
564 // "c:\foo\bar\chrome.exe" -- "%1" | 564 // "c:\foo\bar\chrome.exe" -- "%1" |
565 FilePath program(CommandLine::FromString(value).GetProgram()); | 565 FilePath program(CommandLine::FromString(value).GetProgram()); |
566 if (program.empty()) { | 566 if (program.empty()) { |
567 LOG(WARNING) << "Failed to parse an executable name from command line: \"" | 567 LOG(WARNING) << "Failed to parse an executable name from command line: \"" |
568 << value << "\""; | 568 << value << "\""; |
569 return false; | 569 return false; |
570 } | 570 } |
571 | 571 |
| 572 return EvaluatePath(program); |
| 573 } |
| 574 |
| 575 bool InstallUtil::ProgramCompare::EvaluatePath(const FilePath& path) const { |
572 // Try the simple thing first: do the paths happen to match? | 576 // Try the simple thing first: do the paths happen to match? |
573 if (FilePath::CompareEqualIgnoreCase(path_to_match_.value(), program.value())) | 577 if (FilePath::CompareEqualIgnoreCase(path_to_match_.value(), path.value())) |
574 return true; | 578 return true; |
575 | 579 |
576 // If the paths don't match and we couldn't open the expected file, we've done | 580 // If the paths don't match and we couldn't open the expected file, we've done |
577 // our best. | 581 // our best. |
578 if (!file_handle_.IsValid()) | 582 if (!file_handle_.IsValid()) |
579 return false; | 583 return false; |
580 | 584 |
581 // Open the program and see if it references the expected file. | 585 // Open the program and see if it references the expected file. |
582 base::win::ScopedHandle handle; | 586 base::win::ScopedHandle handle; |
583 BY_HANDLE_FILE_INFORMATION info = {}; | 587 BY_HANDLE_FILE_INFORMATION info = {}; |
584 | 588 |
585 return (OpenForInfo(program, &handle) && | 589 return (OpenForInfo(path, &handle) && |
586 GetInfo(handle, &info) && | 590 GetInfo(handle, &info) && |
587 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && | 591 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && |
588 info.nFileIndexHigh == file_info_.nFileIndexHigh && | 592 info.nFileIndexHigh == file_info_.nFileIndexHigh && |
589 info.nFileIndexLow == file_info_.nFileIndexLow); | 593 info.nFileIndexLow == file_info_.nFileIndexLow); |
590 } | 594 } |
OLD | NEW |