| Index: content/public/common/registry_utils_win.cc
|
| diff --git a/content/public/common/registry_utils_win.cc b/content/public/common/registry_utils_win.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e23ff7315168f1b091e999ab52a1dc94ce2cdc6c
|
| --- /dev/null
|
| +++ b/content/public/common/registry_utils_win.cc
|
| @@ -0,0 +1,43 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "content/public/common/registry_utils_win.h"
|
| +
|
| +#include "base/files/file_path.h"
|
| +#include "base/win/registry.h"
|
| +#include "base/win/windows_version.h"
|
| +
|
| +namespace content {
|
| +
|
| +const base::char16 kRegistryAppsKey[] =
|
| + L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths";
|
| +const base::char16 kRegistryPath[] = L"Path";
|
| +
|
| +const base::char16 kRegistryAcrobat[] = L"Acrobat.exe";
|
| +const base::char16 kRegistryAcrobatReader[] = L"AcroRd32.exe";
|
| +
|
| +bool GetInstalledPath(const base::char16* app, base::FilePath* out) {
|
| + base::string16 reg_path(kRegistryAppsKey);
|
| + reg_path.append(L"\\");
|
| + reg_path.append(app);
|
| +
|
| + base::win::RegKey hkcu_key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ);
|
| + base::string16 path;
|
| + // As of Win7 AppPaths can also be registered in HKCU: http://goo.gl/UgFOf.
|
| + if (base::win::GetVersion() >= base::win::VERSION_WIN7 &&
|
| + hkcu_key.ReadValue(kRegistryPath, &path) == ERROR_SUCCESS) {
|
| + *out = base::FilePath(path);
|
| + return true;
|
| + } else {
|
| + base::win::RegKey hklm_key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ);
|
| + if (hklm_key.ReadValue(kRegistryPath, &path) == ERROR_SUCCESS) {
|
| + *out = base::FilePath(path);
|
| + return true;
|
| + }
|
| + }
|
| +
|
| + return false;
|
| +}
|
| +
|
| +} // namespace content
|
|
|