| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/common/channel_info.h" | 5 #include "chrome/common/channel_info.h" |
| 6 | 6 |
| 7 #include "base/base_paths.h" | |
| 8 #include "base/debug/profiler.h" | 7 #include "base/debug/profiler.h" |
| 9 #include "base/files/file_path.h" | |
| 10 #include "base/path_service.h" | |
| 11 #include "base/profiler/scoped_tracker.h" | 8 #include "base/profiler/scoped_tracker.h" |
| 12 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/installer/util/google_update_settings.h" | 11 #include "chrome/install_static/install_details.h" |
| 15 #include "chrome/installer/util/install_util.h" | |
| 16 #include "components/version_info/version_info.h" | 12 #include "components/version_info/version_info.h" |
| 17 | 13 |
| 18 namespace chrome { | 14 namespace chrome { |
| 19 | 15 |
| 20 std::string GetChannelString() { | 16 std::string GetChannelString() { |
| 21 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is | 17 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is |
| 22 // fixed. | 18 // fixed. |
| 23 tracked_objects::ScopedTracker tracking_profile( | 19 tracked_objects::ScopedTracker tracking_profile( |
| 24 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 20 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 25 "422460 VersionInfo::GetVersionStringModifier")); | 21 "422460 VersionInfo::GetVersionStringModifier")); |
| 26 | 22 |
| 27 #if defined(GOOGLE_CHROME_BUILD) | 23 #if defined(GOOGLE_CHROME_BUILD) |
| 28 base::FilePath module; | 24 base::string16 channel(install_static::InstallDetails::Get().channel()); |
| 29 base::string16 channel; | |
| 30 if (PathService::Get(base::FILE_MODULE, &module)) { | |
| 31 bool is_system_install = !InstallUtil::IsPerUserInstall(module); | |
| 32 channel = GoogleUpdateSettings::GetChromeChannel(is_system_install); | |
| 33 } | |
| 34 #if defined(SYZYASAN) | 25 #if defined(SYZYASAN) |
| 35 if (base::debug::IsBinaryInstrumented()) | 26 if (base::debug::IsBinaryInstrumented()) |
| 36 channel += L" SyzyASan"; | 27 channel += L" SyzyASan"; |
| 37 #endif | 28 #endif |
| 38 return base::UTF16ToASCII(channel); | 29 return base::UTF16ToASCII(channel); |
| 39 #else | 30 #else |
| 40 return std::string(); | 31 return std::string(); |
| 41 #endif | 32 #endif |
| 42 } | 33 } |
| 43 | 34 |
| 44 version_info::Channel GetChannel() { | 35 version_info::Channel GetChannel() { |
| 45 #if defined(GOOGLE_CHROME_BUILD) | 36 #if defined(GOOGLE_CHROME_BUILD) |
| 46 std::wstring channel(L"unknown"); | 37 base::string16 channel(install_static::InstallDetails::Get().channel()); |
| 47 | |
| 48 base::FilePath module; | |
| 49 if (PathService::Get(base::FILE_MODULE, &module)) { | |
| 50 bool is_system_install = !InstallUtil::IsPerUserInstall(module); | |
| 51 channel = GoogleUpdateSettings::GetChromeChannel(is_system_install); | |
| 52 } | |
| 53 | 38 |
| 54 if (channel.empty()) { | 39 if (channel.empty()) { |
| 55 return version_info::Channel::STABLE; | 40 return version_info::Channel::STABLE; |
| 56 } else if (channel == L"beta") { | 41 } else if (channel == L"beta") { |
| 57 return version_info::Channel::BETA; | 42 return version_info::Channel::BETA; |
| 58 } else if (channel == L"dev") { | 43 } else if (channel == L"dev") { |
| 59 return version_info::Channel::DEV; | 44 return version_info::Channel::DEV; |
| 60 } else if (channel == L"canary") { | 45 } else if (channel == L"canary") { |
| 61 return version_info::Channel::CANARY; | 46 return version_info::Channel::CANARY; |
| 62 } | 47 } |
| 63 #endif | 48 #endif |
| 64 | 49 |
| 65 return version_info::Channel::UNKNOWN; | 50 return version_info::Channel::UNKNOWN; |
| 66 } | 51 } |
| 67 | 52 |
| 68 } // namespace chrome | 53 } // namespace chrome |
| OLD | NEW |