OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // CEEE module-wide utilities. | 5 // CEEE module-wide utilities. |
6 | 6 |
7 #include "ceee/ie/common/ceee_module_util.h" | 7 #include "ceee/ie/common/ceee_module_util.h" |
8 | 8 |
| 9 #include <iepmapi.h> |
| 10 |
9 #include "base/file_path.h" | 11 #include "base/file_path.h" |
10 #include "base/file_util.h" | 12 #include "base/file_util.h" |
11 #include "base/logging.h" | 13 #include "base/logging.h" |
12 #include "base/path_service.h" | 14 #include "base/path_service.h" |
13 #include "base/stringize_macros.h" | 15 #include "base/stringize_macros.h" |
14 #include "base/win/registry.h" | 16 #include "base/win/registry.h" |
| 17 #include "ceee/common/com_utils.h" |
15 #include "ceee/common/process_utils_win.h" | 18 #include "ceee/common/process_utils_win.h" |
| 19 #include "ceee/ie/common/ie_util.h" |
16 #include "chrome/installer/util/google_update_constants.h" | 20 #include "chrome/installer/util/google_update_constants.h" |
17 | 21 |
18 #include "version.h" // NOLINT | 22 #include "version.h" // NOLINT |
19 | 23 |
20 namespace { | 24 namespace { |
21 | 25 |
22 const wchar_t* kRegistryPath = L"SOFTWARE\\Google\\CEEE"; | 26 const wchar_t* kRegistryPath = L"SOFTWARE\\Google\\CEEE"; |
23 const wchar_t* kRegistryValueToolbandIsHidden = L"toolband_is_hidden"; | 27 const wchar_t* kRegistryValueToolbandIsHidden = L"toolband_is_hidden"; |
24 const wchar_t* kRegistryValueToolbandPlaced = L"toolband_placed"; | 28 const wchar_t* kRegistryValueToolbandPlaced = L"toolband_placed"; |
25 const wchar_t* kRegistryValueCrxInstalledPath = L"crx_installed_path"; | 29 const wchar_t* kRegistryValueCrxInstalledPath = L"crx_installed_path"; |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 base::win::RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ); | 303 base::win::RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ); |
300 DWORD value; | 304 DWORD value; |
301 if (!key.ReadValueDW(google_update::kRegUsageStatsField, &value)) { | 305 if (!key.ReadValueDW(google_update::kRegUsageStatsField, &value)) { |
302 base::win::RegKey hklm_key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ); | 306 base::win::RegKey hklm_key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ); |
303 if (!hklm_key.ReadValueDW(google_update::kRegUsageStatsField, &value)) | 307 if (!hklm_key.ReadValueDW(google_update::kRegUsageStatsField, &value)) |
304 return false; | 308 return false; |
305 } | 309 } |
306 return (1 == value); | 310 return (1 == value); |
307 } | 311 } |
308 | 312 |
| 313 bool RefreshElevationPolicyIfNeeded() { |
| 314 if (ie_util::GetIeVersion() < ie_util::IEVERSION_IE7) |
| 315 return false; |
| 316 |
| 317 // This may access InternetRegistry instead of real one. However this is |
| 318 // acceptable, we just refresh policy twice. |
| 319 base::win::RegKey hkcu(HKEY_CURRENT_USER, kRegistryPath, |
| 320 KEY_WRITE | KEY_QUERY_VALUE); |
| 321 LOG_IF(ERROR, !hkcu.Valid()) << "Failed to open reg key: " << kRegistryPath; |
| 322 if (!hkcu.Valid()) |
| 323 return false; |
| 324 |
| 325 std::wstring expected_version = TO_L_STRING(CHROME_VERSION_STRING); |
| 326 |
| 327 static const wchar_t kValueName[] = L"last_elevation_refresh"; |
| 328 std::wstring last_elevation_refresh_version; |
| 329 bool result = hkcu.ReadValue(kValueName, &last_elevation_refresh_version); |
| 330 if (last_elevation_refresh_version == expected_version) |
| 331 return false; |
| 332 |
| 333 HRESULT hr = ::IERefreshElevationPolicy(); |
| 334 VLOG(1) << "Elevation policy refresh result: " << com::LogHr(hr); |
| 335 |
| 336 // Write after refreshing because it's better to refresh twice, than to miss |
| 337 // once. |
| 338 result = hkcu.WriteValue(kValueName, expected_version.c_str()); |
| 339 LOG_IF(ERROR, !result) << "Failed to write a registry value: " << kValueName; |
| 340 |
| 341 return true; |
| 342 } |
| 343 |
309 } // namespace ceee_module_util | 344 } // namespace ceee_module_util |
OLD | NEW |