OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 #include "chrome/installer/util/module_util_win.h" | 5 #include "chrome/installer/util/module_util_win.h" |
6 | 6 |
7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/file_version_info.h" | 8 #include "base/file_version_info.h" |
9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/version.h" | 15 #include "base/version.h" |
| 16 #include "base/win/current_module.h" |
16 | 17 |
17 namespace installer { | 18 namespace installer { |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 // Returns the version in the current executable's version resource. | 22 // Returns the version in the current executable's version resource. |
22 base::string16 GetCurrentExecutableVersion() { | 23 base::string16 GetCurrentExecutableVersion() { |
23 scoped_ptr<FileVersionInfo> file_version_info( | 24 scoped_ptr<FileVersionInfo> file_version_info( |
24 CREATE_FILE_VERSION_INFO_FOR_CURRENT_MODULE()); | 25 FileVersionInfo::CreateFileVersionInfoForModule(CURRENT_MODULE())); |
25 DCHECK(file_version_info.get()); | 26 DCHECK(file_version_info.get()); |
26 base::string16 version_string(file_version_info->file_version()); | 27 base::string16 version_string(file_version_info->file_version()); |
27 DCHECK(base::Version(base::UTF16ToASCII(version_string)).IsValid()); | 28 DCHECK(base::Version(base::UTF16ToASCII(version_string)).IsValid()); |
28 return version_string; | 29 return version_string; |
29 } | 30 } |
30 | 31 |
31 // Indicates whether a file can be opened using the same flags that | 32 // Indicates whether a file can be opened using the same flags that |
32 // ::LoadLibrary() uses to open modules. | 33 // ::LoadLibrary() uses to open modules. |
33 bool ModuleCanBeRead(const base::FilePath file_path) { | 34 bool ModuleCanBeRead(const base::FilePath file_path) { |
34 return base::File(file_path, base::File::FLAG_OPEN | base::File::FLAG_READ) | 35 return base::File(file_path, base::File::FLAG_OPEN | base::File::FLAG_READ) |
(...skipping 16 matching lines...) Expand all Loading... |
51 | 52 |
52 // Othwerwise, return the path to the module in a versioned sub-directory of | 53 // Othwerwise, return the path to the module in a versioned sub-directory of |
53 // the current executable's directory. This is the expected location of | 54 // the current executable's directory. This is the expected location of |
54 // modules for proper installs. | 55 // modules for proper installs. |
55 const base::string16 version = GetCurrentExecutableVersion(); | 56 const base::string16 version = GetCurrentExecutableVersion(); |
56 DCHECK(!version.empty()); | 57 DCHECK(!version.empty()); |
57 return exe_dir.Append(version).Append(module_name); | 58 return exe_dir.Append(version).Append(module_name); |
58 } | 59 } |
59 | 60 |
60 } // namespace installer | 61 } // namespace installer |
OLD | NEW |