summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-25 07:59:08 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-25 07:59:08 +0000
commita302ff0affd0d8a63acf872e740cd4e35ca379de (patch)
tree7564ddadd22ca9670a9db36a679f1a3728f19663
parent51c314d93e949d84cba31c471acf3e094148ce5a (diff)
downloadchromium_src-a302ff0affd0d8a63acf872e740cd4e35ca379de.zip
chromium_src-a302ff0affd0d8a63acf872e740cd4e35ca379de.tar.gz
chromium_src-a302ff0affd0d8a63acf872e740cd4e35ca379de.tar.bz2
Transition to base/mac/bundle_locations.h step 3
Convert some instances of [NSBundle mainBundle] to equivalent calls in base/mac/bundle_locations.h BUG=None TEST=Code should compile and all unit tests should pass. Review URL: http://codereview.chromium.org/9240004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119030 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/mac/mac_util.mm7
-rw-r--r--chrome/browser/mac/install_from_dmg.mm6
-rw-r--r--chrome/browser/mac/keystone_glue.mm9
-rw-r--r--chrome/browser/shell_integration_mac.mm26
-rw-r--r--chrome/browser/ui/cocoa/dock_icon.mm5
-rw-r--r--chrome/common/chrome_version_info_mac.mm9
-rw-r--r--ui/base/l10n/l10n_util_mac.mm5
7 files changed, 35 insertions, 32 deletions
diff --git a/base/mac/mac_util.mm b/base/mac/mac_util.mm
index 2ba1a30..7c020e1 100644
--- a/base/mac/mac_util.mm
+++ b/base/mac/mac_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.
@@ -10,6 +10,7 @@
#include "base/file_path.h"
#include "base/logging.h"
+#include "base/mac/bundle_locations.h"
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/memory/scoped_nsobject.h"
@@ -72,7 +73,7 @@ LSSharedFileListItemRef GetLoginItemForApp() {
scoped_nsobject<NSArray> login_items_array(
CFToNSCast(LSSharedFileListCopySnapshot(login_items, NULL)));
- NSURL* url = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
+ NSURL* url = [NSURL fileURLWithPath:[base::mac::MainBundle() bundlePath]];
for(NSUInteger i = 0; i < [login_items_array count]; ++i) {
LSSharedFileListItemRef item = reinterpret_cast<LSSharedFileListItemRef>(
@@ -416,7 +417,7 @@ void AddToLoginItems(bool hide_on_startup) {
LSSharedFileListItemRemove(login_items, item);
}
- NSURL* url = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
+ NSURL* url = [NSURL fileURLWithPath:[base::mac::MainBundle() bundlePath]];
BOOL hide = hide_on_startup ? YES : NO;
NSDictionary* properties =
diff --git a/chrome/browser/mac/install_from_dmg.mm b/chrome/browser/mac/install_from_dmg.mm
index 6447364..caf05a0 100644
--- a/chrome/browser/mac/install_from_dmg.mm
+++ b/chrome/browser/mac/install_from_dmg.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.
@@ -235,7 +235,7 @@ bool IsPathOnReadOnlyDiskImage(const char path[],
// the disk image's device, in "diskNsM" form.
bool IsAppRunningFromReadOnlyDiskImage(std::string* dmg_bsd_device_name) {
return IsPathOnReadOnlyDiskImage(
- [[[NSBundle mainBundle] bundlePath] fileSystemRepresentation],
+ [[base::mac::OuterBundle() bundlePath] fileSystemRepresentation],
dmg_bsd_device_name);
}
@@ -425,7 +425,7 @@ bool MaybeInstallFromDiskImage() {
return false;
}
- NSString* source_path = [[NSBundle mainBundle] bundlePath];
+ NSString* source_path = [base::mac::OuterBundle() bundlePath];
NSString* application_name = [source_path lastPathComponent];
NSString* target_path =
[application_directory stringByAppendingPathComponent:application_name];
diff --git a/chrome/browser/mac/keystone_glue.mm b/chrome/browser/mac/keystone_glue.mm
index 40a8d00..c0c1cd3 100644
--- a/chrome/browser/mac/keystone_glue.mm
+++ b/chrome/browser/mac/keystone_glue.mm
@@ -14,7 +14,6 @@
#include "base/location.h"
#include "base/logging.h"
#include "base/mac/bundle_locations.h"
-#include "base/mac/foundation_util.h"
#include "base/mac/mac_util.h"
#include "base/mac/scoped_nsautorelease_pool.h"
#include "base/mac/scoped_nsexception_enabler.h"
@@ -262,16 +261,16 @@ NSString* const kVersionKey = @"KSVersion";
}
- (NSDictionary*)infoDictionary {
- // Use [NSBundle mainBundle] to get the application's own bundle identifier
+ // Use base::mac::OuterBundle() to get the Chrome app's own bundle identifier
// and path, not the framework's. For auto-update, the application is
// what's significant here: it's used to locate the outermost part of the
// application for the existence checker and other operations that need to
// see the entire application bundle.
- return [[NSBundle mainBundle] infoDictionary];
+ return [base::mac::OuterBundle() infoDictionary];
}
- (void)loadParameters {
- NSBundle* appBundle = [NSBundle mainBundle];
+ NSBundle* appBundle = base::mac::OuterBundle();
NSDictionary* infoDictionary = [self infoDictionary];
NSString* productID = [infoDictionary objectForKey:@"KSProductID"];
@@ -746,7 +745,7 @@ NSString* const kVersionKey = @"KSVersion";
// authenticating, may actually result in different ownership being applied
// to files and directories.
NSFileManager* fileManager = [NSFileManager defaultManager];
- NSString* executablePath = [[NSBundle mainBundle] executablePath];
+ NSString* executablePath = [base::mac::OuterBundle() executablePath];
NSString* frameworkPath = [base::mac::FrameworkBundle() bundlePath];
return ![fileManager isWritableFileAtPath:appPath_] ||
![fileManager isWritableFileAtPath:executablePath] ||
diff --git a/chrome/browser/shell_integration_mac.mm b/chrome/browser/shell_integration_mac.mm
index be2f6af..8a52d7b 100644
--- a/chrome/browser/shell_integration_mac.mm
+++ b/chrome/browser/shell_integration_mac.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.
@@ -22,9 +22,9 @@ bool ShellIntegration::SetAsDefaultBrowser() {
if (!CanSetAsDefaultBrowser())
return false;
- // We really do want the main bundle here, not base::mac::FrameworkBundle(),
- // which is the bundle for the framework.
- NSString* identifier = [[NSBundle mainBundle] bundleIdentifier];
+ // We really do want the outer bundle here, not the main bundle since setting
+ // a shortcut to Chrome as the default browser doesn't make sense.
+ NSString* identifier = [base::mac::OuterBundle() bundleIdentifier];
if (!identifier)
return false;
@@ -42,9 +42,9 @@ bool ShellIntegration::SetAsDefaultProtocolClient(const std::string& protocol) {
if (!CanSetAsDefaultProtocolClient())
return false;
- // We really do want the main bundle here, not base::mac::FrameworkBundle(),
- // which is the bundle for the framework.
- NSString* identifier = [[NSBundle mainBundle] bundleIdentifier];
+ // We really do want the main bundle here since it makes sense to set an
+ // app shortcut as a default protocol handler.
+ NSString* identifier = [base::mac::MainBundle() bundleIdentifier];
if (!identifier)
return false;
@@ -96,9 +96,9 @@ bool IsIdentifierDefaultProtocolClient(NSString* identifier,
// protocols; we don't want to report "no" here if the user has simply chosen
// to open HTML files in a text editor and FTP links with an FTP client.)
ShellIntegration::DefaultWebClientState ShellIntegration::IsDefaultBrowser() {
- // We really do want the main bundle here, not base::mac::FrameworkBundle(),
- // which is the bundle for the framework.
- NSString* my_identifier = [[NSBundle mainBundle] bundleIdentifier];
+ // We really do want the outer bundle here, since this we want to know the
+ // status of the main Chrome bundle and not a shortcut.
+ NSString* my_identifier = [base::mac::OuterBundle() bundleIdentifier];
if (!my_identifier)
return UNKNOWN_DEFAULT_WEB_CLIENT;
@@ -118,9 +118,9 @@ ShellIntegration::DefaultWebClientState
if (protocol.empty())
return UNKNOWN_DEFAULT_WEB_CLIENT;
- // We really do want the main bundle here, not base::mac::FrameworkBundle(),
- // which is the bundle for the framework.
- NSString* my_identifier = [[NSBundle mainBundle] bundleIdentifier];
+ // We really do want the main bundle here since it makes sense to set an
+ // app shortcut as a default protocol handler.
+ NSString* my_identifier = [base::mac::MainBundle() bundleIdentifier];
if (!my_identifier)
return UNKNOWN_DEFAULT_WEB_CLIENT;
diff --git a/chrome/browser/ui/cocoa/dock_icon.mm b/chrome/browser/ui/cocoa/dock_icon.mm
index 56c32c2..0c98774 100644
--- a/chrome/browser/ui/cocoa/dock_icon.mm
+++ b/chrome/browser/ui/cocoa/dock_icon.mm
@@ -1,9 +1,10 @@
-// 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.
#import "chrome/browser/ui/cocoa/dock_icon.h"
+#include "base/mac/bundle_locations.h"
#include "base/memory/scoped_nsobject.h"
#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
@@ -42,7 +43,7 @@ static const float kBadgeIndent = 5.0f;
- (void)drawRect:(NSRect)dirtyRect {
// Not -[NSApplication applicationIconImage]; that fails to return a pasted
// custom icon.
- NSString* appPath = [[NSBundle mainBundle] bundlePath];
+ NSString* appPath = [base::mac::MainBundle() bundlePath];
NSImage* appIcon = [[NSWorkspace sharedWorkspace] iconForFile:appPath];
[appIcon drawInRect:[self bounds]
fromRect:NSZeroRect
diff --git a/chrome/common/chrome_version_info_mac.mm b/chrome/common/chrome_version_info_mac.mm
index aacfbf3..3db365b 100644
--- a/chrome/common/chrome_version_info_mac.mm
+++ b/chrome/common/chrome_version_info_mac.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.
@@ -7,6 +7,7 @@
#import <Cocoa/Cocoa.h>
#include "base/basictypes.h"
+#include "base/mac/bundle_locations.h"
#include "base/sys_string_conversions.h"
namespace chrome {
@@ -14,9 +15,9 @@ namespace chrome {
// static
std::string VersionInfo::GetVersionStringModifier() {
#if defined(GOOGLE_CHROME_BUILD)
- // Use the main application bundle and not the framework bundle. Keystone
- // keys don't live in the framework.
- NSBundle* bundle = [NSBundle mainBundle];
+ // Use the main Chrome application bundle and not the framework bundle.
+ // Keystone keys don't live in the framework.
+ NSBundle* bundle = base::mac::OuterBundle();
NSString* channel = [bundle objectForInfoDictionaryKey:@"KSChannelID"];
// Only ever return "", "unknown", "beta", "dev", or "canary" in a branded
diff --git a/ui/base/l10n/l10n_util_mac.mm b/ui/base/l10n/l10n_util_mac.mm
index 2e40a8a..d2a1a1e 100644
--- a/ui/base/l10n/l10n_util_mac.mm
+++ b/ui/base/l10n/l10n_util_mac.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.
@@ -7,6 +7,7 @@
#include "base/sys_string_conversions.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
+#include "base/mac/bundle_locations.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/l10n_util_mac.h"
@@ -44,7 +45,7 @@ void OverrideLocaleWithCocoaLocale() {
// "Today" are in the same language as raw dates like "March 20, 1999" (Chrome
// strings resources vs ICU generated strings). This also makes the Mac acts
// like other Chrome platforms.
- NSArray* languageList = [[NSBundle mainBundle] preferredLocalizations];
+ NSArray* languageList = [base::mac::OuterBundle() preferredLocalizations];
NSString* firstLocale = [languageList objectAtIndex:0];
// Mac OS X uses "_" instead of "-", so swap to get a real locale value.
std::string locale_value =