chrome_version_info_win.cc revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
1// Copyright (c) 2011 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.
4
5#include "chrome/common/chrome_version_info.h"
6
7#include "base/base_paths.h"
8#include "base/debug/profiler.h"
9#include "base/files/file_path.h"
10#include "base/path_service.h"
11#include "base/strings/string_util.h"
12#include "base/strings/utf_string_conversions.h"
13#include "chrome/installer/util/google_update_settings.h"
14#include "chrome/installer/util/install_util.h"
15
16namespace chrome {
17
18// static
19std::string VersionInfo::GetVersionStringModifier() {
20#if defined(GOOGLE_CHROME_BUILD)
21  base::FilePath module;
22  base::string16 channel;
23  if (PathService::Get(base::FILE_MODULE, &module)) {
24    bool is_system_install =
25        !InstallUtil::IsPerUserInstall(module.value().c_str());
26
27    GoogleUpdateSettings::GetChromeChannelAndModifiers(is_system_install,
28                                                       &channel);
29  }
30#if defined(ADDRESS_SANITIZER)
31  if (base::debug::IsBinaryInstrumented())
32    channel += L" SyzyASan";
33#endif
34  return base::UTF16ToASCII(channel);
35#else
36  return std::string();
37#endif
38}
39
40// static
41VersionInfo::Channel VersionInfo::GetChannel() {
42#if defined(GOOGLE_CHROME_BUILD)
43  std::wstring channel(L"unknown");
44
45  base::FilePath module;
46  if (PathService::Get(base::FILE_MODULE, &module)) {
47    bool is_system_install =
48        !InstallUtil::IsPerUserInstall(module.value().c_str());
49    channel = GoogleUpdateSettings::GetChromeChannel(is_system_install);
50  }
51
52  if (channel.empty()) {
53    return CHANNEL_STABLE;
54  } else if (channel == L"beta") {
55    return CHANNEL_BETA;
56  } else if (channel == L"dev") {
57    return CHANNEL_DEV;
58  } else if (channel == L"canary") {
59    return CHANNEL_CANARY;
60  }
61#endif
62
63  return CHANNEL_UNKNOWN;
64}
65
66}  // namespace chrome
67