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

Side by Side 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: logging Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/shell/browser/shell_browser_context.h" 5 #include "content/shell/browser/shell_browser_context.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 BrowserThread::IO, FROM_HERE, resource_context_.release()); 68 BrowserThread::IO, FROM_HERE, resource_context_.release());
69 } 69 }
70 } 70 }
71 71
72 void ShellBrowserContext::InitWhileIOAllowed() { 72 void ShellBrowserContext::InitWhileIOAllowed() {
73 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); 73 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
74 if (cmd_line->HasSwitch(switches::kIgnoreCertificateErrors)) 74 if (cmd_line->HasSwitch(switches::kIgnoreCertificateErrors))
75 ignore_certificate_errors_ = true; 75 ignore_certificate_errors_ = true;
76 if (cmd_line->HasSwitch(switches::kContentShellDataPath)) { 76 if (cmd_line->HasSwitch(switches::kContentShellDataPath)) {
77 path_ = cmd_line->GetSwitchValuePath(switches::kContentShellDataPath); 77 path_ = cmd_line->GetSwitchValuePath(switches::kContentShellDataPath);
78 BrowserContext::Initialize(this, path_); 78 if (base::DirectoryExists(path_) || base::CreateDirectory(path_)) {
79 return; 79 // We need to have an absolute path.
Peter Beverloo 2016/09/29 16:22:53 nit: might be good to document that the PathServic
michaelpg 2016/09/30 03:38:56 Done.
80 if (!path_.IsAbsolute())
81 path_ = base::MakeAbsoluteFilePath(path_);
82 if (!path_.empty()) {
83 BrowserContext::Initialize(this, path_);
84 return;
85 }
86 } else {
87 LOG(WARNING) << "Unable to create data-path directory: " << path_.value();
88 }
80 } 89 }
90
81 #if defined(OS_WIN) 91 #if defined(OS_WIN)
82 CHECK(PathService::Get(base::DIR_LOCAL_APP_DATA, &path_)); 92 CHECK(PathService::Get(base::DIR_LOCAL_APP_DATA, &path_));
83 path_ = path_.Append(std::wstring(L"content_shell")); 93 path_ = path_.Append(std::wstring(L"content_shell"));
84 #elif defined(OS_LINUX) 94 #elif defined(OS_LINUX)
85 std::unique_ptr<base::Environment> env(base::Environment::Create()); 95 std::unique_ptr<base::Environment> env(base::Environment::Create());
86 base::FilePath config_dir( 96 base::FilePath config_dir(
87 base::nix::GetXDGDirectory(env.get(), 97 base::nix::GetXDGDirectory(env.get(),
88 base::nix::kXdgConfigHomeEnvVar, 98 base::nix::kXdgConfigHomeEnvVar,
89 base::nix::kDotConfigDir)); 99 base::nix::kDotConfigDir));
90 path_ = config_dir.Append("content_shell"); 100 path_ = config_dir.Append("content_shell");
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 return permission_manager_.get(); 205 return permission_manager_.get();
196 } 206 }
197 207
198 BackgroundSyncController* ShellBrowserContext::GetBackgroundSyncController() { 208 BackgroundSyncController* ShellBrowserContext::GetBackgroundSyncController() {
199 if (!background_sync_controller_) 209 if (!background_sync_controller_)
200 background_sync_controller_.reset(new MockBackgroundSyncController()); 210 background_sync_controller_.reset(new MockBackgroundSyncController());
201 return background_sync_controller_.get(); 211 return background_sync_controller_.get();
202 } 212 }
203 213
204 } // namespace content 214 } // namespace content
OLDNEW
« 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