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