Chromium Code Reviews| Index: chrome/installer/util/module_util_win.cc |
| diff --git a/chrome/installer/util/module_util_win.cc b/chrome/installer/util/module_util_win.cc |
| index c589263690a9c127ca795d8b75e3b449a2fdca6f..d3b78d5d9a83a097682a4e2d18a234ffb6b53267 100644 |
| --- a/chrome/installer/util/module_util_win.cc |
| +++ b/chrome/installer/util/module_util_win.cc |
| @@ -2,14 +2,14 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include <windows.h> |
| - |
| #include "chrome/installer/util/module_util_win.h" |
| +#include "base/base_paths.h" |
| #include "base/file_version_info.h" |
| #include "base/files/file.h" |
| #include "base/logging.h" |
| #include "base/memory/scoped_ptr.h" |
| +#include "base/path_service.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "base/version.h" |
| @@ -17,13 +17,6 @@ namespace installer { |
| namespace { |
| -// Returns the directory in which the currently running executable resides. |
| -base::FilePath GetExecutableDir() { |
| - base::char16 path[MAX_PATH]; |
| - ::GetModuleFileNameW(nullptr, path, MAX_PATH); |
| - return base::FilePath(path).DirName(); |
| -} |
| - |
| // Returns the version in the current module's version resource or the empty |
| // string if none found. |
| base::string16 GetCurrentModuleVersion() { |
| @@ -31,7 +24,7 @@ base::string16 GetCurrentModuleVersion() { |
| CREATE_FILE_VERSION_INFO_FOR_CURRENT_MODULE()); |
| if (file_version_info.get()) { |
| base::string16 version_string(file_version_info->file_version()); |
| - if (Version(base::UTF16ToASCII(version_string)).IsValid()) |
| + if (base::Version(base::UTF16ToASCII(version_string)).IsValid()) |
| return version_string; |
| } |
| return base::string16(); |
| @@ -50,16 +43,18 @@ base::FilePath GetModulePath(base::StringPiece16 module_name, |
| base::string16* version) { |
| DCHECK(version); |
| - base::FilePath module_dir = GetExecutableDir(); |
| + base::FilePath module_dir; |
|
gab
2015/11/17 14:45:58
This won't store the module's dir, but the applica
Peter Kasting
2015/11/17 20:24:18
This has ramifications for the function name here
fdoray
2015/11/17 22:10:37
I changed the variable name, but not the function
|
| + if (!base::PathService::Get(base::DIR_EXE, &module_dir)) |
| + return base::FilePath(); |
|
gab
2015/11/17 14:45:58
Add NOTREACHED(), this should never happen.
Peter Kasting
2015/11/17 20:24:18
If it should never happen, NOTREACHED() wouldn't b
fdoray
2015/11/17 22:10:37
base::PathService::Get(base::DIR_EXE, &exe_dir) sh
|
| + |
| base::FilePath module = module_dir.Append(module_name); |
| if (ModuleCanBeRead(module)) |
| return module; |
| base::string16 version_string(GetCurrentModuleVersion()); |
| - if (version_string.empty()) { |
| - LOG(ERROR) << "No valid Chrome version found"; |
| + if (version_string.empty()) |
| return base::FilePath(); |
|
gab
2015/11/17 14:45:58
Pretty sure this should also never happen, +NOTREA
fdoray
2015/11/17 22:10:37
It will not fail if the Chrome binary has a valid
|
| - } |
| + |
| *version = version_string; |
| return module_dir.Append(version_string).Append(module_name); |
| } |