Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9766)

Unified Diff: chrome/common/chrome_version_info_mac.mm

Issue 7249003: Move GetVersionStringModifier() and GetChannel() from platform_util_* to chrome_version_info_* (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Move GetVersionStringModifier() and GetChannel() from platform_util_* to chrome_version_info.cc Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/chrome_version_info_mac.mm
diff --git a/chrome/common/chrome_version_info_mac.mm b/chrome/common/chrome_version_info_mac.mm
new file mode 100644
index 0000000000000000000000000000000000000000..7e257d03d5862e54bb0ef3903a89213b9a3be585
--- /dev/null
+++ b/chrome/common/chrome_version_info_mac.mm
@@ -0,0 +1,63 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/chrome_version_info.h"
+
+#import <Cocoa/Cocoa.h>
+
+#include "base/basictypes.h"
+#include "base/sys_string_conversions.h"
+#include "build/build_config.h"
tony 2011/06/23 16:54:54 Nit: I don't think you need build_config.h here.
haraken1 2011/06/23 23:57:14 Done.
+
+namespace chrome {
+
+// static
+std::string VersionInfo::GetVersionStringModifier() {
+#if defined(GOOGLE_CHROME_BUILD)
+ // Use the main application bundle and not the framework bundle. Keystone
+ // keys don't live in the framework.
+ NSBundle* bundle = [NSBundle mainBundle];
+ NSString* channel = [bundle objectForInfoDictionaryKey:@"KSChannelID"];
+
+ // Only ever return "", "unknown", "beta", "dev", or "canary" in a branded
+ // build.
+ if (![bundle objectForInfoDictionaryKey:@"KSProductID"]) {
+ // This build is not Keystone-enabled, it can't have a channel.
+ channel = @"unknown";
+ } else if (!channel) {
+ // For the stable channel, KSChannelID is not set.
+ channel = @"";
+ } else if ([channel isEqual:@"beta"] ||
+ [channel isEqual:@"dev"] ||
+ [channel isEqual:@"canary"]) {
+ // do nothing.
+ } else {
+ channel = @"unknown";
+ }
+
+ return base::SysNSStringToUTF8(channel);
+#else
+ return std::string();
+#endif
+}
+
+// static
+VersionInfo::Channel VersionInfo::GetChannel() {
+#if defined(GOOGLE_CHROME_BUILD)
+ std::string channel = GetVersionStringModifier();
+ if (channel.empty()) {
+ return CHANNEL_STABLE;
+ } else if (channel == "beta") {
+ return CHANNEL_BETA;
+ } else if (channel == "dev") {
+ return CHANNEL_DEV;
+ } else if (channel == "canary") {
+ return CHANNEL_CANARY;
+ }
+#endif
+
+ return CHANNEL_UNKNOWN;
+}
+
+} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698