OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "apps/app_host/update.h" | 5 #include "apps/app_host/update.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_version_info.h" | 9 #include "base/file_version_info.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 const wchar_t kBinariesAppGuid[] = L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}"; | 35 const wchar_t kBinariesAppGuid[] = L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}"; |
36 | 36 |
37 // Copied from google_chrome_distribution.cc. | 37 // Copied from google_chrome_distribution.cc. |
38 const wchar_t kBrowserAppGuid[] = L"{8A69D345-D564-463c-AFF1-A69D9E530F96}"; | 38 const wchar_t kBrowserAppGuid[] = L"{8A69D345-D564-463c-AFF1-A69D9E530F96}"; |
39 | 39 |
40 // Fetches the version of the App Host, directly from the image's version | 40 // Fetches the version of the App Host, directly from the image's version |
41 // resource. | 41 // resource. |
42 Version GetAppHostVersion() { | 42 Version GetAppHostVersion() { |
43 scoped_ptr<FileVersionInfo> version_info( | 43 scoped_ptr<FileVersionInfo> version_info( |
44 FileVersionInfo::CreateFileVersionInfoForCurrentModule()); | 44 FileVersionInfo::CreateFileVersionInfoForCurrentModule()); |
45 Version app_host_version(WideToASCII(version_info->product_version())); | 45 Version app_host_version(base::WideToASCII(version_info->product_version())); |
46 DCHECK(app_host_version.IsValid()); | 46 DCHECK(app_host_version.IsValid()); |
47 return app_host_version; | 47 return app_host_version; |
48 } | 48 } |
49 | 49 |
50 // Fetches the app version ("pv" entry) of a Google product from the | 50 // Fetches the app version ("pv" entry) of a Google product from the |
51 // system-level registry, given the app GUID ("{###...###}"). | 51 // system-level registry, given the app GUID ("{###...###}"). |
52 Version GetAppVersionFromRegistry(const wchar_t* app_guid) { | 52 Version GetAppVersionFromRegistry(const wchar_t* app_guid) { |
53 HKEY root_key = HKEY_LOCAL_MACHINE; | 53 HKEY root_key = HKEY_LOCAL_MACHINE; |
54 string16 client_key(kGoogleRegClientsKey); | 54 string16 client_key(kGoogleRegClientsKey); |
55 client_key.append(app_guid); | 55 client_key.append(app_guid); |
56 base::win::RegKey reg_key; | 56 base::win::RegKey reg_key; |
57 string16 version_str; | 57 string16 version_str; |
58 if ((reg_key.Open(root_key, client_key.c_str(), | 58 if ((reg_key.Open(root_key, client_key.c_str(), |
59 KEY_QUERY_VALUE) == ERROR_SUCCESS) && | 59 KEY_QUERY_VALUE) == ERROR_SUCCESS) && |
60 (reg_key.ReadValue(kRegVersionField, &version_str) == ERROR_SUCCESS)) { | 60 (reg_key.ReadValue(kRegVersionField, &version_str) == ERROR_SUCCESS)) { |
61 return Version(WideToASCII(version_str)); | 61 return Version(base::WideToASCII(version_str)); |
62 } | 62 } |
63 return Version(); | 63 return Version(); |
64 } | 64 } |
65 | 65 |
66 // Calls setup.exe to update App Host, using the system-level setup.exe. | 66 // Calls setup.exe to update App Host, using the system-level setup.exe. |
67 bool LaunchAppHostUpdate() { | 67 bool LaunchAppHostUpdate() { |
68 // Get the path to the setup.exe. | 68 // Get the path to the setup.exe. |
69 base::FilePath setup_exe( | 69 base::FilePath setup_exe( |
70 chrome_launcher_support::GetSetupExeForInstallationLevel( | 70 chrome_launcher_support::GetSetupExeForInstallationLevel( |
71 chrome_launcher_support::SYSTEM_LEVEL_INSTALLATION)); | 71 chrome_launcher_support::SYSTEM_LEVEL_INSTALLATION)); |
(...skipping 21 matching lines...) Expand all Loading... |
93 Version app_host_version(GetAppHostVersion()); | 93 Version app_host_version(GetAppHostVersion()); |
94 if (app_host_version.CompareTo(new_version) < 0) { | 94 if (app_host_version.CompareTo(new_version) < 0) { |
95 LOG(INFO) << "Updating App Launcher from " << app_host_version.GetString() | 95 LOG(INFO) << "Updating App Launcher from " << app_host_version.GetString() |
96 << " to " << new_version.GetString(); | 96 << " to " << new_version.GetString(); |
97 if (!LaunchAppHostUpdate()) | 97 if (!LaunchAppHostUpdate()) |
98 LOG(ERROR) << "Failed to launch App Launcher update."; | 98 LOG(ERROR) << "Failed to launch App Launcher update."; |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 } // namespace app_host | 102 } // namespace app_host |
OLD | NEW |