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