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

Side by Side Diff: chrome/browser/ui/pdf/adobe_reader_info_win.cc

Issue 2909943003: Removing useless Win7 checks + standardize its use (Closed)
Patch Set: Fix reversed conditionnal Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/pdf/adobe_reader_info_win.h" 5 #include "chrome/browser/ui/pdf/adobe_reader_info_win.h"
6 6
7 #include <shlwapi.h> 7 #include <shlwapi.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/file_version_info.h" 15 #include "base/file_version_info.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/version.h" 19 #include "base/version.h"
20 #include "base/win/registry.h" 20 #include "base/win/registry.h"
21 #include "base/win/windows_version.h"
22 #include "chrome/browser/browser_process.h" 21 #include "chrome/browser/browser_process.h"
23 22
24 namespace { 23 namespace {
25 24
26 // Hardcoded value for the secure version of Acrobat Reader. 25 // Hardcoded value for the secure version of Acrobat Reader.
27 const char kSecureVersion[] = "11.0.8.4"; 26 const char kSecureVersion[] = "11.0.8.4";
28 27
29 const base::char16 kRegistryAcrobat[] = L"Acrobat.exe"; 28 const base::char16 kRegistryAcrobat[] = L"Acrobat.exe";
30 const base::char16 kRegistryAcrobatReader[] = L"AcroRd32.exe"; 29 const base::char16 kRegistryAcrobatReader[] = L"AcroRd32.exe";
31 const base::char16 kRegistryApps[] = 30 const base::char16 kRegistryApps[] =
32 L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths"; 31 L"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths";
33 const base::char16 kRegistryPath[] = L"Path"; 32 const base::char16 kRegistryPath[] = L"Path";
34 33
35 // Gets the installed path for a registered app. 34 // Gets the installed path for a registered app.
36 base::FilePath GetInstalledPath(const base::char16* app) { 35 base::FilePath GetInstalledPath(const base::char16* app) {
37 base::string16 reg_path(kRegistryApps); 36 base::string16 reg_path(kRegistryApps);
38 reg_path.append(L"\\"); 37 reg_path.append(L"\\");
39 reg_path.append(app); 38 reg_path.append(app);
40 39
41 base::FilePath filepath; 40 base::FilePath filepath;
42 base::win::RegKey hkcu_key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ); 41 base::win::RegKey hkcu_key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ);
43 base::string16 path; 42 base::string16 path;
44 // As of Win7 AppPaths can also be registered in HKCU: http://goo.gl/UgFOf. 43 if (hkcu_key.ReadValue(kRegistryPath, &path) == ERROR_SUCCESS) {
Nico 2017/06/01 15:01:22 Keep comment with s/As of Win7//
Patrick Monette 2017/06/02 00:34:04 Done.
45 if (base::win::GetVersion() >= base::win::VERSION_WIN7 &&
46 hkcu_key.ReadValue(kRegistryPath, &path) == ERROR_SUCCESS) {
47 filepath = base::FilePath(path); 44 filepath = base::FilePath(path);
48 } else { 45 } else {
49 base::win::RegKey hklm_key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ); 46 base::win::RegKey hklm_key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ);
50 if (hklm_key.ReadValue(kRegistryPath, &path) == ERROR_SUCCESS) { 47 if (hklm_key.ReadValue(kRegistryPath, &path) == ERROR_SUCCESS) {
51 filepath = base::FilePath(path); 48 filepath = base::FilePath(path);
52 } 49 }
53 } 50 }
54 return filepath.Append(app); 51 return filepath.Append(app);
55 } 52 }
56 53
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // Convert 1.2.03.45 to 1.2.3.45 so base::Version considers it as valid. 95 // Convert 1.2.03.45 to 1.2.3.45 so base::Version considers it as valid.
99 for (int i = 1; i <= 9; ++i) { 96 for (int i = 1; i <= 9; ++i) {
100 std::string from = base::StringPrintf(".0%d", i); 97 std::string from = base::StringPrintf(".0%d", i);
101 std::string to = base::StringPrintf(".%d", i); 98 std::string to = base::StringPrintf(".%d", i);
102 base::ReplaceSubstringsAfterOffset(&reader_version, 0, from, to); 99 base::ReplaceSubstringsAfterOffset(&reader_version, 0, from, to);
103 } 100 }
104 base::Version file_version(reader_version); 101 base::Version file_version(reader_version);
105 return file_version.IsValid() && 102 return file_version.IsValid() &&
106 file_version >= base::Version(kSecureVersion); 103 file_version >= base::Version(kSecureVersion);
107 } 104 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698