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