OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "cloud_print/common/win/install_utils.h" | 5 #include "cloud_print/common/win/install_utils.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_version_info_win.h" | 10 #include "base/file_version_info_win.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 base::win::RegKey key; | 54 base::win::RegKey key; |
55 if (key.Create(HKEY_LOCAL_MACHINE, | 55 if (key.Create(HKEY_LOCAL_MACHINE, |
56 (cloud_print::kClientsKey + product_id).c_str(), | 56 (cloud_print::kClientsKey + product_id).c_str(), |
57 KEY_SET_VALUE) != ERROR_SUCCESS) { | 57 KEY_SET_VALUE) != ERROR_SUCCESS) { |
58 LOG(ERROR) << "Unable to open key"; | 58 LOG(ERROR) << "Unable to open key"; |
59 } | 59 } |
60 | 60 |
61 // Get the version from the resource file. | 61 // Get the version from the resource file. |
62 base::string16 version_string; | 62 base::string16 version_string; |
63 scoped_ptr<FileVersionInfo> version_info( | 63 scoped_ptr<FileVersionInfo> version_info( |
64 FileVersionInfo::CreateFileVersionInfoForCurrentModule()); | 64 CREATE_FILE_VERSION_INFO_FOR_CURRENT_MODULE()); |
65 | 65 |
66 if (version_info.get()) { | 66 if (version_info.get()) { |
67 FileVersionInfoWin* version_info_win = | 67 FileVersionInfoWin* version_info_win = |
68 static_cast<FileVersionInfoWin*>(version_info.get()); | 68 static_cast<FileVersionInfoWin*>(version_info.get()); |
69 version_string = version_info_win->product_version(); | 69 version_string = version_info_win->product_version(); |
70 } else { | 70 } else { |
71 LOG(ERROR) << "Unable to get version string"; | 71 LOG(ERROR) << "Unable to get version string"; |
72 // Use a random version string so that Google Update has something to go by. | 72 // Use a random version string so that Google Update has something to go by. |
73 version_string = L"0.0.0.99"; | 73 version_string = L"0.0.0.99"; |
74 } | 74 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 145 |
146 base::CommandLine uninstall_command(unstall_binary); | 146 base::CommandLine uninstall_command(unstall_binary); |
147 uninstall_command.AppendSwitch(uninstall_switch); | 147 uninstall_command.AppendSwitch(uninstall_switch); |
148 key.WriteValue(kUninstallString, | 148 key.WriteValue(kUninstallString, |
149 uninstall_command.GetCommandLineString().c_str()); | 149 uninstall_command.GetCommandLineString().c_str()); |
150 key.WriteValue(kInstallLocation, | 150 key.WriteValue(kInstallLocation, |
151 unstall_binary.DirName().value().c_str()); | 151 unstall_binary.DirName().value().c_str()); |
152 | 152 |
153 // Get the version resource. | 153 // Get the version resource. |
154 scoped_ptr<FileVersionInfo> version_info( | 154 scoped_ptr<FileVersionInfo> version_info( |
155 FileVersionInfo::CreateFileVersionInfoForCurrentModule()); | 155 CREATE_FILE_VERSION_INFO_FOR_CURRENT_MODULE()); |
156 | 156 |
157 if (version_info.get()) { | 157 if (version_info.get()) { |
158 FileVersionInfoWin* version_info_win = | 158 FileVersionInfoWin* version_info_win = |
159 static_cast<FileVersionInfoWin*>(version_info.get()); | 159 static_cast<FileVersionInfoWin*>(version_info.get()); |
160 key.WriteValue(kDisplayVersion, | 160 key.WriteValue(kDisplayVersion, |
161 version_info_win->file_version().c_str()); | 161 version_info_win->file_version().c_str()); |
162 key.WriteValue(kPublisher, version_info_win->company_name().c_str()); | 162 key.WriteValue(kPublisher, version_info_win->company_name().c_str()); |
163 } else { | 163 } else { |
164 LOG(ERROR) << "Unable to get version string"; | 164 LOG(ERROR) << "Unable to get version string"; |
165 } | 165 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 209 |
210 bool IsProgramsFilesParent(const base::FilePath& path) { | 210 bool IsProgramsFilesParent(const base::FilePath& path) { |
211 base::FilePath program_files; | 211 base::FilePath program_files; |
212 if (!PathService::Get(base::DIR_PROGRAM_FILESX86, &program_files)) | 212 if (!PathService::Get(base::DIR_PROGRAM_FILESX86, &program_files)) |
213 return false; | 213 return false; |
214 return program_files.IsParent(path); | 214 return program_files.IsParent(path); |
215 } | 215 } |
216 | 216 |
217 } // namespace cloud_print | 217 } // namespace cloud_print |
218 | 218 |
OLD | NEW |