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..644360132ed5e324156aa45c5cd43783de027ed1 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,7 +43,12 @@ base::FilePath GetModulePath(base::StringPiece16 module_name, |
base::string16* version) { |
DCHECK(version); |
- base::FilePath module_dir = GetExecutableDir(); |
+ base::FilePath module_dir; |
+ if (!base::PathService::Get(base::DIR_EXE, &module_dir)) { |
Peter Kasting
2015/11/16 21:39:00
Can this ever really fail? It seems like it shoul
fdoray
2015/11/16 22:01:36
It should never fail.
|
+ LOG(ERROR) << "Cannot get current executable directory."; |
Peter Kasting
2015/11/16 21:39:00
We normally avoid logging statements unless you ha
fdoray
2015/11/16 22:01:36
Done.
|
+ return base::FilePath(); |
+ } |
+ |
base::FilePath module = module_dir.Append(module_name); |
if (ModuleCanBeRead(module)) |
return module; |