bundle_locations.h 2.3 KB

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