Fix crash after Launcher drag/drop (take 3 - no unit test)
[chromium-blink-merge.git] / chrome / common / chrome_version_info_win.cc
blob9f59580785b2e81506693277abe4b937fc4292f9
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.
5 #include "chrome/common/chrome_version_info.h"
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"
16 namespace chrome {
18 // static
19 std::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 = !InstallUtil::IsPerUserInstall(module);
25 GoogleUpdateSettings::GetChromeChannelAndModifiers(is_system_install,
26 &channel);
28 #if defined(SYZYASAN)
29 if (base::debug::IsBinaryInstrumented())
30 channel += L" SyzyASan";
31 #endif
32 return base::UTF16ToASCII(channel);
33 #else
34 return std::string();
35 #endif
38 // static
39 VersionInfo::Channel VersionInfo::GetChannel() {
40 #if defined(GOOGLE_CHROME_BUILD)
41 std::wstring channel(L"unknown");
43 base::FilePath module;
44 if (PathService::Get(base::FILE_MODULE, &module)) {
45 bool is_system_install = !InstallUtil::IsPerUserInstall(module);
46 channel = GoogleUpdateSettings::GetChromeChannel(is_system_install);
49 if (channel.empty()) {
50 return CHANNEL_STABLE;
51 } else if (channel == L"beta") {
52 return CHANNEL_BETA;
53 } else if (channel == L"dev") {
54 return CHANNEL_DEV;
55 } else if (channel == L"canary") {
56 return CHANNEL_CANARY;
58 #endif
60 return CHANNEL_UNKNOWN;
63 } // namespace chrome