summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-31 20:18:49 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-31 20:18:49 +0000
commit4dfae51bf8db229251104bc71ae14237a5989e1c (patch)
tree9b68c5d3803d389dbb84edd36d9b1e4f5afded03 /base
parentcb69ca0e206805c4a4a4cdef2db44fb196820c2a (diff)
downloadchromium_src-4dfae51bf8db229251104bc71ae14237a5989e1c.zip
chromium_src-4dfae51bf8db229251104bc71ae14237a5989e1c.tar.gz
chromium_src-4dfae51bf8db229251104bc71ae14237a5989e1c.tar.bz2
First cut at Safari Import - Home Page & History Only.
Review URL: http://codereview.chromium.org/159668 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22179 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/mac_util.h3
-rw-r--r--base/mac_util.mm14
-rw-r--r--base/mac_util_unittest.cc7
3 files changed, 24 insertions, 0 deletions
diff --git a/base/mac_util.h b/base/mac_util.h
index 371aa9e..43f0e5c 100644
--- a/base/mac_util.h
+++ b/base/mac_util.h
@@ -29,6 +29,9 @@ bool AmIBundled();
// aren't a bundle.
NSBundle* MainAppBundle();
+// Returns the ~/Library directory.
+FilePath GetUserLibraryPath();
+
// Set the bundle that MainAppBundle will return, overriding the default value
// (Restore the default by calling SetOverrideAppBundle(nil)).
void SetOverrideAppBundle(NSBundle* bundle);
diff --git a/base/mac_util.mm b/base/mac_util.mm
index 156cb1c..5304b75 100644
--- a/base/mac_util.mm
+++ b/base/mac_util.mm
@@ -53,6 +53,20 @@ NSBundle* MainAppBundle() {
return [NSBundle mainBundle];
}
+FilePath GetUserLibraryPath() {
+ NSArray* dirs = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
+ NSUserDomainMask, YES);
+ if ([dirs count] == 0)
+ return FilePath();
+
+ NSString* library_dir = [dirs objectAtIndex:0];
+ const char* library_dir_path = [library_dir fileSystemRepresentation];
+ if (!library_dir_path)
+ return FilePath();
+
+ return FilePath(library_dir_path);
+}
+
void SetOverrideAppBundle(NSBundle* bundle) {
[g_override_app_bundle release];
g_override_app_bundle = [bundle retain];
diff --git a/base/mac_util_unittest.cc b/base/mac_util_unittest.cc
index 538b1e7..18b8b5e 100644
--- a/base/mac_util_unittest.cc
+++ b/base/mac_util_unittest.cc
@@ -6,6 +6,7 @@
#include <ApplicationServices/ApplicationServices.h>
+#include "base/file_path.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -18,3 +19,9 @@ TEST_F(MacUtilTest, TestFSRef) {
ASSERT_TRUE(mac_util::FSRefFromPath(path, &ref));
EXPECT_EQ(path, mac_util::PathFromFSRef(ref));
}
+
+TEST_F(MacUtilTest, TestLibraryPath) {
+ FilePath library_dir = mac_util::GetUserLibraryPath();
+ // Make sure the string isn't empty.
+ EXPECT_FALSE(library_dir.value().empty());
+}