Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Unified Diff: chrome/test/chromedriver/chrome_launcher.cc

Issue 613163004: [chromedriver] setting browser default download directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use GetSwitchValueNative Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/chromedriver/chrome_launcher.cc
diff --git a/chrome/test/chromedriver/chrome_launcher.cc b/chrome/test/chromedriver/chrome_launcher.cc
index 21595b0c8b3fab8f83af37918ef29e7f2e2eb8b5..739f2fc537edf8d18f674b6529b9a84263ee3417 100644
--- a/chrome/test/chromedriver/chrome_launcher.cc
+++ b/chrome/test/chromedriver/chrome_launcher.cc
@@ -128,28 +128,33 @@ Status PrepareCommandLine(int port,
switches.RemoveSwitch(*iter);
}
switches.SetFromSwitches(capabilities.switches);
-
+ base::FilePath user_data_dir_path;
if (!switches.HasSwitch("user-data-dir")) {
command.AppendArg("data:,");
if (!user_data_dir->CreateUniqueTempDir())
return Status(kUnknownError, "cannot create temp dir for user data dir");
switches.SetSwitch("user-data-dir", user_data_dir->path().value());
- Status status = internal::PrepareUserDataDir(
- user_data_dir->path(), capabilities.prefs.get(),
- capabilities.local_state.get());
- if (status.IsError())
- return status;
+ user_data_dir_path = user_data_dir->path();
+ } else {
+ user_data_dir_path = base::FilePath(switches.
+ GetSwitchValueNative("user-data-dir"));
samuong 2014/10/21 01:01:43 can you put the "switches." on line 140? ie: user
}
+ Status status = internal::PrepareUserDataDir(user_data_dir_path,
+ capabilities.prefs.get(),
+ capabilities.local_state.get());
+ if (status.IsError())
+ return status;
+
if (!extension_dir->CreateUniqueTempDir()) {
return Status(kUnknownError,
"cannot create temp dir for unpacking extensions");
}
- Status status = internal::ProcessExtensions(capabilities.extensions,
- extension_dir->path(),
- true,
- &switches,
- extension_bg_pages);
+ status = internal::ProcessExtensions(capabilities.extensions,
+ extension_dir->path(),
+ true,
+ &switches,
+ extension_bg_pages);
if (status.IsError())
return status;
switches.AppendToCommandLine(&command);
@@ -772,14 +777,32 @@ Status PrepareUserDataDir(
if (!base::CreateDirectory(default_dir))
return Status(kUnknownError, "cannot create default profile directory");
+ std::string preferences;
+ base::FilePath preferences_path =
+ default_dir.Append(chrome::kPreferencesFilename);
+
+ if (base::PathExists(preferences_path))
+ base::ReadFileToString(preferences_path, &preferences);
+ else
+ preferences = kPreferences;
+
Status status =
- WritePrefsFile(kPreferences,
+ WritePrefsFile(preferences,
custom_prefs,
default_dir.Append(chrome::kPreferencesFilename));
if (status.IsError())
return status;
- status = WritePrefsFile(kLocalState,
+ std::string local_state;
+ base::FilePath local_state_path =
+ user_data_dir.Append(chrome::kLocalStateFilename);
+
+ if (base::PathExists(local_state_path))
+ base::ReadFileToString(local_state_path, &local_state);
+ else
+ local_state = kLocalState;
+
+ status = WritePrefsFile(local_state,
custom_local_state,
user_data_dir.Append(chrome::kLocalStateFilename));
if (status.IsError())
« no previous file with comments | « chrome/test/chromedriver/chrome/chrome_desktop_impl.cc ('k') | chrome/test/chromedriver/client/chromedriver.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698