electron/shell/browser/net/network_context_service.cc
electron-roller[bot] 49e62f1261
chore: bump chromium to 95.0.4629.0 (main) (#30676)
* chore: bump chromium in DEPS to 95.0.4620.0

* chore: update patches

* 3076261: Move args_ to private in ExtensionFunction

https://chromium-review.googlesource.com/c/chromium/src/+/3076261

* [GURL -> SiteForCookies] content/public/browser/content_browser_client.h

https://chromium-review.googlesource.com/c/chromium/src/+/3107759

* chore: fix -Wunreachable-code-return in node

* Tracing to diagnose ContentScriptTracker-related bad message reports

https://chromium-review.googlesource.com/c/chromium/src/+/3057922

* chore: bump chromium in DEPS to 95.0.4621.0

* chore: update patches

* Remove title from the URL format on Windows.

https://chromium-review.googlesource.com/c/chromium/src/+/3108445

* chore: bump chromium in DEPS to 95.0.4623.0

* Revert "chore: disable v8 oilpan"

This reverts commit 5d255cf1d8e8efbb906047937a713279e5f800d0.

(cherry picked from commit ba5cde4da2428020d99b7fb603c702878f95da78)

* Change file paths in network context params to be relative.

https://chromium-review.googlesource.com/c/chromium/src/+/3092927

* Code Health: Rename/replace content::WebUI::RegisterMessageCallback().

https://chromium-review.googlesource.com/c/chromium/src/+/3104691

* Migrate CanExecuteContentScriptSync to Mojo

https://chromium-review.googlesource.com/c/chromium/src/+/3108452

* chore: update patches

* remove unreachable code

* Revert "Revert "chore: disable v8 oilpan""

This reverts commit fef495c0294e21760df51bddb5f7bf1ec9ed5f1e.

* fixup mas patch

* Reland "[include] Split out v8.h"

https://chromium-review.googlesource.com/c/v8/v8/+/3113629

* chore: bump chromium in DEPS to 95.0.4624.0

* chore: bump chromium in DEPS to 95.0.4625.0

* chore: bump chromium in DEPS to 95.0.4626.0

* 3033504: Pass NavigationDownloadPolicy in CreateNewWindowParams

https://chromium-review.googlesource.com/c/chromium/src/+/3033504

* 3058038: Introduce TestPrintingContext & test UpdatePrintSettings

https://chromium-review.googlesource.com/c/chromium/src/+/3058038

* 3114943: [Conditional Focus][#4] Add tests and remove flag gating

https://chromium-review.googlesource.com/c/chromium/src/+/3114943

* chore: update patch indices

* chore: bump chromium in DEPS to 95.0.4627.0

* chore: update patches

* 3093591: ozone: webpagepopups: calculate anchor for menu bounds. 4/*

https://chromium-review.googlesource.com/c/chromium/src/+/3093591

* 3110414: [PA] Remove the leading cookie

https://chromium-review.googlesource.com/c/chromium/src/+/3110414

* chore: update patches

* 3076261: Move args_ to private in ExtensionFunction

https://chromium-review.googlesource.com/c/chromium/src/+/3076261

* 3113629: Reland "[include] Split out v8.h"

https://chromium-review.googlesource.com/c/v8/v8/+/3113629

* chore: bump chromium in DEPS to 95.0.4628.0

* chore: update patches

* chore: bump chromium in DEPS to 95.0.4629.0

* chore: update patches

* Fix chrome root store codegen for cross-compile builds.

https://chromium-review.googlesource.com/c/chromium/src/+/3133701

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2021-09-01 15:55:07 -04:00

99 lines
3.8 KiB
C++

// Copyright (c) 2019 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/browser/net/network_context_service.h"
#include <utility>
#include "chrome/common/chrome_constants.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/browser/shared_cors_origin_access_list.h"
#include "electron/fuses.h"
#include "net/net_buildflags.h"
#include "services/network/network_service.h"
#include "services/network/public/cpp/cors/origin_access_list.h"
#include "shell/browser/browser_process_impl.h"
#include "shell/browser/electron_browser_client.h"
#include "shell/browser/net/system_network_context_manager.h"
namespace electron {
NetworkContextService::NetworkContextService(content::BrowserContext* context)
: browser_context_(static_cast<ElectronBrowserContext*>(context)),
proxy_config_monitor_(browser_context_->prefs()) {}
NetworkContextService::~NetworkContextService() = default;
void NetworkContextService::ConfigureNetworkContextParams(
network::mojom::NetworkContextParams* network_context_params,
cert_verifier::mojom::CertVerifierCreationParams*
cert_verifier_creation_params) {
bool in_memory = browser_context_->IsOffTheRecord();
const base::FilePath& path = browser_context_->GetPath();
g_browser_process->system_network_context_manager()
->ConfigureDefaultNetworkContextParams(network_context_params);
mojo::Remote<network::mojom::SSLConfigClient> ssl_config_client;
network_context_params->ssl_config_client_receiver =
ssl_config_client.BindNewPipeAndPassReceiver();
browser_context_->SetSSLConfigClient(std::move(ssl_config_client));
network_context_params->initial_ssl_config = browser_context_->GetSSLConfig();
network_context_params->user_agent = browser_context_->GetUserAgent();
network_context_params->cors_origin_access_list =
browser_context_->GetSharedCorsOriginAccessList()
->GetOriginAccessList()
.CreateCorsOriginAccessPatternsList();
network_context_params->accept_language =
net::HttpUtil::GenerateAcceptLanguageHeader(
ElectronBrowserClient::Get()->GetApplicationLocale());
// Enable the HTTP cache.
network_context_params->http_cache_enabled =
browser_context_->CanUseHttpCache();
network_context_params->cookie_manager_params =
network::mojom::CookieManagerParams::New();
// Configure on-disk storage for persistent sessions.
if (!in_memory) {
// Configure the HTTP cache path and size.
network_context_params->http_cache_path =
path.Append(chrome::kCacheDirname);
network_context_params->http_cache_max_size =
browser_context_->GetMaxCacheSize();
network_context_params->file_paths =
network::mojom::NetworkContextFilePaths::New();
network_context_params->file_paths->data_path = path;
// Currently this just contains HttpServerProperties
network_context_params->file_paths->http_server_properties_file_name =
base::FilePath(chrome::kNetworkPersistentStateFilename);
// Configure persistent cookie path.
network_context_params->file_paths->cookie_database_name =
base::FilePath(chrome::kCookieFilename);
network_context_params->restore_old_session_cookies = false;
network_context_params->persist_session_cookies = false;
network_context_params->enable_encrypted_cookies =
electron::fuses::IsCookieEncryptionEnabled();
network_context_params->file_paths->transport_security_persister_file_name =
base::FilePath(chrome::kTransportSecurityPersisterFilename);
}
proxy_config_monitor_.AddToNetworkContextParams(network_context_params);
BrowserProcessImpl::ApplyProxyModeFromCommandLine(
browser_context_->in_memory_pref_store());
}
} // namespace electron