summaryrefslogtreecommitdiffstats
path: root/base/mac
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 10:55:58 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 10:55:58 +0000
commitb0a28ee99b0d3b7c237f449824ad695a61bec37b (patch)
tree63ee34dce4291ed9313e8806ce9afbd5f226852d /base/mac
parenta6ec730208e3704030f0d26afa6a7351e1b54425 (diff)
downloadchromium_src-b0a28ee99b0d3b7c237f449824ad695a61bec37b.zip
chromium_src-b0a28ee99b0d3b7c237f449824ad695a61bec37b.tar.gz
chromium_src-b0a28ee99b0d3b7c237f449824ad695a61bec37b.tar.bz2
Transition to base/mac/bundle_locations.h step 1
Initial transition steps, trying to do this in small steps so it's easier to review. foundation_util.h: * Remove SetOverride*() methods and modify all callsites to use bundle_location.h version. * MainAppBundle() - call through to bundle_location version as an interim step. * Rename PathForFrameworkBundleResource() and modify callers. * Remove one instance of [NSBundle mainBundle]. BUG=None TEST=Chrome/Mac should launch correctly and all unit tests should pass. Review URL: http://codereview.chromium.org/9187053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118284 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/mac')
-rw-r--r--base/mac/foundation_util.h11
-rw-r--r--base/mac/foundation_util.mm39
2 files changed, 12 insertions, 38 deletions
diff --git a/base/mac/foundation_util.h b/base/mac/foundation_util.h
index 1a87470..580680c 100644
--- a/base/mac/foundation_util.h
+++ b/base/mac/foundation_util.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -49,13 +49,8 @@ BASE_EXPORT bool IsBackgroundOnlyProcess();
BASE_EXPORT NSBundle* MainAppBundle();
BASE_EXPORT FilePath MainAppBundlePath();
-// Returns the path to a resource within the MainAppBundle.
-FilePath PathForMainAppBundleResource(CFStringRef resourceName);
-
-// Set the bundle that MainAppBundle will return, overriding the default value
-// (Restore the default by calling SetOverrideAppBundle(nil)).
-BASE_EXPORT void SetOverrideAppBundle(NSBundle* bundle);
-BASE_EXPORT void SetOverrideAppBundlePath(const FilePath& file_path);
+// Returns the path to a resource within the framework bundle.
+FilePath PathForFrameworkBundleResource(CFStringRef resourceName);
// Returns the creator code associated with the CFBundleRef at bundle.
OSType CreatorCodeForCFBundleRef(CFBundleRef bundle);
diff --git a/base/mac/foundation_util.mm b/base/mac/foundation_util.mm
index f1d277a..519af45 100644
--- a/base/mac/foundation_util.mm
+++ b/base/mac/foundation_util.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -9,6 +9,7 @@
#include "base/file_path.h"
#include "base/logging.h"
+#include "base/mac/bundle_locations.h"
#include "base/sys_string_conversions.h"
namespace base {
@@ -61,29 +62,22 @@ void SetOverrideAmIBundled(bool value) {
bool IsBackgroundOnlyProcess() {
// This function really does want to examine NSBundle's idea of the main
- // bundle dictionary, and not the overriden MainAppBundle. It needs to look
- // at the actual running .app's Info.plist to access its LSUIElement
- // property.
- NSDictionary* info_dictionary = [[NSBundle mainBundle] infoDictionary];
+ // bundle dictionary. It needs to look at the actual running .app's
+ // Info.plist to access its LSUIElement property.
+ NSDictionary* info_dictionary = [base::mac::MainBundle() infoDictionary];
return [[info_dictionary objectForKey:@"LSUIElement"] boolValue] != NO;
}
-// No threading worries since NSBundle isn't thread safe.
-static NSBundle* g_override_app_bundle = nil;
-
NSBundle* MainAppBundle() {
- if (g_override_app_bundle)
- return g_override_app_bundle;
- return [NSBundle mainBundle];
+ return base::mac::FrameworkBundle();
}
FilePath MainAppBundlePath() {
- NSBundle* bundle = MainAppBundle();
- return FilePath([[bundle bundlePath] fileSystemRepresentation]);
+ return base::mac::FrameworkBundlePath();
}
-FilePath PathForMainAppBundleResource(CFStringRef resourceName) {
- NSBundle* bundle = MainAppBundle();
+FilePath PathForFrameworkBundleResource(CFStringRef resourceName) {
+ NSBundle* bundle = base::mac::FrameworkBundle();
NSString* resourcePath = [bundle pathForResource:(NSString*)resourceName
ofType:nil];
if (!resourcePath)
@@ -91,21 +85,6 @@ FilePath PathForMainAppBundleResource(CFStringRef resourceName) {
return FilePath([resourcePath fileSystemRepresentation]);
}
-void SetOverrideAppBundle(NSBundle* bundle) {
- if (bundle != g_override_app_bundle) {
- [g_override_app_bundle release];
- g_override_app_bundle = [bundle retain];
- }
-}
-
-void SetOverrideAppBundlePath(const FilePath& file_path) {
- NSString* path = base::SysUTF8ToNSString(file_path.value());
- NSBundle* bundle = [NSBundle bundleWithPath:path];
- DCHECK(bundle) << "Failed to load the bundle at " << file_path.value();
-
- SetOverrideAppBundle(bundle);
-}
-
OSType CreatorCodeForCFBundleRef(CFBundleRef bundle) {
OSType creator = kUnknownType;
CFBundleGetPackageInfo(bundle, NULL, &creator);