| 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/browser/platform_util.h" | 5 #include "chrome/browser/platform_util.h" |
| 6 | 6 |
| 7 #include <Carbon/Carbon.h> | 7 #include <Carbon/Carbon.h> |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 #include <CoreServices/CoreServices.h> | 9 #include <CoreServices/CoreServices.h> |
| 10 | 10 |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/mac/scoped_aedesc.h" | 13 #include "base/mac/scoped_aedesc.h" |
| 14 #include "base/sys_string_conversions.h" | 14 #include "base/sys_string_conversions.h" |
| 15 #include "chrome/common/chrome_version_info.h" |
| 15 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
| 16 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 17 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 18 #include "ui/base/l10n/l10n_util_mac.h" | 19 #include "ui/base/l10n/l10n_util_mac.h" |
| 19 | 20 |
| 20 namespace platform_util { | 21 namespace platform_util { |
| 21 | 22 |
| 22 void ShowItemInFolder(const FilePath& full_path) { | 23 void ShowItemInFolder(const FilePath& full_path) { |
| 23 DCHECK_EQ([NSThread currentThread], [NSThread mainThread]); | 24 DCHECK_EQ([NSThread currentThread], [NSThread mainThread]); |
| 24 NSString* path_string = base::SysUTF8ToNSString(full_path.value()); | 25 NSString* path_string = base::SysUTF8ToNSString(full_path.value()); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 174 |
| 174 [alert addButtonWithTitle: | 175 [alert addButtonWithTitle: |
| 175 l10n_util::GetNSString(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL)]; | 176 l10n_util::GetNSString(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL)]; |
| 176 [alert addButtonWithTitle: | 177 [alert addButtonWithTitle: |
| 177 l10n_util::GetNSString(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL)]; | 178 l10n_util::GetNSString(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL)]; |
| 178 | 179 |
| 179 NSInteger result = [alert runModal]; | 180 NSInteger result = [alert runModal]; |
| 180 return result == NSAlertFirstButtonReturn; | 181 return result == NSAlertFirstButtonReturn; |
| 181 } | 182 } |
| 182 | 183 |
| 183 std::string GetVersionStringModifier() { | |
| 184 #if defined(GOOGLE_CHROME_BUILD) | |
| 185 // Use the main application bundle and not the framework bundle. Keystone | |
| 186 // keys don't live in the framework. | |
| 187 NSBundle* bundle = [NSBundle mainBundle]; | |
| 188 NSString* channel = [bundle objectForInfoDictionaryKey:@"KSChannelID"]; | |
| 189 | |
| 190 // Only ever return "", "unknown", "beta", "dev", or "canary" in a branded | |
| 191 // build. | |
| 192 if (![bundle objectForInfoDictionaryKey:@"KSProductID"]) { | |
| 193 // This build is not Keystone-enabled, it can't have a channel. | |
| 194 channel = @"unknown"; | |
| 195 } else if (!channel) { | |
| 196 // For the stable channel, KSChannelID is not set. | |
| 197 channel = @""; | |
| 198 } else if ([channel isEqual:@"beta"] || | |
| 199 [channel isEqual:@"dev"] || | |
| 200 [channel isEqual:@"canary"]) { | |
| 201 // do nothing. | |
| 202 } else { | |
| 203 channel = @"unknown"; | |
| 204 } | |
| 205 | |
| 206 return base::SysNSStringToUTF8(channel); | |
| 207 #else | |
| 208 return std::string(); | |
| 209 #endif | |
| 210 } | |
| 211 | |
| 212 Channel GetChannel() { | |
| 213 #if defined(GOOGLE_CHROME_BUILD) | |
| 214 std::string channel = GetVersionStringModifier(); | |
| 215 if (channel.empty()) { | |
| 216 return CHANNEL_STABLE; | |
| 217 } else if (channel == "beta") { | |
| 218 return CHANNEL_BETA; | |
| 219 } else if (channel == "dev") { | |
| 220 return CHANNEL_DEV; | |
| 221 } else if (channel == "canary") { | |
| 222 return CHANNEL_CANARY; | |
| 223 } | |
| 224 #endif | |
| 225 | |
| 226 return CHANNEL_UNKNOWN; | |
| 227 } | |
| 228 | |
| 229 bool CanSetAsDefaultBrowser() { | 184 bool CanSetAsDefaultBrowser() { |
| 230 return GetChannel() != CHANNEL_CANARY; | 185 return chrome::VersionInfo::GetChannel() != |
| 186 chrome::VersionInfo::CHANNEL_CANARY; |
| 231 } | 187 } |
| 232 | 188 |
| 233 bool CanSetAsDefaultProtocolClient(const std::string& protocol) { | 189 bool CanSetAsDefaultProtocolClient(const std::string& protocol) { |
| 234 return CanSetAsDefaultBrowser(); | 190 return CanSetAsDefaultBrowser(); |
| 235 } | 191 } |
| 236 | 192 |
| 237 } // namespace platform_util | 193 } // namespace platform_util |
| OLD | NEW |