| OLD | NEW |
| 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 Loading... |
| 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 // BrowserContext needs an absolute path, which we would normally get via |
| 80 // PathService. In this case, manually ensure the path is absolute. |
| 81 if (!path_.IsAbsolute()) |
| 82 path_ = base::MakeAbsoluteFilePath(path_); |
| 83 if (!path_.empty()) { |
| 84 BrowserContext::Initialize(this, path_); |
| 85 return; |
| 86 } |
| 87 } else { |
| 88 LOG(WARNING) << "Unable to create data-path directory: " << path_.value(); |
| 89 } |
| 80 } | 90 } |
| 91 |
| 81 #if defined(OS_WIN) | 92 #if defined(OS_WIN) |
| 82 CHECK(PathService::Get(base::DIR_LOCAL_APP_DATA, &path_)); | 93 CHECK(PathService::Get(base::DIR_LOCAL_APP_DATA, &path_)); |
| 83 path_ = path_.Append(std::wstring(L"content_shell")); | 94 path_ = path_.Append(std::wstring(L"content_shell")); |
| 84 #elif defined(OS_LINUX) | 95 #elif defined(OS_LINUX) |
| 85 std::unique_ptr<base::Environment> env(base::Environment::Create()); | 96 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
| 86 base::FilePath config_dir( | 97 base::FilePath config_dir( |
| 87 base::nix::GetXDGDirectory(env.get(), | 98 base::nix::GetXDGDirectory(env.get(), |
| 88 base::nix::kXdgConfigHomeEnvVar, | 99 base::nix::kXdgConfigHomeEnvVar, |
| 89 base::nix::kDotConfigDir)); | 100 base::nix::kDotConfigDir)); |
| 90 path_ = config_dir.Append("content_shell"); | 101 path_ = config_dir.Append("content_shell"); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 return permission_manager_.get(); | 206 return permission_manager_.get(); |
| 196 } | 207 } |
| 197 | 208 |
| 198 BackgroundSyncController* ShellBrowserContext::GetBackgroundSyncController() { | 209 BackgroundSyncController* ShellBrowserContext::GetBackgroundSyncController() { |
| 199 if (!background_sync_controller_) | 210 if (!background_sync_controller_) |
| 200 background_sync_controller_.reset(new MockBackgroundSyncController()); | 211 background_sync_controller_.reset(new MockBackgroundSyncController()); |
| 201 return background_sync_controller_.get(); | 212 return background_sync_controller_.get(); |
| 202 } | 213 } |
| 203 | 214 |
| 204 } // namespace content | 215 } // namespace content |
| OLD | NEW |