| 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 #import "chrome/browser/mac/keystone_glue.h" | 5 #import "chrome/browser/mac/keystone_glue.h" |
| 6 | 6 |
| 7 #include <sys/param.h> | 7 #include <sys/param.h> |
| 8 #include <sys/mount.h> | 8 #include <sys/mount.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // updates to Chrome.) | 34 // updates to Chrome.) |
| 35 | 35 |
| 36 #if defined(GOOGLE_CHROME_BUILD) | 36 #if defined(GOOGLE_CHROME_BUILD) |
| 37 #define kBrandFileName @"Google Chrome Brand.plist"; | 37 #define kBrandFileName @"Google Chrome Brand.plist"; |
| 38 #elif defined(CHROMIUM_BUILD) | 38 #elif defined(CHROMIUM_BUILD) |
| 39 #define kBrandFileName @"Chromium Brand.plist"; | 39 #define kBrandFileName @"Chromium Brand.plist"; |
| 40 #else | 40 #else |
| 41 #error Unknown branding | 41 #error Unknown branding |
| 42 #endif | 42 #endif |
| 43 | 43 |
| 44 #if defined(GOOGLE_CHROME_BUILD) |
| 45 #define kMasterPreferencesFileName @"Google Chrome Master Preferences"; |
| 46 #elif defined(CHROMIUM_BUILD) |
| 47 #define kMasterPreferencesFileName @"Chromium Master Preferences"; |
| 48 #else |
| 49 #error Unknown branding |
| 50 #endif |
| 51 |
| 44 // These directories are hardcoded in Keystone promotion preflight and the | 52 // These directories are hardcoded in Keystone promotion preflight and the |
| 45 // Keystone install script, so NSSearchPathForDirectoriesInDomains isn't used | 53 // Keystone install script, so NSSearchPathForDirectoriesInDomains isn't used |
| 46 // since the scripts couldn't use anything like that. | 54 // since the scripts couldn't use anything like that. |
| 47 NSString* kBrandUserFile = @"~/Library/Google/" kBrandFileName; | 55 NSString* kBrandUserFile = @"~/Library/Google/" kBrandFileName; |
| 48 NSString* kBrandSystemFile = @"/Library/Google/" kBrandFileName; | 56 NSString* kBrandSystemFile = @"/Library/Google/" kBrandFileName; |
| 57 // Only support a system-level master preferences file. |
| 58 NSString* kMasterPreferencesFile |
| 59 = @"/Library/Google/" kMasterPreferencesFileName; |
| 49 | 60 |
| 50 NSString* UserBrandFilePath() { | 61 NSString* UserBrandFilePath() { |
| 51 return [kBrandUserFile stringByStandardizingPath]; | 62 return [kBrandUserFile stringByStandardizingPath]; |
| 52 } | 63 } |
| 53 NSString* SystemBrandFilePath() { | 64 NSString* SystemBrandFilePath() { |
| 54 return [kBrandSystemFile stringByStandardizingPath]; | 65 return [kBrandSystemFile stringByStandardizingPath]; |
| 55 } | 66 } |
| 56 | 67 |
| 57 // Adaptor for scheduling an Objective-C method call on a |WorkerPool| | 68 // Adaptor for scheduling an Objective-C method call on a |WorkerPool| |
| 58 // thread. | 69 // thread. |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 if (appPath != appPath_) { | 921 if (appPath != appPath_) { |
| 911 [appPath_ release]; | 922 [appPath_ release]; |
| 912 appPath_ = [appPath copy]; | 923 appPath_ = [appPath copy]; |
| 913 } | 924 } |
| 914 } | 925 } |
| 915 | 926 |
| 916 @end // @implementation KeystoneGlue | 927 @end // @implementation KeystoneGlue |
| 917 | 928 |
| 918 namespace keystone_glue { | 929 namespace keystone_glue { |
| 919 | 930 |
| 931 FilePath MasterPrefsPath() { |
| 932 return FilePath([[kMasterPreferencesFile stringByStandardizingPath] |
| 933 fileSystemRepresentation]); |
| 934 } |
| 935 |
| 936 std::string BrandCode() { |
| 937 KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue]; |
| 938 NSString* brand_path = [keystoneGlue brandFilePath]; |
| 939 |
| 940 if (![brand_path length]) |
| 941 return std::string(); |
| 942 |
| 943 NSString* brand_code = |
| 944 [NSString stringWithContentsOfFile:brand_path |
| 945 encoding:NSASCIIStringEncoding |
| 946 error:nil]; |
| 947 if (!brand_code) |
| 948 return std::string(); |
| 949 |
| 950 return base::SysNSStringToUTF8(brand_code); |
| 951 } |
| 952 |
| 920 bool KeystoneEnabled() { | 953 bool KeystoneEnabled() { |
| 921 return [KeystoneGlue defaultKeystoneGlue] != nil; | 954 return [KeystoneGlue defaultKeystoneGlue] != nil; |
| 922 } | 955 } |
| 923 | 956 |
| 924 string16 CurrentlyInstalledVersion() { | 957 string16 CurrentlyInstalledVersion() { |
| 925 KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue]; | 958 KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue]; |
| 926 NSString* version = [keystoneGlue currentlyInstalledVersion]; | 959 NSString* version = [keystoneGlue currentlyInstalledVersion]; |
| 927 return base::SysNSStringToUTF16(version); | 960 return base::SysNSStringToUTF16(version); |
| 928 } | 961 } |
| 929 | 962 |
| 930 } // namespace keystone_glue | 963 } // namespace keystone_glue |
| OLD | NEW |