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

Unified Diff: content/shell/browser/shell_browser_context.cc

Issue 2344073003: content_shell/app_shell: validate --data-path and fall back to default directory (Closed)
Patch Set: rebase Created 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/browser/shell_browser_context.cc
diff --git a/content/shell/browser/shell_browser_context.cc b/content/shell/browser/shell_browser_context.cc
index 65f4801b923a385b74fa8ff53bab720a5810f48d..38bf23581ddc65aa4ebf243cdc27680e00d660ee 100644
--- a/content/shell/browser/shell_browser_context.cc
+++ b/content/shell/browser/shell_browser_context.cc
@@ -75,9 +75,20 @@ void ShellBrowserContext::InitWhileIOAllowed() {
ignore_certificate_errors_ = true;
if (cmd_line->HasSwitch(switches::kContentShellDataPath)) {
path_ = cmd_line->GetSwitchValuePath(switches::kContentShellDataPath);
- BrowserContext::Initialize(this, path_);
- return;
+ if (base::DirectoryExists(path_) || base::CreateDirectory(path_)) {
+ // BrowserContext needs an absolute path, which we would normally get via
+ // PathService. In this case, manually ensure the path is absolute.
+ if (!path_.IsAbsolute())
+ path_ = base::MakeAbsoluteFilePath(path_);
+ if (!path_.empty()) {
+ BrowserContext::Initialize(this, path_);
+ return;
+ }
+ } else {
+ LOG(WARNING) << "Unable to create data-path directory: " << path_.value();
+ }
}
+
#if defined(OS_WIN)
CHECK(PathService::Get(base::DIR_LOCAL_APP_DATA, &path_));
path_ = path_.Append(std::wstring(L"content_shell"));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698