fix: provide paths for all NetworkContextFilePaths keys (#31777)

* fix: provide paths for all NetworkContextFilePaths keys

* chore: include chrome features header

* chore: build browser_features

* yolo

* add pref service

* fix: include sandbox policy features

* fix pref key

* fix: gate pref key to OS_WIN

Co-authored-by: VerteDinde <khammond@slack-corp.com>
This commit is contained in:
Samuel Attard 2021-11-16 12:26:09 +13:00 committed by GitHub
parent 65e4f75058
commit 246884c4fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 59 additions and 1 deletions

View file

@ -6,6 +6,7 @@
#include <utility>
#include "chrome/browser/browser_features.h"
#include "chrome/common/chrome_constants.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/browser/shared_cors_origin_access_list.h"
@ -19,6 +20,21 @@
namespace electron {
namespace {
bool ShouldTriggerNetworkDataMigration() {
#if defined(OS_WIN)
// On Windows, if sandbox enabled means data must be migrated.
if (SystemNetworkContextManager::IsNetworkSandboxEnabled())
return true;
#endif // defined(OS_WIN)
if (base::FeatureList::IsEnabled(features::kTriggerNetworkDataMigration))
return true;
return false;
}
} // namespace
NetworkContextService::NetworkContextService(content::BrowserContext* context)
: browser_context_(static_cast<ElectronBrowserContext*>(context)),
proxy_config_monitor_(browser_context_->prefs()) {}
@ -70,7 +86,11 @@ void NetworkContextService::ConfigureNetworkContextParams(
network_context_params->file_paths =
network::mojom::NetworkContextFilePaths::New();
network_context_params->file_paths->data_path = path;
network_context_params->file_paths->data_path =
path.Append(chrome::kNetworkDataDirname);
network_context_params->file_paths->unsandboxed_data_path = path;
network_context_params->file_paths->trigger_migration =
ShouldTriggerNetworkDataMigration();
// Currently this just contains HttpServerProperties
network_context_params->file_paths->http_server_properties_file_name =
@ -80,6 +100,12 @@ void NetworkContextService::ConfigureNetworkContextParams(
network_context_params->file_paths->cookie_database_name =
base::FilePath(chrome::kCookieFilename);
network_context_params->file_paths->http_server_properties_file_name =
base::FilePath(chrome::kNetworkPersistentStateFilename);
network_context_params->file_paths->trust_token_database_name =
base::FilePath(chrome::kTrustTokenFilename);
network_context_params->restore_old_session_cookies = false;
network_context_params->persist_session_cookies = false;