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 #ifndef BASE_MAC_BUNDLE_LOCATIONS_H_ 6 #define BASE_MAC_BUNDLE_LOCATIONS_H_ 7 8 #include "base/files/file_path.h" 9 10 #if defined(__OBJC__) 11 #import <Foundation/Foundation.h> 12 #else // __OBJC__ 13 class NSBundle; 14 #endif // __OBJC__ 15 16 namespace base { 17 18 class FilePath; 19 20 namespace mac { 21 22 // This file provides several functions to explicitly request the various 23 // component bundles of Chrome. Please use these methods rather than calling 24 // +[NSBundle mainBundle] or CFBundleGetMainBundle(). 25 // 26 // Terminology 27 // - "Outer Bundle" - This is the main bundle for Chrome; it's what 28 // +[NSBundle mainBundle] returns when Chrome is launched normally. 29 // 30 // - "Main Bundle" - This is the bundle from which Chrome was launched. 31 // This will be the same as the outer bundle except when Chrome is launched 32 // via an app shortcut, in which case this will return the app shortcut's 33 // bundle rather than the main Chrome bundle. 34 // 35 // - "Framework Bundle" - This is the bundle corresponding to the Chrome 36 // framework. 37 // 38 // Guidelines for use: 39 // - To access a resource, the Framework bundle should be used. 40 // - If the choice is between the Outer or Main bundles then please choose 41 // carefully. Most often the Outer bundle will be the right choice, but for 42 // cases such as adding an app to the "launch on startup" list, the Main 43 // bundle is probably the one to use. 44 45 // Methods for retrieving the various bundles. 46 NSBundle* MainBundle(); 47 FilePath MainBundlePath(); 48 NSBundle* OuterBundle(); 49 FilePath OuterBundlePath(); 50 NSBundle* FrameworkBundle(); 51 FilePath FrameworkBundlePath(); 52 53 // Set the bundle that the preceding functions will return, overriding the 54 // default values. Restore the default by passing in |nil|. 55 void SetOverrideOuterBundle(NSBundle* bundle); 56 void SetOverrideFrameworkBundle(NSBundle* bundle); 57 58 // Same as above but accepting a FilePath argument. 59 void SetOverrideOuterBundlePath(const FilePath& file_path); 60 void SetOverrideFrameworkBundlePath(const FilePath& file_path); 61 62 } // namespace mac 63 } // namespace base 64 65 #endif // BASE_MAC_BUNDLE_LOCATIONS_H_ 66