Commit c527ac73 authored by noms's avatar noms Committed by Commit bot

If possible, use the PathService instead of the --user-data-dir flag directly

Some classes still using it directly are:
- cloud_print_proxy_process_browsertest.cc (it's not a browser test so it doesn't
call ChromeMainDelegate::PreSandboxStartup(), which sets up the PathService
to know about the user-data-dir

- in_process_browser_test.cc, which needs to set up the user-data-dir directory
before PreSandboxStartup() is called

- diagnostics_model and diagnostics_controller, which are used in
BasicStartupComplete(), which is called before PreSandboxStartup() where the
PathService is set up

- shell_integration_win.cc which has a function that's used in unit tests, which
don't call PreSandboxStartup()

- chrome/browser/shell_integration.cc is used differently on linux than on other
platforms, and on the former a desktop app shortcut uses a different command line
that that of Chrome's

- cloud_print/service/*, since it seems to be its own thing, and have a separate
user_data_dir

BUG=464616

Review URL: https://codereview.chromium.org/1010923002

Cr-Commit-Position: refs/heads/master@{#322697}
parent a357285f
...@@ -345,10 +345,8 @@ void InitializeUserDataDir() { ...@@ -345,10 +345,8 @@ void InitializeUserDataDir() {
// On Windows, trailing separators leave Chrome in a bad state. // On Windows, trailing separators leave Chrome in a bad state.
// See crbug.com/464616. // See crbug.com/464616.
if (user_data_dir.EndsWithSeparator()) { if (user_data_dir.EndsWithSeparator())
user_data_dir = user_data_dir.StripTrailingSeparators(); user_data_dir = user_data_dir.StripTrailingSeparators();
command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir);
}
const bool specified_directory_was_invalid = !user_data_dir.empty() && const bool specified_directory_was_invalid = !user_data_dir.empty() &&
!PathService::OverrideAndCreateIfNeeded(chrome::DIR_USER_DATA, !PathService::OverrideAndCreateIfNeeded(chrome::DIR_USER_DATA,
......
...@@ -185,12 +185,19 @@ void SetWillLaunchAtLogin(const base::FilePath& application_path, ...@@ -185,12 +185,19 @@ void SetWillLaunchAtLogin(const base::FilePath& application_path,
const base::CommandLine& command_line = const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess(); *base::CommandLine::ForCurrentProcess();
// Propagate --user-data-dir if it was specified on the command line.
// Retrieve the value from the PathService since some sanitation may have
// taken place. There is no need to add it to the command line in the
// event that the dir was overridden by Group Policy since the GP override
// will be in force when Chrome is launched.
if (command_line.HasSwitch(switches::kUserDataDir)) { if (command_line.HasSwitch(switches::kUserDataDir)) {
cmd_line += ASCIIToUTF16(" --"); cmd_line += ASCIIToUTF16(" --");
cmd_line += ASCIIToUTF16(switches::kUserDataDir); cmd_line += ASCIIToUTF16(switches::kUserDataDir);
cmd_line += ASCIIToUTF16("=\""); cmd_line += ASCIIToUTF16("=\"");
cmd_line += base::FilePath user_data_dir;
command_line.GetSwitchValuePath(switches::kUserDataDir).value(); PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
cmd_line += user_data_dir.value();
cmd_line += ASCIIToUTF16("\""); cmd_line += ASCIIToUTF16("\"");
} }
......
...@@ -34,6 +34,8 @@ void LaunchBrowserProcessWithSwitch(const std::string& switch_string) { ...@@ -34,6 +34,8 @@ void LaunchBrowserProcessWithSwitch(const std::string& switch_string) {
} }
base::CommandLine cmd_line(exe_path); base::CommandLine cmd_line(exe_path);
// Propagate an explicit --user-data-dir value if one was given. The new
// browser process will pick up a policy override during initialization.
const base::CommandLine& process_command_line = const base::CommandLine& process_command_line =
*base::CommandLine::ForCurrentProcess(); *base::CommandLine::ForCurrentProcess();
base::FilePath user_data_dir = base::FilePath user_data_dir =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment