diff options
author | kaliamoorthi@chromium.org <kaliamoorthi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-24 22:50:30 +0000 |
---|---|---|
committer | kaliamoorthi@chromium.org <kaliamoorthi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-24 22:50:30 +0000 |
commit | a0efc91acf36dce8fe32c3760bc64d11d01a16cf (patch) | |
tree | 36dd1af4674702c1fdec8f95754314cad7f6e181 | |
parent | 5e1502eaadb2525b3bf963ee2d34852b68c3cb4a (diff) | |
download | chromium_src-a0efc91acf36dce8fe32c3760bc64d11d01a16cf.zip chromium_src-a0efc91acf36dce8fe32c3760bc64d11d01a16cf.tar.gz chromium_src-a0efc91acf36dce8fe32c3760bc64d11d01a16cf.tar.bz2 |
Refactorise the policy_path_parser framework
This CL performs a refactorisation of the policy path parser framework.
BUG=352627
Review URL: https://codereview.chromium.org/204463005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259049 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/policy/policy_path_parser.cc | 79 | ||||
-rw-r--r-- | chrome/browser/policy/policy_path_parser.h | 23 | ||||
-rw-r--r-- | chrome/browser/policy/policy_path_parser_linux.cc | 66 | ||||
-rw-r--r-- | chrome/browser/policy/policy_path_parser_mac.mm | 121 | ||||
-rw-r--r-- | chrome/browser/policy/policy_path_parser_unittest.cc | 52 | ||||
-rw-r--r-- | chrome/browser/policy/policy_path_parser_win.cc | 173 | ||||
-rw-r--r-- | chrome/policy.gypi | 1 |
7 files changed, 320 insertions, 195 deletions
diff --git a/chrome/browser/policy/policy_path_parser.cc b/chrome/browser/policy/policy_path_parser.cc new file mode 100644 index 0000000..e0ad428 --- /dev/null +++ b/chrome/browser/policy/policy_path_parser.cc @@ -0,0 +1,79 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/policy/policy_path_parser.h" + +#include "base/bind.h" +#include "base/files/file_path.h" + +namespace { + +void TrimQuotes(base::FilePath::StringType* path) { + if (path->length() > 1 && + (((*path)[0] == FILE_PATH_LITERAL('"') && + (*path)[path->length() - 1] == FILE_PATH_LITERAL('"')) || + ((*path)[0] == FILE_PATH_LITERAL('\'') && + (*path)[path->length() - 1] == FILE_PATH_LITERAL('\'')))) { + // Strip first and last char which should be matching quotes now. + *path = path->substr(1, path->length() - 2); + } +} + +} // namespace + +namespace policy { + +namespace path_parser { + +namespace internal { + +VariableNameAndValueCallback::VariableNameAndValueCallback( + const base::FilePath::CharType* name, + const internal::GetValueCallback value_callback) + : name(name), value_callback(value_callback) {} + +VariableNameAndValueCallback::~VariableNameAndValueCallback() {} + +} // namespace internal + +// This function performs a lazy call to the GetValueCallback, that is the +// callback is invoked only if the variable is found in the path. This is done +// to reduce the overhead during initialization. +void ReplaceVariableInPathWithValue( + const base::FilePath::StringType& variable, + const policy::path_parser::internal::GetValueCallback& value_callback, + base::FilePath::StringType* path) { + size_t position = path->find(variable); + base::FilePath::StringType value; + if (position != base::FilePath::StringType::npos && + value_callback.Run(&value)) + path->replace(position, variable.length(), value); +} + +// Replaces all variable occurrences in the policy string with the respective +// system settings values. +base::FilePath::StringType ExpandPathVariables( + const base::FilePath::StringType& untranslated_string) { + base::FilePath::StringType result(untranslated_string); + + if (result.length() == 0) + return result; + + // Sanitize quotes in case of any around the whole string. + TrimQuotes(&result); + + for (int i = 0; i < internal::kNoOfVariables; ++i) { + ReplaceVariableInPathWithValue( + base::FilePath::StringType( + internal::kVariableNameAndValueCallbacks[i].name), + internal::kVariableNameAndValueCallbacks[i].value_callback, + &result); + } + + return result; +} + +} // namespace path_parser + +} // namespace policy diff --git a/chrome/browser/policy/policy_path_parser.h b/chrome/browser/policy/policy_path_parser.h index 5bf0345..e3e60dc 100644 --- a/chrome/browser/policy/policy_path_parser.h +++ b/chrome/browser/policy/policy_path_parser.h @@ -7,12 +7,35 @@ #include <string> +#include "base/bind.h" #include "base/files/file_path.h" namespace policy { namespace path_parser { +namespace internal { + +typedef base::Callback<bool(base::FilePath::StringType*)> GetValueCallback; + +struct VariableNameAndValueCallback { + VariableNameAndValueCallback(const base::FilePath::CharType* name, + const GetValueCallback value_callback); + virtual ~VariableNameAndValueCallback(); + + const base::FilePath::CharType* name; + const GetValueCallback value_callback; +}; + +// Different set of variables are supported in each platform (see below). Hence +// this table is filled in with different elements in each platform. +extern const VariableNameAndValueCallback kVariableNameAndValueCallbacks[]; + +// Since the number of elements in the table could vary for each platform, this +// variable is used to keep track of it. +extern const int kNoOfVariables; +} + // This function is used to expand the variables in policy strings that // represent paths. The set of supported variables differs between platforms // but generally covers most standard locations that might be needed in the diff --git a/chrome/browser/policy/policy_path_parser_linux.cc b/chrome/browser/policy/policy_path_parser_linux.cc index e0bed09..452dc12 100644 --- a/chrome/browser/policy/policy_path_parser_linux.cc +++ b/chrome/browser/policy/policy_path_parser_linux.cc @@ -8,51 +8,49 @@ #include "chrome/browser/policy/policy_path_parser.h" +#include "base/bind.h" #include "base/logging.h" namespace policy { namespace path_parser { +namespace internal { + const char* kMachineNamePolicyVarName = "${machine_name}"; const char* kUserNamePolicyVarName = "${user_name}"; -// Replaces all variable occurrences in the policy string with the respective -// system settings values. -base::FilePath::StringType ExpandPathVariables( - const base::FilePath::StringType& untranslated_string) { - base::FilePath::StringType result(untranslated_string); - if (result.length() == 0) - return result; - // Sanitize quotes in case of any around the whole string. - if (result.length() > 1 && - ((result[0] == '"' && result[result.length() - 1] == '"') || - (result[0] == '\'' && result[result.length() - 1] == '\''))) { - // Strip first and last char which should be matching quotes now. - result = result.substr(1, result.length() - 2); - } - // Translate two special variables ${user_name} and ${machine_name} - size_t position = result.find(kUserNamePolicyVarName); - if (position != std::string::npos) { - struct passwd* user = getpwuid(geteuid()); - if (user) { - result.replace(position, strlen(kUserNamePolicyVarName), user->pw_name); - } else { - LOG(ERROR) << "Username variable can not be resolved. "; - } - } - position = result.find(kMachineNamePolicyVarName); - if (position != std::string::npos) { - char machinename[255]; - if (gethostname(machinename, 255) == 0) { - result.replace(position, strlen(kMachineNamePolicyVarName), machinename); - } else { - LOG(ERROR) << "Machine name variable can not be resolved."; - } - } - return result; +bool GetUserName(base::FilePath::StringType* value) { + struct passwd* user = getpwuid(geteuid()); + if (user) + *value = base::FilePath::StringType(user->pw_name); + else + LOG(ERROR) << "Username variable can not be resolved. "; + return (user != NULL); +} + +bool GetMachineName(base::FilePath::StringType* value) { + char machinename[255]; + int status; + if ((status = gethostname(machinename, 255)) == 0) + *value = base::FilePath::StringType(machinename); + else + LOG(ERROR) << "Machine name variable can not be resolved."; + return (status == 0); } +// A table mapping variable name to their respective getvalue callbacks. +const VariableNameAndValueCallback kVariableNameAndValueCallbacks[] = { + VariableNameAndValueCallback(kUserNamePolicyVarName, + base::Bind(&GetUserName)), + VariableNameAndValueCallback(kMachineNamePolicyVarName, + base::Bind(&GetMachineName))}; + +// Total number of entries in the mapping table. +const int kNoOfVariables = arraysize(kVariableNameAndValueCallbacks); + +} // namespace internal + void CheckUserDataDirPolicy(base::FilePath* user_data_dir) { // This function is not implemented in Linux because we don't support the // policy on this platform. diff --git a/chrome/browser/policy/policy_path_parser_mac.mm b/chrome/browser/policy/policy_path_parser_mac.mm index b734faa3..797e307 100644 --- a/chrome/browser/policy/policy_path_parser_mac.mm +++ b/chrome/browser/policy/policy_path_parser_mac.mm @@ -4,7 +4,7 @@ #include "chrome/browser/policy/policy_path_parser.h" -#include "base/basictypes.h" +#include "base/bind.h" #include "base/files/file_path.h" #include "base/logging.h" #import "base/mac/scoped_nsautorelease_pool.h" @@ -21,78 +21,63 @@ namespace policy { namespace path_parser { +namespace internal { + +bool GetFolder(NSSearchPathDirectory id, base::FilePath::StringType* value) { + NSArray* searchpaths = + NSSearchPathForDirectoriesInDomains(id, NSAllDomainsMask, true); + if ([searchpaths count] > 0) { + NSString* variable_value = [searchpaths objectAtIndex:0]; + *value = base::SysNSStringToUTF8(variable_value); + return true; + } + return false; +} + +bool GetUserName(base::FilePath::StringType* value) { + NSString* username = NSUserName(); + if (username) + *value = base::SysNSStringToUTF8(username); + else + LOG(ERROR) << "Username variable can not be resolved."; + return (username != NULL); +} + +bool GetMachineName(base::FilePath::StringType* value) { + SCDynamicStoreContext context = {0, NULL, NULL, NULL}; + SCDynamicStoreRef store = SCDynamicStoreCreate( + kCFAllocatorDefault, CFSTR("policy_subsystem"), NULL, &context); + CFStringRef machinename = SCDynamicStoreCopyLocalHostName(store); + if (machinename) { + *value = base::SysCFStringRefToUTF8(machinename); + CFRelease(machinename); + } else { + LOG(ERROR) << "Machine name variable can not be resolved."; + } + CFRelease(store); + return (machinename != NULL); +} + const char* kUserNamePolicyVarName = "${user_name}"; const char* kMachineNamePolicyVarName = "${machine_name}"; const char* kMacUsersDirectory = "${users}"; const char* kMacDocumentsFolderVarName = "${documents}"; -struct MacFolderNamesToSPDMaping { - const char* name; - NSSearchPathDirectory id; -}; - -// Mapping from variable names to MacOS NSSearchPathDirectory ids. -const MacFolderNamesToSPDMaping mac_folder_mapping[] = { - { kMacUsersDirectory, NSUserDirectory}, - { kMacDocumentsFolderVarName, NSDocumentDirectory} -}; - -// Replaces all variable occurrences in the policy string with the respective -// system settings values. -base::FilePath::StringType ExpandPathVariables( - const base::FilePath::StringType& untranslated_string) { - base::FilePath::StringType result(untranslated_string); - if (result.length() == 0) - return result; - // Sanitize quotes in case of any around the whole string. - if (result.length() > 1 && - ((result[0] == '"' && result[result.length() - 1] == '"') || - (result[0] == '\'' && result[result.length() - 1] == '\''))) { - // Strip first and last char which should be matching quotes now. - result = result.substr(1, result.length() - 2); - } - // First translate all path variables we recognize. - for (size_t i = 0; i < arraysize(mac_folder_mapping); ++i) { - size_t position = result.find(mac_folder_mapping[i].name); - if (position != std::string::npos) { - NSArray* searchpaths = NSSearchPathForDirectoriesInDomains( - mac_folder_mapping[i].id, NSAllDomainsMask, true); - if ([searchpaths count] > 0) { - NSString *variable_value = [searchpaths objectAtIndex:0]; - result.replace(position, strlen(mac_folder_mapping[i].name), - base::SysNSStringToUTF8(variable_value)); - } - } - } - // Next translate two special variables ${user_name} and ${machine_name} - size_t position = result.find(kUserNamePolicyVarName); - if (position != std::string::npos) { - NSString* username = NSUserName(); - if (username) { - result.replace(position, strlen(kUserNamePolicyVarName), - base::SysNSStringToUTF8(username)); - } else { - LOG(ERROR) << "Username variable can not be resolved."; - } - } - position = result.find(kMachineNamePolicyVarName); - if (position != std::string::npos) { - SCDynamicStoreContext context = { 0, NULL, NULL, NULL }; - SCDynamicStoreRef store = SCDynamicStoreCreate(kCFAllocatorDefault, - CFSTR("policy_subsystem"), - NULL, &context); - CFStringRef machinename = SCDynamicStoreCopyLocalHostName(store); - if (machinename) { - result.replace(position, strlen(kMachineNamePolicyVarName), - base::SysCFStringRefToUTF8(machinename)); - CFRelease(machinename); - } else { - LOG(ERROR) << "Machine name variable can not be resolved."; - } - CFRelease(store); - } - return result; -} +// A table mapping variable name to their respective getvalue callbacks. +const VariableNameAndValueCallback kVariableNameAndValueCallbacks[] = { + VariableNameAndValueCallback(kUserNamePolicyVarName, + base::Bind(GetUserName)), + VariableNameAndValueCallback(kMachineNamePolicyVarName, + base::Bind(GetMachineName)), + VariableNameAndValueCallback(kMacUsersDirectory, + base::Bind(GetFolder, NSUserDirectory)), + VariableNameAndValueCallback(kMacDocumentsFolderVarName, + base::Bind(GetFolder, NSDocumentDirectory))}; + +// Total number of entries in the mapping table. +const int kNoOfVariables = arraysize(kVariableNameAndValueCallbacks); + +} // namespace internal void CheckUserDataDirPolicy(base::FilePath* user_data_dir) { base::mac::ScopedNSAutoreleasePool pool; diff --git a/chrome/browser/policy/policy_path_parser_unittest.cc b/chrome/browser/policy/policy_path_parser_unittest.cc index 633ef78..f8e816e 100644 --- a/chrome/browser/policy/policy_path_parser_unittest.cc +++ b/chrome/browser/policy/policy_path_parser_unittest.cc @@ -20,13 +20,43 @@ class PolicyPathParserTests : public testing::Test { } }; -#if defined(OS_MACOSX) -// http://crbug.com/327520 -#define MAYBE_AllPlatformVariables DISABLED_AllPlatformVariables -#else -#define MAYBE_AllPlatformVariables AllPlatformVariables -#endif -TEST_F(PolicyPathParserTests, MAYBE_AllPlatformVariables) { +namespace path_parser { + +// The test needs access to a routine that is not exposed via the public header. +void ReplaceVariableInPathWithValue( + const base::FilePath::StringType& variable, + const policy::path_parser::internal::GetValueCallback& value_callback, + base::FilePath::StringType* path); + +} // namespace path_parser; + +bool GetBuggy(base::FilePath::StringType* value) { + *value = base::FilePath::StringType(FILE_PATH_LITERAL("ok")); + return true; +} + +TEST_F(PolicyPathParserTests, ReplaceVariableInPathWithValue) { + // This is custom variable with custom callback. It should replace ${buggy} + // with ok. + base::FilePath::StringType custom_vars(FILE_PATH_LITERAL("//$C/${buggy}")); + base::FilePath::StringType custom_vars_expected(FILE_PATH_LITERAL("//$C/ok")); + base::FilePath::StringType buggy(FILE_PATH_LITERAL("${buggy}")); + + path_parser::ReplaceVariableInPathWithValue( + buggy, base::Bind(&GetBuggy), &custom_vars); + ASSERT_EQ(custom_vars, custom_vars_expected); + + // There is no ${buggy} in input, so it should remain unchanged. + base::FilePath::StringType custom2_vars(FILE_PATH_LITERAL("//$C/ok")); + base::FilePath::StringType custom2_vars_expected( + FILE_PATH_LITERAL("//$C/ok")); + + path_parser::ReplaceVariableInPathWithValue( + buggy, base::Bind(&GetBuggy), &custom2_vars); + ASSERT_EQ(custom2_vars, custom2_vars_expected); +} + +TEST_F(PolicyPathParserTests, CommonExpandPathVariables) { // No vars whatsoever no substitution should occur. base::FilePath::StringType no_vars(FILE_PATH_LITERAL("//$C/shares")); base::FilePath::StringType no_vars_result = @@ -50,7 +80,15 @@ TEST_F(PolicyPathParserTests, MAYBE_AllPlatformVariables) { ASSERT_EQ(quotes_result, no_quotes); quotes_result = path_parser::ExpandPathVariables(double_quotes); ASSERT_EQ(quotes_result, no_quotes); +} +#if defined(OS_MACOSX) +// http://crbug.com/327520 +#define MAYBE_AllPlatformVariables DISABLED_AllPlatformVariables +#else +#define MAYBE_AllPlatformVariables AllPlatformVariables +#endif +TEST_F(PolicyPathParserTests, MAYBE_AllPlatformVariables) { // Both should have been substituted. base::FilePath::StringType vars( FILE_PATH_LITERAL("${user_name}${machine_name}")); diff --git a/chrome/browser/policy/policy_path_parser_win.cc b/chrome/browser/policy/policy_path_parser_win.cc index 71c9011..2d94f03 100644 --- a/chrome/browser/policy/policy_path_parser_win.cc +++ b/chrome/browser/policy/policy_path_parser_win.cc @@ -8,6 +8,7 @@ #include "chrome/browser/policy/policy_path_parser.h" +#include "base/bind.h" #include "base/memory/scoped_ptr.h" #include "base/strings/utf_string_conversions.h" #include "base/win/registry.h" @@ -28,6 +29,59 @@ bool LoadUserDataDirPolicyFromRegistry(HKEY hive, base::FilePath* dir) { return false; } +} // namespace + +namespace policy { + +namespace path_parser { + +namespace internal { + +bool GetSpecialFolderPath(int id, base::FilePath::StringType* value) { + WCHAR path[MAX_PATH]; + ::SHGetSpecialFolderPath(0, path, id, false); + *value = base::FilePath::StringType(path); + return true; +} + +bool GetWindowsUserName(base::FilePath::StringType* value) { + DWORD return_length = 0; + ::GetUserName(NULL, &return_length); + if (return_length) { + scoped_ptr<WCHAR[]> username(new WCHAR[return_length]); + ::GetUserName(username.get(), &return_length); + *value = base::FilePath::StringType(username.get()); + } + return (return_length != 0); +} + +bool GetMachineName(base::FilePath::StringType* value) { + DWORD return_length = 0; + ::GetComputerNameEx(ComputerNamePhysicalDnsHostname, NULL, &return_length); + if (return_length) { + scoped_ptr<WCHAR[]> machinename(new WCHAR[return_length]); + ::GetComputerNameEx( + ComputerNamePhysicalDnsHostname, machinename.get(), &return_length); + *value = base::FilePath::StringType(machinename.get()); + } + return (return_length != 0); +} + +bool GetClientName(base::FilePath::StringType* value) { + LPWSTR buffer = NULL; + DWORD buffer_length = 0; + BOOL status; + if ((status = ::WTSQuerySessionInformation(WTS_CURRENT_SERVER, + WTS_CURRENT_SESSION, + WTSClientName, + &buffer, + &buffer_length))) { + *value = base::FilePath::StringType(buffer); + ::WTSFreeMemory(buffer); + } + return (status == TRUE); +} + const WCHAR* kMachineNamePolicyVarName = L"${machine_name}"; const WCHAR* kUserNamePolicyVarName = L"${user_name}"; const WCHAR* kWinDocumentsFolderVarName = L"${documents}"; @@ -39,92 +93,39 @@ const WCHAR* kWinProgramFilesFolderVarName = L"${program_files}"; const WCHAR* kWinWindowsFolderVarName = L"${windows}"; const WCHAR* kWinClientName = L"${client_name}"; -struct WinFolderNamesToCSIDLMapping { - const WCHAR* name; - int id; -}; - -// Mapping from variable names to Windows CSIDL ids. -const WinFolderNamesToCSIDLMapping win_folder_mapping[] = { - { kWinWindowsFolderVarName, CSIDL_WINDOWS}, - { kWinProgramFilesFolderVarName, CSIDL_PROGRAM_FILES}, - { kWinProgramDataFolderVarName, CSIDL_COMMON_APPDATA}, - { kWinProfileFolderVarName, CSIDL_PROFILE}, - { kWinLocalAppDataFolderVarName, CSIDL_LOCAL_APPDATA}, - { kWinRoamingAppDataFolderVarName, CSIDL_APPDATA}, - { kWinDocumentsFolderVarName, CSIDL_PERSONAL} -}; - -} // namespace - -namespace policy { - -namespace path_parser { - -// Replaces all variable occurances in the policy string with the respective -// system settings values. -base::FilePath::StringType ExpandPathVariables( - const base::FilePath::StringType& untranslated_string) { - base::FilePath::StringType result(untranslated_string); - if (result.length() == 0) - return result; - // Sanitize quotes in case of any around the whole string. - if (result.length() > 1 && - ((result[0] == L'"' && result[result.length() - 1] == L'"') || - (result[0] == L'\'' && result[result.length() - 1] == L'\''))) { - // Strip first and last char which should be matching quotes now. - result = result.substr(1, result.length() - 2); - } - // First translate all path variables we recognize. - for (int i = 0; i < arraysize(win_folder_mapping); ++i) { - size_t position = result.find(win_folder_mapping[i].name); - if (position != std::wstring::npos) { - WCHAR path[MAX_PATH]; - ::SHGetSpecialFolderPath(0, path, win_folder_mapping[i].id, false); - std::wstring path_string(path); - result.replace(position, wcslen(win_folder_mapping[i].name), path_string); - } - } - // Next translate other windows specific variables. - size_t position = result.find(kUserNamePolicyVarName); - if (position != std::wstring::npos) { - DWORD return_length = 0; - ::GetUserName(NULL, &return_length); - if (return_length != 0) { - scoped_ptr<WCHAR[]> username(new WCHAR[return_length]); - ::GetUserName(username.get(), &return_length); - std::wstring username_string(username.get()); - result.replace(position, wcslen(kUserNamePolicyVarName), username_string); - } - } - position = result.find(kMachineNamePolicyVarName); - if (position != std::wstring::npos) { - DWORD return_length = 0; - ::GetComputerNameEx(ComputerNamePhysicalDnsHostname, NULL, &return_length); - if (return_length != 0) { - scoped_ptr<WCHAR[]> machinename(new WCHAR[return_length]); - ::GetComputerNameEx(ComputerNamePhysicalDnsHostname, - machinename.get(), &return_length); - std::wstring machinename_string(machinename.get()); - result.replace( - position, wcslen(kMachineNamePolicyVarName), machinename_string); - } - } - position = result.find(kWinClientName); - if (position != std::wstring::npos) { - LPWSTR buffer = NULL; - DWORD buffer_length = 0; - if (::WTSQuerySessionInformation(WTS_CURRENT_SERVER, WTS_CURRENT_SESSION, - WTSClientName, - &buffer, &buffer_length)) { - std::wstring clientname_string(buffer); - result.replace(position, wcslen(kWinClientName), clientname_string); - ::WTSFreeMemory(buffer); - } - } - - return result; -} +// A table mapping variable name to their respective getvalue callbacks. +const VariableNameAndValueCallback kVariableNameAndValueCallbacks[] = { + VariableNameAndValueCallback( + kWinWindowsFolderVarName, + base::Bind(GetSpecialFolderPath, CSIDL_WINDOWS)), + VariableNameAndValueCallback( + kWinProgramFilesFolderVarName, + base::Bind(GetSpecialFolderPath, CSIDL_PROGRAM_FILES)), + VariableNameAndValueCallback( + kWinProgramDataFolderVarName, + base::Bind(GetSpecialFolderPath, CSIDL_COMMON_APPDATA)), + VariableNameAndValueCallback( + kWinProfileFolderVarName, + base::Bind(GetSpecialFolderPath, CSIDL_PROFILE)), + VariableNameAndValueCallback( + kWinLocalAppDataFolderVarName, + base::Bind(GetSpecialFolderPath, CSIDL_LOCAL_APPDATA)), + VariableNameAndValueCallback( + kWinRoamingAppDataFolderVarName, + base::Bind(GetSpecialFolderPath, CSIDL_APPDATA)), + VariableNameAndValueCallback( + kWinDocumentsFolderVarName, + base::Bind(GetSpecialFolderPath, CSIDL_PERSONAL)), + VariableNameAndValueCallback(kUserNamePolicyVarName, + base::Bind(GetWindowsUserName)), + VariableNameAndValueCallback(kMachineNamePolicyVarName, + base::Bind(GetMachineName)), + VariableNameAndValueCallback(kWinClientName, base::Bind(GetClientName))}; + +// Total number of entries in the mapping table. +const int kNoOfVariables = arraysize(kVariableNameAndValueCallbacks); + +} // namespace internal void CheckUserDataDirPolicy(base::FilePath* user_data_dir) { DCHECK(user_data_dir); diff --git a/chrome/policy.gypi b/chrome/policy.gypi index 79cc543..60de7fe 100644 --- a/chrome/policy.gypi +++ b/chrome/policy.gypi @@ -20,6 +20,7 @@ 'browser/policy/policy_path_parser_linux.cc', 'browser/policy/policy_path_parser_mac.mm', 'browser/policy/policy_path_parser_win.cc', + 'browser/policy/policy_path_parser.cc', ], }, ], |