Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2326)

Unified Diff: content/public/common/registry_utils_win.cc

Issue 324593004: Windows: Add an "Open in Adobe Reader" menu item for PDF files in the download shelf. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix build Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« content/public/common/registry_utils_win.h ('K') | « content/public/common/registry_utils_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698