diff options
author | pastarmovj@chromium.org <pastarmovj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-09 15:23:02 +0000 |
---|---|---|
committer | pastarmovj@chromium.org <pastarmovj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-09 15:23:02 +0000 |
commit | d24b937688ac39a04e84450d5205596c8e08fd92 (patch) | |
tree | 3dec80eded91702acd28bcd10d6a88101541a77b /chrome/app/chrome_main.cc | |
parent | 1930a11fbd7d49a75ad341b0c33489c60dfaaa11 (diff) | |
download | chromium_src-d24b937688ac39a04e84450d5205596c8e08fd92.zip chromium_src-d24b937688ac39a04e84450d5205596c8e08fd92.tar.gz chromium_src-d24b937688ac39a04e84450d5205596c8e08fd92.tar.bz2 |
Replaced environment variables for our own ones in the UserDataDir policy for Windows.
BUG=49601
TEST=Manual. Set the policy in windows and it should be equivalent to using the --user-data-dir option.
Review URL: http://codereview.chromium.org/6250192
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74290 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/app/chrome_main.cc')
-rw-r--r-- | chrome/app/chrome_main.cc | 51 |
1 files changed, 12 insertions, 39 deletions
diff --git a/chrome/app/chrome_main.cc b/chrome/app/chrome_main.cc index 45b60f0..051b43a 100644 --- a/chrome/app/chrome_main.cc +++ b/chrome/app/chrome_main.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -47,7 +47,6 @@ #include <malloc.h> #include <new.h> #include "base/win/registry.h" -#include "policy/policy_constants.h" #include "sandbox/src/sandbox.h" #include "tools/memory_watcher/memory_watcher.h" #endif @@ -119,6 +118,17 @@ int ChromeMain(int argc, char** argv); } #endif +// Checks if the UserDataDir policy has been set and returns its value in the +// |user_data_dir| parameter. If no policy is set the parameter is not changed. +void CheckUserDataDirPolicy(FilePath* user_data_dir); + +#if !defined(OS_WIN) +// This policy is not implemented for Linux and ChromeOS. The win and mac ver- +// sions are implemented in the platform specific version of chrome_main.cc e.g. +// chrome_main_win.cc or chrome_main_mac.mm . +void CheckUserDataDirPolicy(FilePath* user_data_dir) {} +#endif + namespace { #if defined(OS_WIN) @@ -517,43 +527,6 @@ void HandleHelpSwitches(const CommandLine& command_line) { #endif // OS_POSIX -#if defined(OS_WIN) -// Checks if the registry key exists in the given hive and expands any -// environment variables in the string. -bool LoadUserDataDirPolicyFromRegistry(HKEY hive, FilePath* user_data_dir) { - std::wstring key_name = UTF8ToWide(policy::key::kUserDataDir); - std::wstring value; - - base::win::RegKey hklm_policy_key(hive, policy::kRegistrySubKey, KEY_READ); - if (hklm_policy_key.ReadValue(key_name.c_str(), &value) == ERROR_SUCCESS) { - // Try to expand the env variables if not possible fallback to no expansion. - DWORD expanded_len = ::ExpandEnvironmentStrings(value.c_str(), NULL, 0); - if (expanded_len) { - scoped_array<WCHAR> expanded_value(new WCHAR[expanded_len]); - ::ExpandEnvironmentStrings(value.c_str(), - expanded_value.get(), expanded_len); - *user_data_dir = FilePath::FromWStringHack(expanded_value.get()); - } else { - *user_data_dir = FilePath::FromWStringHack(value); - } - return true; - } - return false; -} -#endif // OS_WIN - -// Checks if the UserDataDir policy has been set and returns its value in the -// |user_data_dir| parameter. If no policy is set the parameter is not changed. -void CheckUserDataDirPolicy(FilePath* user_data_dir) { -#if defined(OS_WIN) - // Policy from the HKLM hive has precedence over HKCU so if we have one here - // we don't have to try to load HKCU. - if (LoadUserDataDirPolicyFromRegistry(HKEY_LOCAL_MACHINE, user_data_dir)) - return; - LoadUserDataDirPolicyFromRegistry(HKEY_CURRENT_USER, user_data_dir); -#endif -} - // We dispatch to a process-type-specific FooMain() based on a command-line // flag. This struct is used to build a table of (flag, main function) pairs. struct MainFunction { |