bundle_locations.h 2.4 KB

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