Index: chrome/browser/mac/keystone_glue.mm |
diff --git a/chrome/browser/mac/keystone_glue.mm b/chrome/browser/mac/keystone_glue.mm |
index 247231207a856cf159b91a6c0d7480ded9ce7e92..42c123a1cedf8eae4fba7323f51b80a0cf68b0c8 100644 |
--- a/chrome/browser/mac/keystone_glue.mm |
+++ b/chrome/browser/mac/keystone_glue.mm |
@@ -41,11 +41,22 @@ namespace ksr = keystone_registration; |
#error Unknown branding |
#endif |
+#if defined(GOOGLE_CHROME_BUILD) |
+#define kMasterPreferencesFileName @"Google Chrome Master Preferences"; |
+#elif defined(CHROMIUM_BUILD) |
+#define kMasterPreferencesFileName @"Chromium Master Preferences"; |
+#else |
+#error Unknown branding |
+#endif |
+ |
// These directories are hardcoded in Keystone promotion preflight and the |
// Keystone install script, so NSSearchPathForDirectoriesInDomains isn't used |
// since the scripts couldn't use anything like that. |
NSString* kBrandUserFile = @"~/Library/Google/" kBrandFileName; |
NSString* kBrandSystemFile = @"/Library/Google/" kBrandFileName; |
+// Only support a system-level master preferences file. |
+NSString* kMasterPreferencesFile |
+ = @"/Library/Google/" kMasterPreferencesFileName; |
NSString* UserBrandFilePath() { |
return [kBrandUserFile stringByStandardizingPath]; |
@@ -917,6 +928,28 @@ NSString* const kVersionKey = @"KSVersion"; |
namespace keystone_glue { |
+FilePath MasterPrefsPath() { |
+ return FilePath([[kMasterPreferencesFile stringByStandardizingPath] |
+ fileSystemRepresentation]); |
+} |
+ |
+std::string BrandCode() { |
+ KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue]; |
+ NSString* brand_path = [keystoneGlue brandFilePath]; |
+ |
+ if (![brand_path length]) |
+ return std::string(); |
+ |
+ NSString* brand_code = |
+ [NSString stringWithContentsOfFile:brand_path |
+ encoding:NSASCIIStringEncoding |
+ error:nil]; |
+ if (!brand_code) |
+ return std::string(); |
+ |
+ return base::SysNSStringToUTF8(brand_code); |
+} |
+ |
bool KeystoneEnabled() { |
return [KeystoneGlue defaultKeystoneGlue] != nil; |
} |