[Android] Added UMA for search by image context menu.
[chromium-blink-merge.git] / chrome / installer / util / compat_checks.cc
blobef50f61ef01c781392b3d0c8f6667cd66217509a
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
3 // found in the LICENSE file.
5 #include "chrome/installer/util/compat_checks.h"
7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_split.h"
9 #include "base/strings/string_util.h"
10 #include "base/win/registry.h"
12 namespace {
14 // SEP stands for Symantec End Point Protection.
15 std::wstring GetSEPVersion() {
16 const wchar_t kProductKey[] =
17 L"SOFTWARE\\Symantec\\Symantec Endpoint Protection\\SMC";
18 base::win::RegKey key(HKEY_LOCAL_MACHINE, kProductKey, KEY_READ);
19 std::wstring version_str;
20 key.ReadValue(L"ProductVersion", &version_str);
21 return version_str;
24 // The product version should be a string like "11.0.3001.2224". This function
25 // returns as params the first 3 values. Return value is false if anything
26 // does not fit the format.
27 bool ParseSEPVersion(const std::wstring& version, int* v0, int* v1, int* v2) {
28 std::vector<std::wstring> v;
29 base::SplitString(version, L'.', &v);
30 if (v.size() != 4)
31 return false;
32 if (!base::StringToInt(v[0], v0))
33 return false;
34 if (!base::StringToInt(v[1], v1))
35 return false;
36 if (!base::StringToInt(v[2], v2))
37 return false;
38 return true;
41 // The incompatible versions are anything before 11MR3, which is 11.0.3001.
42 bool IsBadSEPVersion(int v0, int v1, int v2) {
43 if (v0 < 11)
44 return true;
45 if (v1 > 0)
46 return false;
47 if (v2 < 3001)
48 return true;
49 return false;
52 } // namespace
54 bool HasIncompatibleSymantecEndpointVersion(const wchar_t* version) {
55 int v0, v1, v2;
56 std::wstring ver_str(version ? version : GetSEPVersion());
57 if (!ParseSEPVersion(ver_str, &v0, &v1, &v2))
58 return false;
59 return IsBadSEPVersion(v0, v1, v2);