| 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/chrome_version_info.h" | 5 #include "chrome/common/channel_info.h" |
| 6 | 6 |
| 7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/mac/bundle_locations.h" | 10 #include "base/mac/bundle_locations.h" |
| 11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
| 12 #include "components/version_info/version_info.h" |
| 12 | 13 |
| 13 namespace chrome { | 14 namespace chrome { |
| 14 | 15 |
| 15 // static | 16 std::string GetChannelString() { |
| 16 std::string VersionInfo::GetVersionStringModifier() { | |
| 17 #if defined(GOOGLE_CHROME_BUILD) | 17 #if defined(GOOGLE_CHROME_BUILD) |
| 18 // Use the main Chrome application bundle and not the framework bundle. | 18 // Use the main Chrome application bundle and not the framework bundle. |
| 19 // Keystone keys don't live in the framework. | 19 // Keystone keys don't live in the framework. |
| 20 NSBundle* bundle = base::mac::OuterBundle(); | 20 NSBundle* bundle = base::mac::OuterBundle(); |
| 21 NSString* channel = [bundle objectForInfoDictionaryKey:@"KSChannelID"]; | 21 NSString* channel = [bundle objectForInfoDictionaryKey:@"KSChannelID"]; |
| 22 | 22 |
| 23 // Only ever return "", "unknown", "beta", "dev", or "canary" in a branded | 23 // Only ever return "", "unknown", "beta", "dev", or "canary" in a branded |
| 24 // build. | 24 // build. |
| 25 if (![bundle objectForInfoDictionaryKey:@"KSProductID"]) { | 25 if (![bundle objectForInfoDictionaryKey:@"KSProductID"]) { |
| 26 // This build is not Keystone-enabled, it can't have a channel. | 26 // This build is not Keystone-enabled, it can't have a channel. |
| 27 channel = @"unknown"; | 27 channel = @"unknown"; |
| 28 } else if (!channel) { | 28 } else if (!channel) { |
| 29 // For the stable channel, KSChannelID is not set. | 29 // For the stable channel, KSChannelID is not set. |
| 30 channel = @""; | 30 channel = @""; |
| 31 } else if ([channel isEqual:@"beta"] || | 31 } else if ([channel isEqual:@"beta"] || |
| 32 [channel isEqual:@"dev"] || | 32 [channel isEqual:@"dev"] || |
| 33 [channel isEqual:@"canary"]) { | 33 [channel isEqual:@"canary"]) { |
| 34 // do nothing. | 34 // do nothing. |
| 35 } else { | 35 } else { |
| 36 channel = @"unknown"; | 36 channel = @"unknown"; |
| 37 } | 37 } |
| 38 | 38 |
| 39 return base::SysNSStringToUTF8(channel); | 39 return base::SysNSStringToUTF8(channel); |
| 40 #else | 40 #else |
| 41 return std::string(); | 41 return std::string(); |
| 42 #endif | 42 #endif |
| 43 } | 43 } |
| 44 | 44 |
| 45 // static | 45 version_info::Channel GetChannel() { |
| 46 version_info::Channel VersionInfo::GetChannel() { | |
| 47 #if defined(GOOGLE_CHROME_BUILD) | 46 #if defined(GOOGLE_CHROME_BUILD) |
| 48 std::string channel = GetVersionStringModifier(); | 47 std::string channel = GetChannelString(); |
| 49 if (channel.empty()) { | 48 if (channel.empty()) { |
| 50 return version_info::Channel::STABLE; | 49 return version_info::Channel::STABLE; |
| 51 } else if (channel == "beta") { | 50 } else if (channel == "beta") { |
| 52 return version_info::Channel::BETA; | 51 return version_info::Channel::BETA; |
| 53 } else if (channel == "dev") { | 52 } else if (channel == "dev") { |
| 54 return version_info::Channel::DEV; | 53 return version_info::Channel::DEV; |
| 55 } else if (channel == "canary") { | 54 } else if (channel == "canary") { |
| 56 return version_info::Channel::CANARY; | 55 return version_info::Channel::CANARY; |
| 57 } | 56 } |
| 58 #endif | 57 #endif |
| 59 | 58 |
| 60 return version_info::Channel::UNKNOWN; | 59 return version_info::Channel::UNKNOWN; |
| 61 } | 60 } |
| 62 | 61 |
| 63 } // namespace chrome | 62 } // namespace chrome |
| OLD | NEW |