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