Home | History | Annotate | Download | only in policy
      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 CHROME_BROWSER_POLICY_POLICY_PATH_PARSER_H_
      6 #define CHROME_BROWSER_POLICY_POLICY_PATH_PARSER_H_
      7 
      8 #include <string>
      9 
     10 #include "base/files/file_path.h"
     11 
     12 namespace policy {
     13 
     14 namespace path_parser {
     15 
     16 // This function is used to expand the variables in policy strings that
     17 // represent paths. The set of supported variables differs between platforms
     18 // but generally covers most standard locations that might be needed in the
     19 // existing used cases.
     20 // All platforms:
     21 //   ${user_name}       - The user that is running Chrome (respects suids).
     22 //                        (example : "johndoe")
     23 //   ${machine_name}    - The machine name possibly with domain (example :
     24 //                        "johnny.cg1.cooldomain.org")
     25 // Windows only:
     26 //   ${documents}       - The "Documents" folder for the current user.
     27 //                        (example : "C:\Users\Administrator\Documents")
     28 //   ${local_app_data}  - The Application Data folder for the current user.
     29 //                        (example : "C:\Users\Administrator\AppData\Local")
     30 //   ${roaming_app_data}- The Roamed AppData folder for the current user.
     31 //                        (example : "C:\Users\Administrator\AppData\Roaming")
     32 //   ${profile}         - The home folder for the current user.
     33 //                        (example : "C:\Users\Administrator")
     34 //   ${global_app_data} - The system-wide Application Data folder.
     35 //                        (example : "C:\Users\All Users\AppData")
     36 //   ${program_files}   - The "Program Files" folder for the current process.
     37 //                        Depends on whether it is 32 or 64 bit process.
     38 //                        (example : "C:\Program Files (x86)")
     39 //   ${windows}         - The Windows folder
     40 //                        (example : "C:\WINNT" or "C:\Windows")
     41 // MacOS only:
     42 //   ${users}           - The folder where users profiles are stored
     43 //                        (example : "/Users")
     44 //   ${documents}       - The "Documents" folder of the current user.
     45 //                        (example : "/Users/johndoe/Documents")
     46 // Any non recognized variable is not being translated at all. Variables are
     47 // translated only once in every string because for most of these there is no
     48 // sense in concatenating them more than once in a single path.
     49 base::FilePath::StringType ExpandPathVariables(
     50     const base::FilePath::StringType& untranslated_string);
     51 
     52 // A helper function used to read the UserDataDir path policy without relying on
     53 // any policy infrastructure. This is required because this policy is needed
     54 // much earlier before the PrefService is initialized.
     55 // The function will fill |user_data_dir| if the policy "UserDataDir" is set and
     56 // leave it intact if the policy is missing. If the policy is set it should
     57 // override any manual changes to the profile path the user might have made so
     58 // this function should be used to verify no policy is specified whenever the
     59 // profile path is not read from the PathService which already takes this into
     60 // account.
     61 void CheckUserDataDirPolicy(base::FilePath* user_data_dir);
     62 
     63 }  // namespace path_parser
     64 
     65 }  // namespace policy
     66 
     67 #endif  // CHROME_BROWSER_POLICY_POLICY_PATH_PARSER_H_
     68