OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/android/build_info.h" | 7 #include "base/android/build_info.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "components/version_info/channel_android.h" |
10 #include "components/version_info/version_info.h" | 11 #include "components/version_info/version_info.h" |
11 | 12 |
12 namespace chrome { | 13 namespace chrome { |
13 | 14 |
14 std::string GetChannelString() { | 15 std::string GetChannelString() { |
15 switch (GetChannel()) { | 16 switch (GetChannel()) { |
16 case version_info::Channel::UNKNOWN: return "unknown"; | 17 case version_info::Channel::UNKNOWN: return "unknown"; |
17 case version_info::Channel::CANARY: return "canary"; | 18 case version_info::Channel::CANARY: return "canary"; |
18 case version_info::Channel::DEV: return "dev"; | 19 case version_info::Channel::DEV: return "dev"; |
19 case version_info::Channel::BETA: return "beta"; | 20 case version_info::Channel::BETA: return "beta"; |
20 case version_info::Channel::STABLE: return std::string(); | 21 case version_info::Channel::STABLE: return std::string(); |
21 } | 22 } |
22 NOTREACHED() << "Unknown channel " << static_cast<int>(GetChannel()); | 23 NOTREACHED() << "Unknown channel " << static_cast<int>(GetChannel()); |
23 return std::string(); | 24 return std::string(); |
24 } | 25 } |
25 | 26 |
26 version_info::Channel GetChannel() { | 27 version_info::Channel GetChannel() { |
27 const base::android::BuildInfo* bi = base::android::BuildInfo::GetInstance(); | 28 const base::android::BuildInfo* bi = base::android::BuildInfo::GetInstance(); |
28 DCHECK(bi && bi->package_name()); | 29 DCHECK(bi && bi->package_name()); |
29 | 30 return version_info::ChannelFromPackageName(bi->package_name()); |
30 if (!strcmp(bi->package_name(), "com.android.chrome") || | |
31 !strcmp(bi->package_name(), "com.chrome.work")) | |
32 return version_info::Channel::STABLE; | |
33 if (!strcmp(bi->package_name(), "com.chrome.beta")) | |
34 return version_info::Channel::BETA; | |
35 if (!strcmp(bi->package_name(), "com.chrome.dev")) | |
36 return version_info::Channel::DEV; | |
37 if (!strcmp(bi->package_name(), "com.chrome.canary")) | |
38 return version_info::Channel::CANARY; | |
39 | |
40 return version_info::Channel::UNKNOWN; | |
41 } | 31 } |
42 | 32 |
43 } // namespace chrome | 33 } // namespace chrome |
OLD | NEW |