Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/mac/bundle_locations.h" | |
| 6 | |
| 7 namespace base { | |
| 8 namespace mac { | |
| 9 | |
| 10 // No threading worries since NSBundle isn't thread safe. | |
|
Avi (use Gerrit)
2012/01/10 15:37:13
Why do I find this sentence funny? :) Is it worth
Mark Mentovai
2012/01/10 22:09:35
Avi wrote:
jeremy
2012/01/11 07:12:44
This comment is copied from foundation_utils.h , I
Avi (use Gerrit)
2012/01/11 14:44:22
Oh, that's fine. It struck me as absurd that there
| |
| 11 static NSBundle* g_override_launch_bundle = nil; | |
| 12 static NSBundle* g_override_framework_bundle = nil; | |
| 13 static NSBundle* g_override_outer_bundle = nil; | |
| 14 | |
| 15 NSBundle* LaunchBundle() { | |
|
Mark Mentovai
2012/01/10 22:09:35
This name sounds like it’s going to launch a bundl
jeremy
2012/01/11 07:12:44
Yes it does, changing to MainBundle() - other sugg
| |
| 16 if (g_override_launch_bundle) | |
| 17 return g_override_launch_bundle; | |
| 18 return [NSBundle mainBundle]; | |
| 19 } | |
| 20 | |
| 21 FilePath LaunchBundleBundlePath() { | |
|
Mark Mentovai
2012/01/10 22:09:35
This name sounds like you’re stuttering.
jeremy
2012/01/11 07:12:44
Done.
| |
| 22 NSBundle* bundle = LaunchBundle(); | |
| 23 return FilePath([[bundle bundlePath] fileSystemRepresentation]); | |
| 24 } | |
| 25 | |
| 26 NSBundle* OuterBundle() { | |
| 27 if (g_override_outer_bundle) | |
| 28 return g_override_outer_bundle; | |
| 29 return [NSBundle mainBundle]; | |
| 30 } | |
| 31 | |
| 32 FilePath OuterBundlePath() { | |
| 33 NSBundle* bundle = OuterBundle(); | |
| 34 return FilePath([[bundle bundlePath] fileSystemRepresentation]); | |
| 35 } | |
| 36 | |
| 37 NSBundle* FrameworkBundle() { | |
|
Mark Mentovai
2012/01/10 22:09:35
If we have convenience wrappers for the other two
jeremy
2012/01/11 07:12:44
Done.
| |
| 38 if (g_override_framework_bundle) | |
| 39 return g_override_framework_bundle; | |
| 40 return [NSBundle mainBundle]; | |
| 41 } | |
| 42 | |
| 43 static void AssignOverrideBundle(NSBundle* new_bundle, | |
| 44 NSBundle* override_bundle) { | |
| 45 if (new_bundle != override_bundle) { | |
| 46 [override_bundle release]; | |
| 47 override_bundle = [new_bundle retain]; | |
| 48 } | |
| 49 } | |
| 50 | |
| 51 void SetOverrideLaunchBundle(NSBundle* bundle) { | |
| 52 AssignOverrideBundle(bundle, g_override_launch_bundle); | |
| 53 } | |
| 54 | |
| 55 void SetOverrideFrameworkBundle(NSBundle* bundle) { | |
| 56 AssignOverrideBundle(bundle, g_override_framework_bundle); | |
| 57 } | |
| 58 | |
| 59 void SetOverrideOuterBundle(NSBundle* bundle) { | |
| 60 AssignOverrideBundle(bundle, g_override_outer_bundle); | |
| 61 } | |
| 62 | |
| 63 } // namespace mac | |
| 64 } // namespace base | |
| OLD | NEW |