summaryrefslogtreecommitdiffstats
path: root/chrome/browser/mac
diff options
context:
space:
mode:
authoravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-30 14:24:01 +0000
committeravi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-30 14:24:01 +0000
commitc9c1512e70096a0ce81ac7ebbbcafa2ce8e07205 (patch)
tree4d22f86a5ca128f27a1b856eb1f9e56775517c05 /chrome/browser/mac
parentef7aab90b0ac2ed31fab60c4a280355682015869 (diff)
downloadchromium_src-c9c1512e70096a0ce81ac7ebbbcafa2ce8e07205.zip
chromium_src-c9c1512e70096a0ce81ac7ebbbcafa2ce8e07205.tar.gz
chromium_src-c9c1512e70096a0ce81ac7ebbbcafa2ce8e07205.tar.bz2
Enable brand codes and master preferences on the Mac.
BUG=93421 TEST=alter brand codes and master prefs files; should be read Review URL: http://codereview.chromium.org/7655056 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98811 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/mac')
-rw-r--r--chrome/browser/mac/keystone_glue.h5
-rw-r--r--chrome/browser/mac/keystone_glue.mm15
-rw-r--r--chrome/browser/mac/master_prefs.h20
-rw-r--r--chrome/browser/mac/master_prefs.mm43
4 files changed, 83 insertions, 0 deletions
diff --git a/chrome/browser/mac/keystone_glue.h b/chrome/browser/mac/keystone_glue.h
index 615b5e9..65bdc70 100644
--- a/chrome/browser/mac/keystone_glue.h
+++ b/chrome/browser/mac/keystone_glue.h
@@ -198,6 +198,11 @@ enum BrandFileType {
// Functions that may be accessed from non-Objective-C C/C++ code.
namespace keystone_glue {
+// Returns the brand code of the installation. Note that beta, dev, and canary
+// channels, as well as some stable builds, may have an empty string as a brand
+// code.
+std::string BrandCode();
+
// True if Keystone is enabled.
bool KeystoneEnabled();
diff --git a/chrome/browser/mac/keystone_glue.mm b/chrome/browser/mac/keystone_glue.mm
index 2472312..2b34466 100644
--- a/chrome/browser/mac/keystone_glue.mm
+++ b/chrome/browser/mac/keystone_glue.mm
@@ -9,6 +9,7 @@
#include <vector>
+#include "base/file_util.h"
#include "base/logging.h"
#include "base/mac/mac_util.h"
#include "base/mac/scoped_nsautorelease_pool.h"
@@ -917,6 +918,20 @@ NSString* const kVersionKey = @"KSVersion";
namespace keystone_glue {
+std::string BrandCode() {
+ KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue];
+ NSString* brand_path = [keystoneGlue brandFilePath];
+
+ if (![brand_path length])
+ return std::string();
+
+ std::string brand_code;
+ file_util::ReadFileToString(FilePath([brand_path fileSystemRepresentation]),
+ &brand_code);
+
+ return brand_code;
+}
+
bool KeystoneEnabled() {
return [KeystoneGlue defaultKeystoneGlue] != nil;
}
diff --git a/chrome/browser/mac/master_prefs.h b/chrome/browser/mac/master_prefs.h
new file mode 100644
index 0000000..ce2e330
--- /dev/null
+++ b/chrome/browser/mac/master_prefs.h
@@ -0,0 +1,20 @@
+// 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.
+
+#ifndef CHROME_BROWSER_MAC_MASTER_PREFS_H_
+#define CHROME_BROWSER_MAC_MASTER_PREFS_H_
+#pragma once
+
+#include "base/file_path.h"
+
+namespace master_prefs {
+
+// Returns the path to the master preferences file. Note that this path may be
+// empty (in the case where this type of build cannot have a master preferences
+// file) or may not actually exist on the filesystem.
+FilePath MasterPrefsPath();
+
+} // namespace master_prefs
+
+#endif // CHROME_BROWSER_MAC_MASTER_PREFS_H_
diff --git a/chrome/browser/mac/master_prefs.mm b/chrome/browser/mac/master_prefs.mm
new file mode 100644
index 0000000..dae0f2e
--- /dev/null
+++ b/chrome/browser/mac/master_prefs.mm
@@ -0,0 +1,43 @@
+// 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/browser/mac/master_prefs.h"
+
+#include "base/mac/foundation_util.h"
+#include "chrome/common/chrome_version_info.h"
+
+#if defined(GOOGLE_CHROME_BUILD)
+
+namespace {
+
+const char kGoogleDirectory[] = "Google";
+const char kMasterPreferencesFileName[] = "Google Chrome Master Preferences";
+
+} // namespace
+
+#endif // GOOGLE_CHROME_BUILD
+
+namespace master_prefs {
+
+FilePath MasterPrefsPath() {
+#if defined(GOOGLE_CHROME_BUILD)
+ // There is only a system-level master preferences file, and only for the
+ // official build, and not for the canary.
+ chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
+
+ if (channel == chrome::VersionInfo::CHANNEL_CANARY)
+ return FilePath();
+
+ FilePath library_path;
+ if (!base::mac::GetLocalDirectory(NSLibraryDirectory, &library_path))
+ return FilePath();
+
+ return library_path.Append(kGoogleDirectory)
+ .Append(kMasterPreferencesFileName);
+#else
+ return FilePath();
+#endif // GOOGLE_CHROME_BUILD
+}
+
+} // namespace master_prefs