chore: bump chromium to f755b70e34659441e72c1a928a406 (master) (#21000)
This commit is contained in:
parent
a5c9bd53e0
commit
49b47ee4ed
181 changed files with 1117 additions and 1786 deletions
|
@ -227,7 +227,7 @@ void AtomMainDelegate::PostEarlyInitialization(bool is_running_tests) {
|
|||
if (cmd_line->HasSwitch(::switches::kLang)) {
|
||||
const std::string locale = cmd_line->GetSwitchValueASCII(::switches::kLang);
|
||||
const base::FilePath locale_file_path =
|
||||
ui::ResourceBundle::GetSharedInstance().GetLocaleFilePath(locale, true);
|
||||
ui::ResourceBundle::GetSharedInstance().GetLocaleFilePath(locale);
|
||||
if (!locale_file_path.empty()) {
|
||||
custom_locale = locale;
|
||||
#if defined(OS_LINUX)
|
||||
|
|
|
@ -697,8 +697,7 @@ void App::AllowCertificateError(
|
|||
const GURL& request_url,
|
||||
bool is_main_frame_request,
|
||||
bool strict_enforcement,
|
||||
const base::RepeatingCallback<void(content::CertificateRequestResultType)>&
|
||||
callback) {
|
||||
base::OnceCallback<void(content::CertificateRequestResultType)> callback) {
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
bool prevent_default = Emit(
|
||||
|
@ -707,7 +706,7 @@ void App::AllowCertificateError(
|
|||
|
||||
// Deny the certificate by default.
|
||||
if (!prevent_default)
|
||||
callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
|
||||
std::move(callback).Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
|
||||
}
|
||||
|
||||
base::OnceClosure App::SelectClientCertificate(
|
||||
|
|
|
@ -114,8 +114,8 @@ class App : public AtomBrowserClient::Delegate,
|
|||
const GURL& request_url,
|
||||
bool is_main_frame_request,
|
||||
bool strict_enforcement,
|
||||
const base::RepeatingCallback<
|
||||
void(content::CertificateRequestResultType)>& callback) override;
|
||||
base::OnceCallback<void(content::CertificateRequestResultType)> callback)
|
||||
override;
|
||||
base::OnceClosure SelectClientCertificate(
|
||||
content::WebContents* web_contents,
|
||||
net::SSLCertRequestInfo* cert_request_info,
|
||||
|
|
|
@ -243,7 +243,7 @@ void BrowserWindow::OnCloseButtonClicked(bool* prevent_default) {
|
|||
// Already closed by renderer
|
||||
return;
|
||||
|
||||
if (web_contents()->NeedToFireBeforeUnload())
|
||||
if (web_contents()->NeedToFireBeforeUnloadOrUnload())
|
||||
web_contents()->DispatchBeforeUnload(false /* auto_cancel */);
|
||||
else
|
||||
web_contents()->Close();
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "base/bind_helpers.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "content/public/common/service_manager_connection.h"
|
||||
#include "content/public/browser/system_connector.h"
|
||||
#include "gin/dictionary.h"
|
||||
#include "gin/function_template.h"
|
||||
#include "services/device/public/mojom/constants.mojom.h"
|
||||
|
@ -87,17 +87,16 @@ void PowerSaveBlocker::UpdatePowerSaveBlocker() {
|
|||
|
||||
device::mojom::WakeLock* PowerSaveBlocker::GetWakeLock() {
|
||||
if (!wake_lock_) {
|
||||
device::mojom::WakeLockProviderPtr wake_lock_provider;
|
||||
DCHECK(content::ServiceManagerConnection::GetForProcess());
|
||||
auto* connector =
|
||||
content::ServiceManagerConnection::GetForProcess()->GetConnector();
|
||||
connector->BindInterface(device::mojom::kServiceName,
|
||||
mojo::MakeRequest(&wake_lock_provider));
|
||||
mojo::Remote<device::mojom::WakeLockProvider> wake_lock_provider;
|
||||
DCHECK(content::GetSystemConnector());
|
||||
content::GetSystemConnector()->Connect(
|
||||
device::mojom::kServiceName,
|
||||
wake_lock_provider.BindNewPipeAndPassReceiver());
|
||||
|
||||
wake_lock_provider->GetWakeLockWithoutContext(
|
||||
device::mojom::WakeLockType::kPreventAppSuspension,
|
||||
device::mojom::WakeLockReason::kOther, ELECTRON_PRODUCT_NAME,
|
||||
mojo::MakeRequest(&wake_lock_));
|
||||
wake_lock_.BindNewPipeAndPassReceiver());
|
||||
}
|
||||
return wake_lock_.get();
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "gin/handle.h"
|
||||
#include "gin/object_template_builder.h"
|
||||
#include "gin/wrappable.h"
|
||||
#include "mojo/public/cpp/bindings/remote.h"
|
||||
#include "services/device/public/mojom/wake_lock.mojom.h"
|
||||
|
||||
namespace electron {
|
||||
|
@ -49,7 +50,7 @@ class PowerSaveBlocker : public gin::Wrappable<PowerSaveBlocker> {
|
|||
using WakeLockTypeMap = std::map<int, device::mojom::WakeLockType>;
|
||||
WakeLockTypeMap wake_lock_types_;
|
||||
|
||||
device::mojom::WakeLockPtr wake_lock_;
|
||||
mojo::Remote<device::mojom::WakeLock> wake_lock_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(PowerSaveBlocker);
|
||||
};
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace predictors {
|
|||
// error. Probably upstream the constructor should be moved to
|
||||
// preconnect_manager.cc.
|
||||
PreconnectRequest::PreconnectRequest(
|
||||
const GURL& origin,
|
||||
const url::Origin& origin,
|
||||
int num_sockets,
|
||||
const net::NetworkIsolationKey& network_isolation_key)
|
||||
: origin(origin),
|
||||
|
@ -553,7 +553,7 @@ void Session::DownloadURL(const GURL& url) {
|
|||
auto* download_manager =
|
||||
content::BrowserContext::GetDownloadManager(browser_context());
|
||||
auto download_params = std::make_unique<download::DownloadUrlParameters>(
|
||||
url, MISSING_TRAFFIC_ANNOTATION);
|
||||
url, MISSING_TRAFFIC_ANNOTATION, net::NetworkIsolationKey());
|
||||
download_manager->DownloadUrl(std::move(download_params));
|
||||
}
|
||||
|
||||
|
@ -642,7 +642,8 @@ static void StartPreconnectOnUI(
|
|||
const GURL& url,
|
||||
int num_sockets_to_preconnect) {
|
||||
std::vector<predictors::PreconnectRequest> requests = {
|
||||
{url.GetOrigin(), num_sockets_to_preconnect, net::NetworkIsolationKey()}};
|
||||
{url::Origin::Create(url), num_sockets_to_preconnect,
|
||||
net::NetworkIsolationKey()}};
|
||||
browser_context->GetPreconnectManager()->Start(url, requests);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,9 @@ class BufferDataSource : public mojo::DataPipeProducer::DataSource {
|
|||
size_t readable_size = buffer_.size() - offset;
|
||||
size_t writable_size = buffer.size();
|
||||
size_t copyable_size = std::min(readable_size, writable_size);
|
||||
memcpy(buffer.data(), &buffer_[offset], copyable_size);
|
||||
if (copyable_size > 0) {
|
||||
memcpy(buffer.data(), &buffer_[offset], copyable_size);
|
||||
}
|
||||
result.bytes_read = copyable_size;
|
||||
} else {
|
||||
NOTREACHED();
|
||||
|
|
|
@ -1868,7 +1868,8 @@ void WebContents::Print(gin_helper::Arguments* args) {
|
|||
|
||||
std::vector<printing::PrinterBasicInfo> WebContents::GetPrinterList() {
|
||||
std::vector<printing::PrinterBasicInfo> printers;
|
||||
auto print_backend = printing::PrintBackend::CreateInstance(nullptr);
|
||||
auto print_backend = printing::PrintBackend::CreateInstance(
|
||||
nullptr, g_browser_process->GetApplicationLocale());
|
||||
{
|
||||
// TODO(deepak1556): Deprecate this api in favor of an
|
||||
// async version and post a non blocing task call.
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
#include "content/public/browser/keyboard_event_processing_result.h"
|
||||
#include "content/public/browser/render_widget_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/browser/web_contents_binding_set.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "content/public/common/favicon_url.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "electron/shell/common/api/api.mojom.h"
|
||||
#include "gin/handle.h"
|
||||
#include "mojo/public/cpp/bindings/binding_set.h"
|
||||
#include "printing/buildflags/buildflags.h"
|
||||
#include "services/service_manager/public/cpp/binder_registry.h"
|
||||
#include "shell/browser/api/frame_subscriber.h"
|
||||
|
|
|
@ -35,6 +35,11 @@ void GPUInfoEnumerator::AddTimeDeltaInSecondsF(const char* name,
|
|||
current->SetInteger(name, value.InMilliseconds());
|
||||
}
|
||||
|
||||
void GPUInfoEnumerator::AddBinary(const char* name,
|
||||
const base::span<const uint8_t>& value) {
|
||||
current->Set(name, std::make_unique<base::Value>(value));
|
||||
}
|
||||
|
||||
void GPUInfoEnumerator::BeginGPUDevice() {
|
||||
value_stack.push(std::move(current));
|
||||
current = std::make_unique<base::DictionaryValue>();
|
||||
|
|
|
@ -36,6 +36,8 @@ class GPUInfoEnumerator final : public gpu::GPUInfo::Enumerator {
|
|||
void AddBool(const char* name, bool value) override;
|
||||
void AddTimeDeltaInSecondsF(const char* name,
|
||||
const base::TimeDelta& value) override;
|
||||
void AddBinary(const char* name,
|
||||
const base::span<const uint8_t>& value) override;
|
||||
void BeginGPUDevice() override;
|
||||
void EndGPUDevice() override;
|
||||
void BeginVideoDecodeAcceleratorSupportedProfile() override;
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "services/device/public/cpp/geolocation/location_provider.h"
|
||||
#include "services/network/public/cpp/features.h"
|
||||
#include "services/network/public/cpp/resource_request_body.h"
|
||||
#include "services/service_manager/public/cpp/binder_map.h"
|
||||
#include "shell/app/manifests.h"
|
||||
#include "shell/browser/api/atom_api_app.h"
|
||||
#include "shell/browser/api/atom_api_protocol.h"
|
||||
|
@ -97,7 +98,6 @@
|
|||
#include "net/ssl/client_cert_store_win.h"
|
||||
#elif defined(OS_MACOSX)
|
||||
#include "net/ssl/client_cert_store_mac.h"
|
||||
#include "services/audio/public/mojom/constants.mojom.h"
|
||||
#elif defined(USE_OPENSSL)
|
||||
#include "net/ssl/client_cert_store.h"
|
||||
#endif
|
||||
|
@ -160,6 +160,12 @@ void SetApplicationLocaleOnIOThread(const std::string& locale) {
|
|||
g_io_thread_application_locale.Get() = locale;
|
||||
}
|
||||
|
||||
void BindNetworkHintsHandler(
|
||||
content::RenderFrameHost* frame_host,
|
||||
mojo::PendingReceiver<network_hints::mojom::NetworkHintsHandler> receiver) {
|
||||
NetworkHintsHandlerImpl::Create(frame_host, std::move(receiver));
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
const base::FilePath::StringPieceType kPathDelimiter = FILE_PATH_LITERAL(";");
|
||||
#else
|
||||
|
@ -368,6 +374,7 @@ void AtomBrowserClient::RenderProcessWillLaunch(
|
|||
prefs.disable_popups = web_preferences->IsEnabled("disablePopups");
|
||||
prefs.web_security = web_preferences->IsEnabled(options::kWebSecurity,
|
||||
true /* default value */);
|
||||
prefs.browser_context = host->GetBrowserContext();
|
||||
}
|
||||
|
||||
AddProcessPreferences(host->GetID(), prefs);
|
||||
|
@ -578,15 +585,6 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
|||
}
|
||||
}
|
||||
|
||||
void AtomBrowserClient::AdjustUtilityServiceProcessCommandLine(
|
||||
const service_manager::Identity& identity,
|
||||
base::CommandLine* command_line) {
|
||||
#if defined(OS_MACOSX)
|
||||
if (identity.name() == audio::mojom::kServiceName)
|
||||
command_line->AppendSwitch(::switches::kMessageLoopTypeUi);
|
||||
#endif
|
||||
}
|
||||
|
||||
void AtomBrowserClient::DidCreatePpapiPlugin(content::BrowserPpapiHost* host) {
|
||||
#if BUILDFLAG(ENABLE_PEPPER_FLASH)
|
||||
host->GetPpapiHost()->AddHostFactoryFilter(
|
||||
|
@ -625,12 +623,11 @@ void AtomBrowserClient::AllowCertificateError(
|
|||
const GURL& request_url,
|
||||
bool is_main_frame_request,
|
||||
bool strict_enforcement,
|
||||
const base::RepeatingCallback<void(content::CertificateRequestResultType)>&
|
||||
callback) {
|
||||
base::OnceCallback<void(content::CertificateRequestResultType)> callback) {
|
||||
if (delegate_) {
|
||||
delegate_->AllowCertificateError(web_contents, cert_error, ssl_info,
|
||||
request_url, is_main_frame_request,
|
||||
strict_enforcement, callback);
|
||||
strict_enforcement, std::move(callback));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -725,7 +722,7 @@ void AtomBrowserClient::SiteInstanceDeleting(
|
|||
}
|
||||
|
||||
std::unique_ptr<net::ClientCertStore> AtomBrowserClient::CreateClientCertStore(
|
||||
content::ResourceContext* resource_context) {
|
||||
content::BrowserContext* browser_context) {
|
||||
#if defined(USE_NSS_CERTS)
|
||||
return std::make_unique<net::ClientCertStoreNSS>(
|
||||
net::ClientCertStoreNSS::PasswordDelegateFactory());
|
||||
|
@ -833,9 +830,9 @@ void OnOpenExternal(const GURL& escaped_url, bool allowed) {
|
|||
|
||||
void HandleExternalProtocolInUI(
|
||||
const GURL& url,
|
||||
const content::WebContents::Getter& web_contents_getter,
|
||||
content::WebContents::OnceGetter web_contents_getter,
|
||||
bool has_user_gesture) {
|
||||
content::WebContents* web_contents = web_contents_getter.Run();
|
||||
content::WebContents* web_contents = std::move(web_contents_getter).Run();
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
|
@ -852,7 +849,7 @@ void HandleExternalProtocolInUI(
|
|||
|
||||
bool AtomBrowserClient::HandleExternalProtocol(
|
||||
const GURL& url,
|
||||
content::WebContents::Getter web_contents_getter,
|
||||
content::WebContents::OnceGetter web_contents_getter,
|
||||
int child_id,
|
||||
content::NavigationUIData* navigation_data,
|
||||
bool is_main_frame,
|
||||
|
@ -860,9 +857,10 @@ bool AtomBrowserClient::HandleExternalProtocol(
|
|||
bool has_user_gesture,
|
||||
const base::Optional<url::Origin>& initiating_origin,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
|
||||
base::PostTask(FROM_HERE, {BrowserThread::UI},
|
||||
base::BindOnce(&HandleExternalProtocolInUI, url,
|
||||
web_contents_getter, has_user_gesture));
|
||||
base::PostTask(
|
||||
FROM_HERE, {BrowserThread::UI},
|
||||
base::BindOnce(&HandleExternalProtocolInUI, url,
|
||||
std::move(web_contents_getter), has_user_gesture));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -981,10 +979,12 @@ bool AtomBrowserClient::WillCreateURLLoaderFactory(
|
|||
int render_process_id,
|
||||
URLLoaderFactoryType type,
|
||||
const url::Origin& request_initiator,
|
||||
base::Optional<int64_t> navigation_id,
|
||||
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
|
||||
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
|
||||
header_client,
|
||||
bool* bypass_redirect_checks) {
|
||||
bool* bypass_redirect_checks,
|
||||
network::mojom::URLLoaderFactoryOverridePtr* factory_override) {
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
api::Protocol* protocol =
|
||||
api::Protocol::FromWrappedClass(isolate, browser_context);
|
||||
|
@ -1001,44 +1001,32 @@ bool AtomBrowserClient::WillCreateURLLoaderFactory(
|
|||
if (header_client)
|
||||
header_client_receiver = header_client->InitWithNewPipeAndPassReceiver();
|
||||
|
||||
new ProxyingURLLoaderFactory(web_request.get(),
|
||||
protocol->intercept_handlers(), browser_context,
|
||||
render_process_id, std::move(proxied_receiver),
|
||||
std::move(target_factory_remote),
|
||||
std::move(header_client_receiver), type);
|
||||
new ProxyingURLLoaderFactory(
|
||||
web_request.get(), protocol->intercept_handlers(), browser_context,
|
||||
render_process_id, std::move(navigation_id), std::move(proxied_receiver),
|
||||
std::move(target_factory_remote), std::move(header_client_receiver),
|
||||
type);
|
||||
|
||||
if (bypass_redirect_checks)
|
||||
*bypass_redirect_checks = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
mojo::PendingRemote<network::mojom::URLLoaderFactory>
|
||||
AtomBrowserClient::CreateURLLoaderFactoryForNetworkRequests(
|
||||
content::RenderProcessHost* process,
|
||||
network::mojom::NetworkContext* network_context,
|
||||
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
|
||||
header_client,
|
||||
const url::Origin& request_initiator,
|
||||
const base::Optional<net::NetworkIsolationKey>& network_isolation_key) {
|
||||
auto render_process_id = process->GetID();
|
||||
auto it = process_preferences_.find(render_process_id);
|
||||
if (it != process_preferences_.end() && !it->second.web_security) {
|
||||
// bypass CORB
|
||||
network::mojom::URLLoaderFactoryParamsPtr params =
|
||||
network::mojom::URLLoaderFactoryParams::New();
|
||||
void AtomBrowserClient::OverrideURLLoaderFactoryParams(
|
||||
content::BrowserContext* browser_context,
|
||||
const url::Origin& origin,
|
||||
bool is_for_isolated_world,
|
||||
network::mojom::URLLoaderFactoryParams* factory_params) {
|
||||
for (const auto& iter : process_preferences_) {
|
||||
if (iter.second.browser_context != browser_context)
|
||||
continue;
|
||||
|
||||
if (header_client)
|
||||
params->header_client = std::move(*header_client);
|
||||
params->process_id = render_process_id;
|
||||
params->is_corb_enabled = false;
|
||||
|
||||
// Create the URLLoaderFactory.
|
||||
mojo::PendingRemote<network::mojom::URLLoaderFactory> factory_remote;
|
||||
network_context->CreateURLLoaderFactory(
|
||||
factory_remote.InitWithNewPipeAndPassReceiver(), std::move(params));
|
||||
return factory_remote;
|
||||
if (!iter.second.web_security) {
|
||||
// bypass CORB
|
||||
factory_params->process_id = iter.first;
|
||||
factory_params->is_corb_enabled = false;
|
||||
}
|
||||
}
|
||||
return mojo::NullRemote();
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
|
@ -1089,13 +1077,6 @@ bool AtomBrowserClient::ShouldEnableStrictSiteIsolation() {
|
|||
void AtomBrowserClient::BindHostReceiverForRenderer(
|
||||
content::RenderProcessHost* render_process_host,
|
||||
mojo::GenericPendingReceiver receiver) {
|
||||
if (auto host_receiver =
|
||||
receiver.As<network_hints::mojom::NetworkHintsHandler>()) {
|
||||
NetworkHintsHandlerImpl::Create(render_process_host->GetID(),
|
||||
std::move(host_receiver));
|
||||
return;
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
if (auto host_receiver = receiver.As<spellcheck::mojom::SpellCheckHost>()) {
|
||||
SpellCheckHostChromeImpl::Create(render_process_host->GetID(),
|
||||
|
@ -1105,6 +1086,13 @@ void AtomBrowserClient::BindHostReceiverForRenderer(
|
|||
#endif
|
||||
}
|
||||
|
||||
void AtomBrowserClient::RegisterBrowserInterfaceBindersForFrame(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
service_manager::BinderMapWithContext<content::RenderFrameHost*>* map) {
|
||||
map->Add<network_hints::mojom::NetworkHintsHandler>(
|
||||
base::BindRepeating(&BindNetworkHintsHandler));
|
||||
}
|
||||
|
||||
std::unique_ptr<content::LoginDelegate> AtomBrowserClient::CreateLoginDelegate(
|
||||
const net::AuthChallengeInfo& auth_info,
|
||||
content::WebContents* web_contents,
|
||||
|
|
|
@ -67,6 +67,10 @@ class AtomBrowserClient : public content::ContentBrowserClient,
|
|||
void BindHostReceiverForRenderer(
|
||||
content::RenderProcessHost* render_process_host,
|
||||
mojo::GenericPendingReceiver receiver) override;
|
||||
void RegisterBrowserInterfaceBindersForFrame(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
service_manager::BinderMapWithContext<content::RenderFrameHost*>* map)
|
||||
override;
|
||||
|
||||
std::string GetUserAgent() override;
|
||||
void SetUserAgent(const std::string& user_agent);
|
||||
|
@ -94,9 +98,6 @@ class AtomBrowserClient : public content::ContentBrowserClient,
|
|||
content::SiteInstance* pending_site_instance) override;
|
||||
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
|
||||
int child_process_id) override;
|
||||
void AdjustUtilityServiceProcessCommandLine(
|
||||
const service_manager::Identity& identity,
|
||||
base::CommandLine* command_line) override;
|
||||
void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
|
||||
std::string GetGeolocationApiKey() override;
|
||||
scoped_refptr<content::QuotaPermissionContext> CreateQuotaPermissionContext()
|
||||
|
@ -110,8 +111,8 @@ class AtomBrowserClient : public content::ContentBrowserClient,
|
|||
const GURL& request_url,
|
||||
bool is_main_frame_request,
|
||||
bool strict_enforcement,
|
||||
const base::Callback<void(content::CertificateRequestResultType)>&
|
||||
callback) override;
|
||||
base::OnceCallback<void(content::CertificateRequestResultType)> callback)
|
||||
override;
|
||||
base::OnceClosure SelectClientCertificate(
|
||||
content::WebContents* web_contents,
|
||||
net::SSLCertRequestInfo* cert_request_info,
|
||||
|
@ -142,7 +143,7 @@ class AtomBrowserClient : public content::ContentBrowserClient,
|
|||
std::vector<std::string>* additional_schemes) override;
|
||||
void SiteInstanceDeleting(content::SiteInstance* site_instance) override;
|
||||
std::unique_ptr<net::ClientCertStore> CreateClientCertStore(
|
||||
content::ResourceContext* resource_context) override;
|
||||
content::BrowserContext* browser_context) override;
|
||||
std::unique_ptr<device::LocationProvider> OverrideSystemLocationProvider()
|
||||
override;
|
||||
mojo::Remote<network::mojom::NetworkContext> CreateNetworkContext(
|
||||
|
@ -178,19 +179,17 @@ class AtomBrowserClient : public content::ContentBrowserClient,
|
|||
int render_process_id,
|
||||
URLLoaderFactoryType type,
|
||||
const url::Origin& request_initiator,
|
||||
base::Optional<int64_t> navigation_id,
|
||||
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
|
||||
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
|
||||
header_client,
|
||||
bool* bypass_redirect_checks) override;
|
||||
mojo::PendingRemote<network::mojom::URLLoaderFactory>
|
||||
CreateURLLoaderFactoryForNetworkRequests(
|
||||
content::RenderProcessHost* process,
|
||||
network::mojom::NetworkContext* network_context,
|
||||
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
|
||||
header_client,
|
||||
const url::Origin& request_initiator,
|
||||
const base::Optional<net::NetworkIsolationKey>& network_isolation_key)
|
||||
override;
|
||||
bool* bypass_redirect_checks,
|
||||
network::mojom::URLLoaderFactoryOverridePtr* factory_override) override;
|
||||
void OverrideURLLoaderFactoryParams(
|
||||
content::BrowserContext* browser_context,
|
||||
const url::Origin& origin,
|
||||
bool is_for_isolated_world,
|
||||
network::mojom::URLLoaderFactoryParams* factory_params) override;
|
||||
#if defined(OS_WIN)
|
||||
bool PreSpawnRenderer(sandbox::TargetPolicy* policy,
|
||||
RendererSpawnFlags flags) override;
|
||||
|
@ -202,7 +201,7 @@ class AtomBrowserClient : public content::ContentBrowserClient,
|
|||
|
||||
bool HandleExternalProtocol(
|
||||
const GURL& url,
|
||||
content::WebContents::Getter web_contents_getter,
|
||||
content::WebContents::OnceGetter web_contents_getter,
|
||||
int child_id,
|
||||
content::NavigationUIData* navigation_data,
|
||||
bool is_main_frame,
|
||||
|
@ -234,6 +233,7 @@ class AtomBrowserClient : public content::ContentBrowserClient,
|
|||
bool native_window_open = false;
|
||||
bool disable_popups = false;
|
||||
bool web_security = true;
|
||||
content::BrowserContext* browser_context = nullptr;
|
||||
};
|
||||
|
||||
bool ShouldForceNewSiteInstance(content::RenderFrameHost* current_rfh,
|
||||
|
|
|
@ -322,7 +322,8 @@ AtomBrowserContext::GetURLLoaderFactory() {
|
|||
->WillCreateURLLoaderFactory(
|
||||
this, nullptr, -1,
|
||||
content::ContentBrowserClient::URLLoaderFactoryType::kNavigation,
|
||||
url::Origin(), &factory_receiver, &header_client, nullptr);
|
||||
url::Origin(), base::nullopt, &factory_receiver, &header_client,
|
||||
nullptr, nullptr);
|
||||
|
||||
network::mojom::URLLoaderFactoryParamsPtr params =
|
||||
network::mojom::URLLoaderFactoryParams::New();
|
||||
|
|
|
@ -22,11 +22,11 @@
|
|||
#include "chrome/browser/icon_manager.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/child_process_security_policy.h"
|
||||
#include "content/public/browser/system_connector.h"
|
||||
#include "content/public/browser/web_ui_controller_factory.h"
|
||||
#include "content/public/common/content_features.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "content/public/common/result_codes.h"
|
||||
#include "content/public/common/service_manager_connection.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "media/base/localized_strings.h"
|
||||
#include "services/device/public/mojom/constants.mojom.h"
|
||||
|
@ -562,13 +562,10 @@ AtomBrowserMainParts::GetGeolocationControl() {
|
|||
if (geolocation_control_)
|
||||
return geolocation_control_.get();
|
||||
|
||||
auto request = mojo::MakeRequest(&geolocation_control_);
|
||||
if (!content::ServiceManagerConnection::GetForProcess())
|
||||
return geolocation_control_.get();
|
||||
|
||||
service_manager::Connector* connector =
|
||||
content::ServiceManagerConnection::GetForProcess()->GetConnector();
|
||||
connector->BindInterface(device::mojom::kServiceName, std::move(request));
|
||||
auto receiver = geolocation_control_.BindNewPipeAndPassReceiver();
|
||||
service_manager::Connector* connector = content::GetSystemConnector();
|
||||
if (connector)
|
||||
connector->Connect(device::mojom::kServiceName, std::move(receiver));
|
||||
return geolocation_control_.get();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "content/public/browser/browser_main_parts.h"
|
||||
#include "content/public/common/main_function_params.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "mojo/public/cpp/bindings/remote.h"
|
||||
#include "services/device/public/mojom/geolocation_control.mojom.h"
|
||||
#include "ui/views/layout/layout_provider.h"
|
||||
|
||||
|
@ -147,7 +148,7 @@ class AtomBrowserMainParts : public content::BrowserMainParts {
|
|||
// List of callbacks should be executed before destroying JS env.
|
||||
std::list<base::OnceClosure> destructors_;
|
||||
|
||||
device::mojom::GeolocationControlPtr geolocation_control_;
|
||||
mojo::Remote<device::mojom::GeolocationControl> geolocation_control_;
|
||||
|
||||
static AtomBrowserMainParts* self_;
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "base/lazy_instance.h"
|
||||
#include "base/logging.h"
|
||||
#include "extensions/browser/media_capture_util.h"
|
||||
#include "extensions/browser/serial_extension_host_queue.h"
|
||||
#include "shell/browser/extensions/atom_extension_web_contents_observer.h"
|
||||
|
||||
namespace extensions {
|
||||
|
@ -65,13 +64,6 @@ bool AtomExtensionHostDelegate::CheckMediaAccessPermission(
|
|||
return true;
|
||||
}
|
||||
|
||||
static base::LazyInstance<SerialExtensionHostQueue>::DestructorAtExit g_queue =
|
||||
LAZY_INSTANCE_INITIALIZER;
|
||||
|
||||
ExtensionHostQueue* AtomExtensionHostDelegate::GetExtensionHostQueue() const {
|
||||
return g_queue.Pointer();
|
||||
}
|
||||
|
||||
content::PictureInPictureResult
|
||||
AtomExtensionHostDelegate::EnterPictureInPicture(
|
||||
content::WebContents* web_contents,
|
||||
|
|
|
@ -36,7 +36,6 @@ class AtomExtensionHostDelegate : public ExtensionHostDelegate {
|
|||
const GURL& security_origin,
|
||||
blink::mojom::MediaStreamType type,
|
||||
const Extension* extension) override;
|
||||
ExtensionHostQueue* GetExtensionHostQueue() const override;
|
||||
content::PictureInPictureResult EnterPictureInPicture(
|
||||
content::WebContents* web_contents,
|
||||
const viz::SurfaceId& surface_id,
|
||||
|
|
|
@ -129,11 +129,11 @@ base::FilePath AtomExtensionsBrowserClient::GetBundleResourcePath(
|
|||
|
||||
void AtomExtensionsBrowserClient::LoadResourceFromResourceBundle(
|
||||
const network::ResourceRequest& request,
|
||||
network::mojom::URLLoaderRequest loader,
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
||||
const base::FilePath& resource_relative_path,
|
||||
int resource_id,
|
||||
const std::string& content_security_policy,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
bool send_cors_header) {
|
||||
NOTREACHED() << "Load resources from bundles not supported.";
|
||||
}
|
||||
|
@ -297,4 +297,9 @@ std::string AtomExtensionsBrowserClient::GetUserAgent() const {
|
|||
return AtomBrowserClient::Get()->GetUserAgent();
|
||||
}
|
||||
|
||||
void AtomExtensionsBrowserClient::RegisterBrowserInterfaceBindersForFrame(
|
||||
service_manager::BinderMapWithContext<content::RenderFrameHost*>* map,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const extensions::Extension* extension) const {}
|
||||
|
||||
} // namespace electron
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "base/macros.h"
|
||||
#include "build/build_config.h"
|
||||
#include "extensions/browser/extensions_browser_client.h"
|
||||
#include "mojo/public/cpp/bindings/pending_remote.h"
|
||||
|
||||
class PrefService;
|
||||
|
||||
|
@ -59,11 +60,11 @@ class AtomExtensionsBrowserClient : public extensions::ExtensionsBrowserClient {
|
|||
int* resource_id) const override;
|
||||
void LoadResourceFromResourceBundle(
|
||||
const network::ResourceRequest& request,
|
||||
network::mojom::URLLoaderRequest loader,
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
||||
const base::FilePath& resource_relative_path,
|
||||
int resource_id,
|
||||
const std::string& content_security_policy,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
bool send_cors_header) override;
|
||||
bool AllowCrossRendererResourceLoad(
|
||||
const GURL& url,
|
||||
|
@ -116,6 +117,10 @@ class AtomExtensionsBrowserClient : public extensions::ExtensionsBrowserClient {
|
|||
bool IsLockScreenContext(content::BrowserContext* context) override;
|
||||
std::string GetApplicationLocale() override;
|
||||
std::string GetUserAgent() const override;
|
||||
void RegisterBrowserInterfaceBindersForFrame(
|
||||
service_manager::BinderMapWithContext<content::RenderFrameHost*>* map,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const extensions::Extension* extension) const override;
|
||||
|
||||
// |context| is the single BrowserContext used for IsValidContext().
|
||||
// |pref_service| is used for GetPrefServiceForContext().
|
||||
|
|
|
@ -10,7 +10,8 @@ namespace electron {
|
|||
|
||||
MicrotasksRunner::MicrotasksRunner(v8::Isolate* isolate) : isolate_(isolate) {}
|
||||
|
||||
void MicrotasksRunner::WillProcessTask(const base::PendingTask& pending_task) {}
|
||||
void MicrotasksRunner::WillProcessTask(const base::PendingTask& pending_task,
|
||||
bool was_blocked_or_low_priority) {}
|
||||
|
||||
void MicrotasksRunner::DidProcessTask(const base::PendingTask& pending_task) {
|
||||
v8::Isolate::Scope scope(isolate_);
|
||||
|
|
|
@ -24,7 +24,8 @@ class MicrotasksRunner : public base::TaskObserver {
|
|||
explicit MicrotasksRunner(v8::Isolate* isolate);
|
||||
|
||||
// base::TaskObserver
|
||||
void WillProcessTask(const base::PendingTask& pending_task) override;
|
||||
void WillProcessTask(const base::PendingTask& pending_task,
|
||||
bool was_blocked_or_low_priority) override;
|
||||
void DidProcessTask(const base::PendingTask& pending_task) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -174,7 +174,7 @@ NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options,
|
|||
params.remove_standard_frame = !has_frame();
|
||||
|
||||
if (transparent())
|
||||
params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
|
||||
params.opacity = views::Widget::InitParams::WindowOpacity::kTranslucent;
|
||||
|
||||
// The given window is most likely not rectangular since it uses
|
||||
// transparency and has no standard frame, don't show a shadow for it.
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/file_url_loader.h"
|
||||
#include "mojo/public/cpp/bindings/receiver.h"
|
||||
#include "mojo/public/cpp/bindings/remote.h"
|
||||
#include "mojo/public/cpp/system/data_pipe_producer.h"
|
||||
#include "mojo/public/cpp/system/file_data_source.h"
|
||||
#include "net/base/filename_util.h"
|
||||
|
@ -59,13 +60,13 @@ class AsarURLLoader : public network::mojom::URLLoader {
|
|||
static void CreateAndStart(
|
||||
const network::ResourceRequest& request,
|
||||
network::mojom::URLLoaderRequest loader,
|
||||
network::mojom::URLLoaderClientPtrInfo client_info,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
scoped_refptr<net::HttpResponseHeaders> extra_response_headers) {
|
||||
// Owns itself. Will live as long as its URLLoader and URLLoaderClientPtr
|
||||
// bindings are alive - essentially until either the client gives up or all
|
||||
// file data has been sent to it.
|
||||
auto* asar_url_loader = new AsarURLLoader;
|
||||
asar_url_loader->Start(request, std::move(loader), std::move(client_info),
|
||||
asar_url_loader->Start(request, std::move(loader), std::move(client),
|
||||
std::move(extra_response_headers));
|
||||
}
|
||||
|
||||
|
@ -84,18 +85,20 @@ class AsarURLLoader : public network::mojom::URLLoader {
|
|||
|
||||
void Start(const network::ResourceRequest& request,
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
||||
network::mojom::URLLoaderClientPtrInfo client_info,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
scoped_refptr<net::HttpResponseHeaders> extra_response_headers) {
|
||||
network::ResourceResponseHead head;
|
||||
head.request_start = base::TimeTicks::Now();
|
||||
head.response_start = base::TimeTicks::Now();
|
||||
head.headers = extra_response_headers;
|
||||
|
||||
client_.Bind(std::move(client_info));
|
||||
|
||||
base::FilePath path;
|
||||
if (!net::FileURLToFilePath(request.url, &path)) {
|
||||
OnClientComplete(net::ERR_FAILED);
|
||||
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
|
||||
std::move(client));
|
||||
client_remote->OnComplete(
|
||||
network::URLLoaderCompletionStatus(net::ERR_FAILED));
|
||||
MaybeDeleteSelf();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -103,12 +106,13 @@ class AsarURLLoader : public network::mojom::URLLoader {
|
|||
base::FilePath asar_path, relative_path;
|
||||
if (!GetAsarArchivePath(path, &asar_path, &relative_path)) {
|
||||
content::CreateFileURLLoader(request, std::move(loader),
|
||||
std::move(client_), nullptr, false,
|
||||
std::move(client), nullptr, false,
|
||||
extra_response_headers);
|
||||
MaybeDeleteSelf();
|
||||
return;
|
||||
}
|
||||
|
||||
client_.Bind(std::move(client));
|
||||
receiver_.Bind(std::move(loader));
|
||||
receiver_.set_disconnect_handler(base::BindOnce(
|
||||
&AsarURLLoader::OnConnectionError, base::Unretained(this)));
|
||||
|
@ -281,7 +285,7 @@ class AsarURLLoader : public network::mojom::URLLoader {
|
|||
|
||||
std::unique_ptr<mojo::DataPipeProducer> data_producer_;
|
||||
mojo::Receiver<network::mojom::URLLoader> receiver_{this};
|
||||
network::mojom::URLLoaderClientPtr client_;
|
||||
mojo::Remote<network::mojom::URLLoaderClient> client_;
|
||||
|
||||
// In case of successful loads, this holds the total number of bytes written
|
||||
// to the response (this may be smaller than the total size of the file when
|
||||
|
@ -298,15 +302,15 @@ class AsarURLLoader : public network::mojom::URLLoader {
|
|||
void CreateAsarURLLoader(
|
||||
const network::ResourceRequest& request,
|
||||
network::mojom::URLLoaderRequest loader,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
scoped_refptr<net::HttpResponseHeaders> extra_response_headers) {
|
||||
auto task_runner = base::CreateSequencedTaskRunner(
|
||||
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::USER_VISIBLE,
|
||||
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN});
|
||||
task_runner->PostTask(
|
||||
FROM_HERE, base::BindOnce(&AsarURLLoader::CreateAndStart, request,
|
||||
std::move(loader), client.PassInterface(),
|
||||
std::move(extra_response_headers)));
|
||||
FROM_HERE,
|
||||
base::BindOnce(&AsarURLLoader::CreateAndStart, request, std::move(loader),
|
||||
std::move(client), std::move(extra_response_headers)));
|
||||
}
|
||||
|
||||
} // namespace asar
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#ifndef SHELL_BROWSER_NET_ASAR_ASAR_URL_LOADER_H_
|
||||
#define SHELL_BROWSER_NET_ASAR_ASAR_URL_LOADER_H_
|
||||
|
||||
#include "mojo/public/cpp/bindings/pending_remote.h"
|
||||
#include "services/network/public/mojom/url_loader.mojom.h"
|
||||
|
||||
namespace asar {
|
||||
|
@ -12,7 +13,7 @@ namespace asar {
|
|||
void CreateAsarURLLoader(
|
||||
const network::ResourceRequest& request,
|
||||
network::mojom::URLLoaderRequest loader,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
scoped_refptr<net::HttpResponseHeaders> extra_response_headers);
|
||||
|
||||
} // namespace asar
|
||||
|
|
|
@ -141,7 +141,7 @@ network::ResourceResponseHead ToResponseHead(
|
|||
|
||||
// Helper to write string to pipe.
|
||||
struct WriteData {
|
||||
network::mojom::URLLoaderClientPtr client;
|
||||
mojo::Remote<network::mojom::URLLoaderClient> client;
|
||||
std::string data;
|
||||
std::unique_ptr<mojo::DataPipeProducer> producer;
|
||||
};
|
||||
|
@ -173,7 +173,7 @@ void AtomURLLoaderFactory::CreateLoaderAndStart(
|
|||
int32_t request_id,
|
||||
uint32_t options,
|
||||
const network::ResourceRequest& request,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
handler_.Run(
|
||||
|
@ -195,7 +195,7 @@ void AtomURLLoaderFactory::StartLoading(
|
|||
int32_t request_id,
|
||||
uint32_t options,
|
||||
const network::ResourceRequest& request,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
|
||||
network::mojom::URLLoaderFactory* proxy_factory,
|
||||
ProtocolType type,
|
||||
|
@ -206,7 +206,9 @@ void AtomURLLoaderFactory::StartLoading(
|
|||
// passed, to keep compatibility with old code.
|
||||
v8::Local<v8::Value> response;
|
||||
if (!args->GetNext(&response)) {
|
||||
client->OnComplete(
|
||||
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
|
||||
std::move(client));
|
||||
client_remote->OnComplete(
|
||||
network::URLLoaderCompletionStatus(net::ERR_NOT_IMPLEMENTED));
|
||||
return;
|
||||
}
|
||||
|
@ -216,7 +218,9 @@ void AtomURLLoaderFactory::StartLoading(
|
|||
if (!dict.IsEmpty()) {
|
||||
int error_code;
|
||||
if (dict.Get("error", &error_code)) {
|
||||
client->OnComplete(network::URLLoaderCompletionStatus(error_code));
|
||||
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
|
||||
std::move(client));
|
||||
client_remote->OnComplete(network::URLLoaderCompletionStatus(error_code));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -260,7 +264,9 @@ void AtomURLLoaderFactory::StartLoading(
|
|||
|
||||
// Some protocol accepts non-object responses.
|
||||
if (dict.IsEmpty() && ResponseMustBeObject(type)) {
|
||||
client->OnComplete(
|
||||
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
|
||||
std::move(client));
|
||||
client_remote->OnComplete(
|
||||
network::URLLoaderCompletionStatus(net::ERR_NOT_IMPLEMENTED));
|
||||
return;
|
||||
}
|
||||
|
@ -288,7 +294,10 @@ void AtomURLLoaderFactory::StartLoading(
|
|||
case ProtocolType::kFree:
|
||||
ProtocolType type;
|
||||
if (!gin::ConvertFromV8(args->isolate(), response, &type)) {
|
||||
client->OnComplete(network::URLLoaderCompletionStatus(net::ERR_FAILED));
|
||||
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
|
||||
std::move(client));
|
||||
client_remote->OnComplete(
|
||||
network::URLLoaderCompletionStatus(net::ERR_FAILED));
|
||||
return;
|
||||
}
|
||||
StartLoading(std::move(loader), routing_id, request_id, options, request,
|
||||
|
@ -300,13 +309,16 @@ void AtomURLLoaderFactory::StartLoading(
|
|||
|
||||
// static
|
||||
void AtomURLLoaderFactory::StartLoadingBuffer(
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
network::ResourceResponseHead head,
|
||||
const gin_helper::Dictionary& dict) {
|
||||
v8::Local<v8::Value> buffer = dict.GetHandle();
|
||||
dict.Get("data", &buffer);
|
||||
if (!node::Buffer::HasInstance(buffer)) {
|
||||
client->OnComplete(network::URLLoaderCompletionStatus(net::ERR_FAILED));
|
||||
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
|
||||
std::move(client));
|
||||
client_remote->OnComplete(
|
||||
network::URLLoaderCompletionStatus(net::ERR_FAILED));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -317,7 +329,7 @@ void AtomURLLoaderFactory::StartLoadingBuffer(
|
|||
|
||||
// static
|
||||
void AtomURLLoaderFactory::StartLoadingString(
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
network::ResourceResponseHead head,
|
||||
const gin_helper::Dictionary& dict,
|
||||
v8::Isolate* isolate,
|
||||
|
@ -328,7 +340,10 @@ void AtomURLLoaderFactory::StartLoadingString(
|
|||
} else if (!dict.IsEmpty()) {
|
||||
dict.Get("data", &contents);
|
||||
} else {
|
||||
client->OnComplete(network::URLLoaderCompletionStatus(net::ERR_FAILED));
|
||||
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
|
||||
std::move(client));
|
||||
client_remote->OnComplete(
|
||||
network::URLLoaderCompletionStatus(net::ERR_FAILED));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -339,7 +354,7 @@ void AtomURLLoaderFactory::StartLoadingString(
|
|||
void AtomURLLoaderFactory::StartLoadingFile(
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
||||
network::ResourceRequest request,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
network::ResourceResponseHead head,
|
||||
const gin_helper::Dictionary& dict,
|
||||
v8::Isolate* isolate,
|
||||
|
@ -353,7 +368,10 @@ void AtomURLLoaderFactory::StartLoadingFile(
|
|||
if (dict.Get("path", &path))
|
||||
request.url = net::FilePathToFileURL(path);
|
||||
} else {
|
||||
client->OnComplete(network::URLLoaderCompletionStatus(net::ERR_FAILED));
|
||||
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
|
||||
std::move(client));
|
||||
client_remote->OnComplete(
|
||||
network::URLLoaderCompletionStatus(net::ERR_FAILED));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -366,7 +384,7 @@ void AtomURLLoaderFactory::StartLoadingFile(
|
|||
void AtomURLLoaderFactory::StartLoadingHttp(
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
||||
const network::ResourceRequest& original_request,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
|
||||
const gin_helper::Dictionary& dict) {
|
||||
auto request = std::make_unique<network::ResourceRequest>();
|
||||
|
@ -407,7 +425,7 @@ void AtomURLLoaderFactory::StartLoadingHttp(
|
|||
// static
|
||||
void AtomURLLoaderFactory::StartLoadingStream(
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
network::ResourceResponseHead head,
|
||||
const gin_helper::Dictionary& dict) {
|
||||
v8::Local<v8::Value> stream;
|
||||
|
@ -415,25 +433,30 @@ void AtomURLLoaderFactory::StartLoadingStream(
|
|||
// Assume the opts is already a stream.
|
||||
stream = dict.GetHandle();
|
||||
} else if (stream->IsNullOrUndefined()) {
|
||||
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
|
||||
std::move(client));
|
||||
// "data" was explicitly passed as null or undefined, assume the user wants
|
||||
// to send an empty body.
|
||||
//
|
||||
// Note that We must submit a empty body otherwise NetworkService would
|
||||
// crash.
|
||||
client->OnReceiveResponse(head);
|
||||
client_remote->OnReceiveResponse(head);
|
||||
mojo::ScopedDataPipeProducerHandle producer;
|
||||
mojo::ScopedDataPipeConsumerHandle consumer;
|
||||
if (mojo::CreateDataPipe(nullptr, &producer, &consumer) != MOJO_RESULT_OK) {
|
||||
client->OnComplete(
|
||||
client_remote->OnComplete(
|
||||
network::URLLoaderCompletionStatus(net::ERR_INSUFFICIENT_RESOURCES));
|
||||
return;
|
||||
}
|
||||
producer.reset(); // The data pipe is empty.
|
||||
client->OnStartLoadingResponseBody(std::move(consumer));
|
||||
client->OnComplete(network::URLLoaderCompletionStatus(net::OK));
|
||||
client_remote->OnStartLoadingResponseBody(std::move(consumer));
|
||||
client_remote->OnComplete(network::URLLoaderCompletionStatus(net::OK));
|
||||
return;
|
||||
} else if (!stream->IsObject()) {
|
||||
client->OnComplete(network::URLLoaderCompletionStatus(net::ERR_FAILED));
|
||||
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
|
||||
std::move(client));
|
||||
client_remote->OnComplete(
|
||||
network::URLLoaderCompletionStatus(net::ERR_FAILED));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -441,7 +464,10 @@ void AtomURLLoaderFactory::StartLoadingStream(
|
|||
v8::Local<v8::Value> method;
|
||||
if (!data.Get("on", &method) || !method->IsFunction() ||
|
||||
!data.Get("removeListener", &method) || !method->IsFunction()) {
|
||||
client->OnComplete(network::URLLoaderCompletionStatus(net::ERR_FAILED));
|
||||
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
|
||||
std::move(client));
|
||||
client_remote->OnComplete(
|
||||
network::URLLoaderCompletionStatus(net::ERR_FAILED));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -451,25 +477,27 @@ void AtomURLLoaderFactory::StartLoadingStream(
|
|||
|
||||
// static
|
||||
void AtomURLLoaderFactory::SendContents(
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
network::ResourceResponseHead head,
|
||||
std::string data) {
|
||||
mojo::Remote<network::mojom::URLLoaderClient> client_remote(
|
||||
std::move(client));
|
||||
head.headers->AddHeader(kCORSHeader);
|
||||
client->OnReceiveResponse(head);
|
||||
client_remote->OnReceiveResponse(head);
|
||||
|
||||
// Code bellow follows the pattern of data_url_loader_factory.cc.
|
||||
mojo::ScopedDataPipeProducerHandle producer;
|
||||
mojo::ScopedDataPipeConsumerHandle consumer;
|
||||
if (mojo::CreateDataPipe(nullptr, &producer, &consumer) != MOJO_RESULT_OK) {
|
||||
client->OnComplete(
|
||||
client_remote->OnComplete(
|
||||
network::URLLoaderCompletionStatus(net::ERR_INSUFFICIENT_RESOURCES));
|
||||
return;
|
||||
}
|
||||
|
||||
client->OnStartLoadingResponseBody(std::move(consumer));
|
||||
client_remote->OnStartLoadingResponseBody(std::move(consumer));
|
||||
|
||||
auto write_data = std::make_unique<WriteData>();
|
||||
write_data->client = std::move(client);
|
||||
write_data->client = std::move(client_remote);
|
||||
write_data->data = std::move(data);
|
||||
write_data->producer =
|
||||
std::make_unique<mojo::DataPipeProducer>(std::move(producer));
|
||||
|
|
|
@ -10,7 +10,9 @@
|
|||
#include <utility>
|
||||
|
||||
#include "mojo/public/cpp/bindings/pending_receiver.h"
|
||||
#include "mojo/public/cpp/bindings/pending_remote.h"
|
||||
#include "mojo/public/cpp/bindings/receiver_set.h"
|
||||
#include "mojo/public/cpp/bindings/remote.h"
|
||||
#include "net/url_request/url_request_job_factory.h"
|
||||
#include "services/network/public/cpp/resource_response.h"
|
||||
#include "services/network/public/mojom/url_loader_factory.mojom.h"
|
||||
|
@ -49,7 +51,7 @@ class AtomURLLoaderFactory : public network::mojom::URLLoaderFactory {
|
|||
int32_t request_id,
|
||||
uint32_t options,
|
||||
const network::ResourceRequest& request,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation)
|
||||
override;
|
||||
void Clone(mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver)
|
||||
|
@ -61,25 +63,27 @@ class AtomURLLoaderFactory : public network::mojom::URLLoaderFactory {
|
|||
int32_t request_id,
|
||||
uint32_t options,
|
||||
const network::ResourceRequest& request,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
|
||||
network::mojom::URLLoaderFactory* proxy_factory,
|
||||
ProtocolType type,
|
||||
gin::Arguments* args);
|
||||
|
||||
private:
|
||||
static void StartLoadingBuffer(network::mojom::URLLoaderClientPtr client,
|
||||
network::ResourceResponseHead head,
|
||||
const gin_helper::Dictionary& dict);
|
||||
static void StartLoadingString(network::mojom::URLLoaderClientPtr client,
|
||||
network::ResourceResponseHead head,
|
||||
const gin_helper::Dictionary& dict,
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> response);
|
||||
static void StartLoadingBuffer(
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
network::ResourceResponseHead head,
|
||||
const gin_helper::Dictionary& dict);
|
||||
static void StartLoadingString(
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
network::ResourceResponseHead head,
|
||||
const gin_helper::Dictionary& dict,
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> response);
|
||||
static void StartLoadingFile(
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
||||
network::ResourceRequest request,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
network::ResourceResponseHead head,
|
||||
const gin_helper::Dictionary& dict,
|
||||
v8::Isolate* isolate,
|
||||
|
@ -87,19 +91,20 @@ class AtomURLLoaderFactory : public network::mojom::URLLoaderFactory {
|
|||
static void StartLoadingHttp(
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
||||
const network::ResourceRequest& original_request,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
|
||||
const gin_helper::Dictionary& dict);
|
||||
static void StartLoadingStream(
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
network::ResourceResponseHead head,
|
||||
const gin_helper::Dictionary& dict);
|
||||
|
||||
// Helper to send string as response.
|
||||
static void SendContents(network::mojom::URLLoaderClientPtr client,
|
||||
network::ResourceResponseHead head,
|
||||
std::string data);
|
||||
static void SendContents(
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
network::ResourceResponseHead head,
|
||||
std::string data);
|
||||
|
||||
// TODO(zcbenz): This comes from extensions/browser/extension_protocols.cc
|
||||
// but I don't know what it actually does, find out the meanings of |Clone|
|
||||
|
|
|
@ -12,11 +12,12 @@
|
|||
|
||||
namespace electron {
|
||||
|
||||
NodeStreamLoader::NodeStreamLoader(network::ResourceResponseHead head,
|
||||
network::mojom::URLLoaderRequest loader,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> emitter)
|
||||
NodeStreamLoader::NodeStreamLoader(
|
||||
network::ResourceResponseHead head,
|
||||
network::mojom::URLLoaderRequest loader,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> emitter)
|
||||
: binding_(this, std::move(loader)),
|
||||
client_(std::move(client)),
|
||||
isolate_(isolate),
|
||||
|
@ -53,7 +54,6 @@ void NodeStreamLoader::Start(network::ResourceResponseHead head) {
|
|||
}
|
||||
|
||||
producer_ = std::make_unique<mojo::DataPipeProducer>(std::move(producer));
|
||||
|
||||
client_->OnReceiveResponse(head);
|
||||
client_->OnStartLoadingResponseBody(std::move(consumer));
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "mojo/public/cpp/bindings/pending_remote.h"
|
||||
#include "mojo/public/cpp/bindings/remote.h"
|
||||
#include "mojo/public/cpp/bindings/strong_binding.h"
|
||||
#include "mojo/public/cpp/system/data_pipe_producer.h"
|
||||
#include "services/network/public/cpp/resource_response.h"
|
||||
|
@ -30,7 +32,7 @@ class NodeStreamLoader : public network::mojom::URLLoader {
|
|||
public:
|
||||
NodeStreamLoader(network::ResourceResponseHead head,
|
||||
network::mojom::URLLoaderRequest loader,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> emitter);
|
||||
|
||||
|
@ -58,7 +60,7 @@ class NodeStreamLoader : public network::mojom::URLLoader {
|
|||
void ResumeReadingBodyFromNet() override {}
|
||||
|
||||
mojo::Binding<network::mojom::URLLoader> binding_;
|
||||
network::mojom::URLLoaderClientPtr client_;
|
||||
mojo::Remote<network::mojom::URLLoaderClient> client_;
|
||||
|
||||
v8::Isolate* isolate_;
|
||||
v8::Global<v8::Object> emitter_;
|
||||
|
|
|
@ -40,7 +40,7 @@ ProxyingURLLoaderFactory::InProgressRequest::InProgressRequest(
|
|||
const network::ResourceRequest& request,
|
||||
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
|
||||
network::mojom::URLLoaderRequest loader_request,
|
||||
network::mojom::URLLoaderClientPtr client)
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client)
|
||||
: factory_(factory),
|
||||
request_(request),
|
||||
original_initiator_(request.request_initiator),
|
||||
|
@ -52,13 +52,12 @@ ProxyingURLLoaderFactory::InProgressRequest::InProgressRequest(
|
|||
proxied_loader_binding_(this, std::move(loader_request)),
|
||||
target_client_(std::move(client)),
|
||||
current_response_(network::mojom::URLResponseHead::New()),
|
||||
proxied_client_binding_(this),
|
||||
// Always use "extraHeaders" mode to be compatible with old APIs, except
|
||||
// when the |request_id_| is zero, which is not supported in Chromium and
|
||||
// only happens in Electron when the request is started from net module.
|
||||
has_any_extra_headers_listeners_(network_service_request_id != 0) {
|
||||
// If there is a client error, clean up the request.
|
||||
target_client_.set_connection_error_handler(base::BindOnce(
|
||||
target_client_.set_disconnect_handler(base::BindOnce(
|
||||
&ProxyingURLLoaderFactory::InProgressRequest::OnRequestError,
|
||||
weak_factory_.GetWeakPtr(),
|
||||
network::URLLoaderCompletionStatus(net::ERR_ABORTED)));
|
||||
|
@ -97,7 +96,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::UpdateRequestInfo() {
|
|||
request_id_, factory_->render_process_id_, request_.render_frame_id,
|
||||
nullptr, routing_id_, request_for_info, false,
|
||||
!(options_ & network::mojom::kURLLoadOptionSynchronous),
|
||||
factory_->IsForServiceWorkerScript()));
|
||||
factory_->IsForServiceWorkerScript(), factory_->navigation_id_));
|
||||
|
||||
current_request_uses_header_client_ =
|
||||
factory_->url_loader_header_client_receiver_.is_bound() &&
|
||||
|
@ -138,8 +137,8 @@ void ProxyingURLLoaderFactory::InProgressRequest::RestartInternal() {
|
|||
// continue or cancel the request.
|
||||
//
|
||||
// We pause the binding here to prevent further client message processing.
|
||||
if (proxied_client_binding_.is_bound())
|
||||
proxied_client_binding_.PauseIncomingMethodCallProcessing();
|
||||
if (proxied_client_receiver_.is_bound())
|
||||
proxied_client_receiver_.Pause();
|
||||
|
||||
// Pause the header client, since we want to wait until OnBeforeRequest has
|
||||
// finished before processing any future events.
|
||||
|
@ -332,8 +331,8 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToBeforeSendHeaders(
|
|||
return;
|
||||
}
|
||||
|
||||
if (proxied_client_binding_.is_bound())
|
||||
proxied_client_binding_.ResumeIncomingMethodCallProcessing();
|
||||
if (proxied_client_receiver_.is_bound())
|
||||
proxied_client_receiver_.Resume();
|
||||
|
||||
auto continuation = base::BindRepeating(
|
||||
&InProgressRequest::ContinueToSendHeaders, weak_factory_.GetWeakPtr());
|
||||
|
@ -353,9 +352,9 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToBeforeSendHeaders(
|
|||
// they respond. |continuation| above will be invoked asynchronously to
|
||||
// continue or cancel the request.
|
||||
//
|
||||
// We pause the binding here to prevent further client message processing.
|
||||
if (proxied_client_binding_.is_bound())
|
||||
proxied_client_binding_.PauseIncomingMethodCallProcessing();
|
||||
// We pause the receiver here to prevent further client message processing.
|
||||
if (proxied_client_receiver_.is_bound())
|
||||
proxied_client_receiver_.Resume();
|
||||
return;
|
||||
}
|
||||
DCHECK_EQ(net::OK, result);
|
||||
|
@ -402,8 +401,8 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToSendHeaders(
|
|||
pending_follow_redirect_params_.reset();
|
||||
}
|
||||
|
||||
if (proxied_client_binding_.is_bound())
|
||||
proxied_client_binding_.ResumeIncomingMethodCallProcessing();
|
||||
if (proxied_client_receiver_.is_bound())
|
||||
proxied_client_receiver_.Resume();
|
||||
|
||||
// Note: In Electron onSendHeaders is called for all protocols.
|
||||
factory_->web_request_api()->OnSendHeaders(&info_.value(), request_,
|
||||
|
@ -425,8 +424,8 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToStartRequest(
|
|||
return;
|
||||
}
|
||||
|
||||
if (proxied_client_binding_.is_bound())
|
||||
proxied_client_binding_.ResumeIncomingMethodCallProcessing();
|
||||
if (proxied_client_receiver_.is_bound())
|
||||
proxied_client_receiver_.Resume();
|
||||
|
||||
if (header_client_receiver_.is_bound())
|
||||
header_client_receiver_.Resume();
|
||||
|
@ -434,8 +433,6 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToStartRequest(
|
|||
if (!target_loader_.is_bound() && factory_->target_factory_.is_bound()) {
|
||||
// No extensions have cancelled us up to this point, so it's now OK to
|
||||
// initiate the real network request.
|
||||
network::mojom::URLLoaderClientPtr proxied_client;
|
||||
proxied_client_binding_.Bind(mojo::MakeRequest(&proxied_client));
|
||||
uint32_t options = options_;
|
||||
// Even if this request does not use the header client, future redirects
|
||||
// might, so we need to set the option on the loader.
|
||||
|
@ -444,11 +441,12 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToStartRequest(
|
|||
factory_->target_factory_->CreateLoaderAndStart(
|
||||
mojo::MakeRequest(&target_loader_), routing_id_,
|
||||
network_service_request_id_, options, request_,
|
||||
std::move(proxied_client), traffic_annotation_);
|
||||
proxied_client_receiver_.BindNewPipeAndPassRemote(),
|
||||
traffic_annotation_);
|
||||
}
|
||||
|
||||
// From here the lifecycle of this request is driven by subsequent events on
|
||||
// either |proxy_loader_binding_|, |proxy_client_binding_|, or
|
||||
// either |proxy_loader_binding_|, |proxy_client_receiver_|, or
|
||||
// |header_client_receiver_|.
|
||||
}
|
||||
|
||||
|
@ -473,8 +471,8 @@ void ProxyingURLLoaderFactory::InProgressRequest::
|
|||
std::move(on_headers_received_callback_).Run(net::OK, headers, redirect_url_);
|
||||
override_headers_ = nullptr;
|
||||
|
||||
if (proxied_client_binding_)
|
||||
proxied_client_binding_.ResumeIncomingMethodCallProcessing();
|
||||
if (proxied_client_receiver_.is_bound())
|
||||
proxied_client_receiver_.Resume();
|
||||
}
|
||||
|
||||
void ProxyingURLLoaderFactory::InProgressRequest::ContinueToResponseStarted(
|
||||
|
@ -508,7 +506,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToResponseStarted(
|
|||
|
||||
// These will get re-bound if a new request is initiated by
|
||||
// |FollowRedirect()|.
|
||||
proxied_client_binding_.Close();
|
||||
proxied_client_receiver_.reset();
|
||||
header_client_receiver_.reset();
|
||||
target_loader_.reset();
|
||||
|
||||
|
@ -518,7 +516,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToResponseStarted(
|
|||
|
||||
info_->AddResponseInfoFromResourceResponse(*current_response_);
|
||||
|
||||
proxied_client_binding_.ResumeIncomingMethodCallProcessing();
|
||||
proxied_client_receiver_.Resume();
|
||||
|
||||
factory_->web_request_api()->OnResponseStarted(&info_.value(), request_);
|
||||
target_client_->OnReceiveResponse(std::move(current_response_));
|
||||
|
@ -534,8 +532,8 @@ void ProxyingURLLoaderFactory::InProgressRequest::ContinueToBeforeRedirect(
|
|||
|
||||
info_->AddResponseInfoFromResourceResponse(*current_response_);
|
||||
|
||||
if (proxied_client_binding_.is_bound())
|
||||
proxied_client_binding_.ResumeIncomingMethodCallProcessing();
|
||||
if (proxied_client_receiver_.is_bound())
|
||||
proxied_client_receiver_.Resume();
|
||||
|
||||
factory_->web_request_api()->OnBeforeRedirect(&info_.value(), request_,
|
||||
redirect_info.new_url);
|
||||
|
@ -566,7 +564,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::
|
|||
// bugs. The latter doesn't know anything about the redirect. Continuing
|
||||
// the load with it gives unexpected results. See
|
||||
// https://crbug.com/882661#c72.
|
||||
proxied_client_binding_.Close();
|
||||
proxied_client_receiver_.reset();
|
||||
header_client_receiver_.reset();
|
||||
target_loader_.reset();
|
||||
|
||||
|
@ -647,8 +645,9 @@ void ProxyingURLLoaderFactory::InProgressRequest::
|
|||
// they respond. |continuation| above will be invoked asynchronously to
|
||||
// continue or cancel the request.
|
||||
//
|
||||
// We pause the binding here to prevent further client message processing.
|
||||
proxied_client_binding_.PauseIncomingMethodCallProcessing();
|
||||
// We pause the receiver here to prevent further client message processing.
|
||||
if (proxied_client_receiver_.is_bound())
|
||||
proxied_client_receiver_.Pause();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -674,6 +673,7 @@ ProxyingURLLoaderFactory::ProxyingURLLoaderFactory(
|
|||
const HandlersMap& intercepted_handlers,
|
||||
content::BrowserContext* browser_context,
|
||||
int render_process_id,
|
||||
base::Optional<int64_t> navigation_id,
|
||||
network::mojom::URLLoaderFactoryRequest loader_request,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderFactory> target_factory_remote,
|
||||
mojo::PendingReceiver<network::mojom::TrustedURLLoaderHeaderClient>
|
||||
|
@ -683,6 +683,7 @@ ProxyingURLLoaderFactory::ProxyingURLLoaderFactory(
|
|||
intercepted_handlers_(intercepted_handlers),
|
||||
browser_context_(browser_context),
|
||||
render_process_id_(render_process_id),
|
||||
navigation_id_(std::move(navigation_id)),
|
||||
loader_factory_type_(loader_factory_type) {
|
||||
target_factory_.Bind(std::move(target_factory_remote));
|
||||
target_factory_.set_disconnect_handler(base::BindOnce(
|
||||
|
@ -718,7 +719,7 @@ void ProxyingURLLoaderFactory::CreateLoaderAndStart(
|
|||
int32_t request_id,
|
||||
uint32_t options,
|
||||
const network::ResourceRequest& original_request,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) {
|
||||
// Take a copy so we can mutate the request.
|
||||
network::ResourceRequest request = original_request;
|
||||
|
|
|
@ -93,7 +93,7 @@ class ProxyingURLLoaderFactory
|
|||
const network::ResourceRequest& request,
|
||||
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
|
||||
network::mojom::URLLoaderRequest loader_request,
|
||||
network::mojom::URLLoaderClientPtr client);
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client);
|
||||
~InProgressRequest() override;
|
||||
|
||||
void Restart();
|
||||
|
@ -158,7 +158,7 @@ class ProxyingURLLoaderFactory
|
|||
const uint32_t options_;
|
||||
const net::MutableNetworkTrafficAnnotationTag traffic_annotation_;
|
||||
mojo::Binding<network::mojom::URLLoader> proxied_loader_binding_;
|
||||
network::mojom::URLLoaderClientPtr target_client_;
|
||||
mojo::Remote<network::mojom::URLLoaderClient> target_client_;
|
||||
|
||||
base::Optional<extensions::WebRequestInfo> info_;
|
||||
|
||||
|
@ -166,7 +166,8 @@ class ProxyingURLLoaderFactory
|
|||
scoped_refptr<net::HttpResponseHeaders> override_headers_;
|
||||
GURL redirect_url_;
|
||||
|
||||
mojo::Binding<network::mojom::URLLoaderClient> proxied_client_binding_;
|
||||
mojo::Receiver<network::mojom::URLLoaderClient> proxied_client_receiver_{
|
||||
this};
|
||||
network::mojom::URLLoaderPtr target_loader_;
|
||||
|
||||
bool request_completed_ = false;
|
||||
|
@ -209,6 +210,7 @@ class ProxyingURLLoaderFactory
|
|||
const HandlersMap& intercepted_handlers,
|
||||
content::BrowserContext* browser_context,
|
||||
int render_process_id,
|
||||
base::Optional<int64_t> navigation_id,
|
||||
network::mojom::URLLoaderFactoryRequest loader_request,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderFactory>
|
||||
target_factory_remote,
|
||||
|
@ -224,7 +226,7 @@ class ProxyingURLLoaderFactory
|
|||
int32_t request_id,
|
||||
uint32_t options,
|
||||
const network::ResourceRequest& request,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation)
|
||||
override;
|
||||
void Clone(mojo::PendingReceiver<network::mojom::URLLoaderFactory>
|
||||
|
@ -266,6 +268,7 @@ class ProxyingURLLoaderFactory
|
|||
|
||||
content::BrowserContext* const browser_context_;
|
||||
const int render_process_id_;
|
||||
base::Optional<int64_t> navigation_id_;
|
||||
mojo::ReceiverSet<network::mojom::URLLoaderFactory> proxy_receivers_;
|
||||
mojo::Remote<network::mojom::URLLoaderFactory> target_factory_;
|
||||
mojo::Receiver<network::mojom::TrustedURLLoaderHeaderClient>
|
||||
|
|
|
@ -56,6 +56,7 @@ void ResolveProxyHelper::StartPendingRequest() {
|
|||
content::BrowserContext::GetDefaultStoragePartition(browser_context_)
|
||||
->GetNetworkContext()
|
||||
->LookUpProxyForURL(pending_requests_.front().url,
|
||||
net::NetworkIsolationKey::Todo(),
|
||||
std::move(proxy_lookup_client));
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "mojo/public/cpp/bindings/pending_receiver.h"
|
||||
#include "net/net_buildflags.h"
|
||||
#include "services/network/network_service.h"
|
||||
#include "services/network/public/cpp/cross_thread_shared_url_loader_factory_info.h"
|
||||
#include "services/network/public/cpp/cross_thread_pending_shared_url_loader_factory.h"
|
||||
#include "services/network/public/cpp/features.h"
|
||||
#include "services/network/public/cpp/shared_url_loader_factory.h"
|
||||
#include "shell/browser/atom_browser_client.h"
|
||||
|
@ -75,7 +75,7 @@ class SystemNetworkContextManager::URLLoaderFactoryForSystem
|
|||
int32_t request_id,
|
||||
uint32_t options,
|
||||
const network::ResourceRequest& url_request,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation)
|
||||
override {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
|
@ -94,10 +94,10 @@ class SystemNetworkContextManager::URLLoaderFactoryForSystem
|
|||
}
|
||||
|
||||
// SharedURLLoaderFactory implementation:
|
||||
std::unique_ptr<network::SharedURLLoaderFactoryInfo> Clone() override {
|
||||
std::unique_ptr<network::PendingSharedURLLoaderFactory> Clone() override {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
return std::make_unique<network::CrossThreadSharedURLLoaderFactoryInfo>(
|
||||
return std::make_unique<network::CrossThreadPendingSharedURLLoaderFactory>(
|
||||
this);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <utility>
|
||||
|
||||
#include "mojo/public/cpp/bindings/pending_remote.h"
|
||||
#include "mojo/public/cpp/system/string_data_source.h"
|
||||
#include "services/network/public/cpp/shared_url_loader_factory.h"
|
||||
|
||||
|
@ -15,7 +16,7 @@ URLPipeLoader::URLPipeLoader(
|
|||
scoped_refptr<network::SharedURLLoaderFactory> factory,
|
||||
std::unique_ptr<network::ResourceRequest> request,
|
||||
network::mojom::URLLoaderRequest loader,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
const net::NetworkTrafficAnnotationTag& annotation,
|
||||
base::DictionaryValue upload_data)
|
||||
: binding_(this, std::move(loader)),
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "mojo/public/cpp/bindings/receiver.h"
|
||||
#include "mojo/public/cpp/bindings/remote.h"
|
||||
#include "mojo/public/cpp/bindings/strong_binding.h"
|
||||
#include "mojo/public/cpp/system/data_pipe_producer.h"
|
||||
#include "services/network/public/cpp/simple_url_loader.h"
|
||||
|
@ -34,7 +36,7 @@ class URLPipeLoader : public network::mojom::URLLoader,
|
|||
URLPipeLoader(scoped_refptr<network::SharedURLLoaderFactory> factory,
|
||||
std::unique_ptr<network::ResourceRequest> request,
|
||||
network::mojom::URLLoaderRequest loader,
|
||||
network::mojom::URLLoaderClientPtr client,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
const net::NetworkTrafficAnnotationTag& annotation,
|
||||
base::DictionaryValue upload_data);
|
||||
|
||||
|
@ -66,7 +68,7 @@ class URLPipeLoader : public network::mojom::URLLoader,
|
|||
void ResumeReadingBodyFromNet() override {}
|
||||
|
||||
mojo::Binding<network::mojom::URLLoader> binding_;
|
||||
network::mojom::URLLoaderClientPtr client_;
|
||||
mojo::Remote<network::mojom::URLLoaderClient> client_;
|
||||
|
||||
std::unique_ptr<mojo::DataPipeProducer> producer_;
|
||||
std::unique_ptr<network::SimpleURLLoader> loader_;
|
||||
|
|
|
@ -16,21 +16,20 @@
|
|||
#include "shell/common/gin_converters/gurl_converter.h"
|
||||
#include "v8/include/v8.h"
|
||||
|
||||
NetworkHintsHandlerImpl::NetworkHintsHandlerImpl(int32_t render_process_id)
|
||||
: network_hints::SimpleNetworkHintsHandlerImpl(render_process_id),
|
||||
render_process_id_(render_process_id) {}
|
||||
NetworkHintsHandlerImpl::NetworkHintsHandlerImpl(
|
||||
content::RenderFrameHost* frame_host)
|
||||
: network_hints::SimpleNetworkHintsHandlerImpl(
|
||||
frame_host->GetProcess()->GetID()),
|
||||
render_frame_host_(frame_host) {}
|
||||
|
||||
NetworkHintsHandlerImpl::~NetworkHintsHandlerImpl() = default;
|
||||
|
||||
void NetworkHintsHandlerImpl::Preconnect(int32_t render_frame_id,
|
||||
const GURL& url,
|
||||
void NetworkHintsHandlerImpl::Preconnect(const GURL& url,
|
||||
bool allow_credentials) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
|
||||
content::RenderFrameHost* render_frame_host =
|
||||
content::RenderFrameHost::FromID(render_process_id_, render_frame_id);
|
||||
content::BrowserContext* browser_context =
|
||||
render_frame_host->GetProcess()->GetBrowserContext();
|
||||
render_frame_host_->GetProcess()->GetBrowserContext();
|
||||
auto* session = electron::api::Session::FromWrappedClass(
|
||||
v8::Isolate::GetCurrent(),
|
||||
static_cast<electron::AtomBrowserContext*>(browser_context));
|
||||
|
@ -40,9 +39,9 @@ void NetworkHintsHandlerImpl::Preconnect(int32_t render_frame_id,
|
|||
}
|
||||
|
||||
void NetworkHintsHandlerImpl::Create(
|
||||
int32_t render_process_id,
|
||||
content::RenderFrameHost* frame_host,
|
||||
mojo::PendingReceiver<network_hints::mojom::NetworkHintsHandler> receiver) {
|
||||
mojo::MakeSelfOwnedReceiver(
|
||||
base::WrapUnique(new NetworkHintsHandlerImpl(render_process_id)),
|
||||
base::WrapUnique(new NetworkHintsHandlerImpl(frame_host)),
|
||||
std::move(receiver));
|
||||
}
|
||||
|
|
|
@ -7,25 +7,27 @@
|
|||
|
||||
#include "components/network_hints/browser/simple_network_hints_handler_impl.h"
|
||||
|
||||
namespace content {
|
||||
class RenderFrameHost;
|
||||
}
|
||||
|
||||
class NetworkHintsHandlerImpl
|
||||
: public network_hints::SimpleNetworkHintsHandlerImpl {
|
||||
public:
|
||||
~NetworkHintsHandlerImpl() override;
|
||||
|
||||
static void Create(
|
||||
int32_t render_process_id,
|
||||
content::RenderFrameHost* frame_host,
|
||||
mojo::PendingReceiver<network_hints::mojom::NetworkHintsHandler>
|
||||
receiver);
|
||||
|
||||
// network_hints::mojom::NetworkHintsHandler:
|
||||
void Preconnect(int32_t render_frame_id,
|
||||
const GURL& url,
|
||||
bool allow_credentials) override;
|
||||
void Preconnect(const GURL& url, bool allow_credentials) override;
|
||||
|
||||
private:
|
||||
explicit NetworkHintsHandlerImpl(int32_t render_process_id);
|
||||
explicit NetworkHintsHandlerImpl(content::RenderFrameHost*);
|
||||
|
||||
int32_t render_process_id_;
|
||||
content::RenderFrameHost* render_frame_host_ = nullptr;
|
||||
};
|
||||
|
||||
#endif // SHELL_BROWSER_NETWORK_HINTS_HANDLER_IMPL_H_
|
||||
|
|
|
@ -20,9 +20,6 @@
|
|||
#include "shell/browser/notifications/win/win32_desktop_notifications/common.h"
|
||||
#include "shell/browser/notifications/win/win32_desktop_notifications/toast.h"
|
||||
|
||||
using std::make_shared;
|
||||
using std::shared_ptr;
|
||||
|
||||
namespace electron {
|
||||
|
||||
HBITMAP CopyBitmap(HBITMAP bitmap) {
|
||||
|
@ -281,8 +278,8 @@ DesktopNotificationController::Notification
|
|||
DesktopNotificationController::AddNotification(std::wstring caption,
|
||||
std::wstring body_text,
|
||||
HBITMAP image) {
|
||||
NotificationLink data(this);
|
||||
|
||||
auto data = std::make_shared<NotificationData>();
|
||||
data->controller = this;
|
||||
data->caption = move(caption);
|
||||
data->body_text = move(body_text);
|
||||
data->image = CopyBitmap(image);
|
||||
|
@ -298,6 +295,7 @@ void DesktopNotificationController::CloseNotification(
|
|||
// Remove it from the queue
|
||||
auto it = find(queue_.begin(), queue_.end(), notification.data_);
|
||||
if (it != queue_.end()) {
|
||||
(*it)->controller = nullptr;
|
||||
queue_.erase(it);
|
||||
this->OnNotificationClosed(notification);
|
||||
return;
|
||||
|
@ -318,7 +316,8 @@ void DesktopNotificationController::CheckQueue() {
|
|||
}
|
||||
}
|
||||
|
||||
void DesktopNotificationController::CreateToast(NotificationLink&& data) {
|
||||
void DesktopNotificationController::CreateToast(
|
||||
std::shared_ptr<NotificationData>&& data) {
|
||||
auto* hinstance = RegisterWndClasses();
|
||||
auto* hwnd = Toast::Create(hinstance, data);
|
||||
if (hwnd) {
|
||||
|
@ -333,7 +332,7 @@ void DesktopNotificationController::CreateToast(NotificationLink&& data) {
|
|||
scr.Y(toast_margin_);
|
||||
}
|
||||
|
||||
instances_.push_back({hwnd, move(data)});
|
||||
instances_.push_back({hwnd, std::move(data)});
|
||||
|
||||
if (!hwnd_controller_) {
|
||||
// NOTE: We cannot use a message-only window because we need to
|
||||
|
@ -377,7 +376,7 @@ DesktopNotificationController::Notification::Notification(
|
|||
const DesktopNotificationController::Notification&) = default;
|
||||
|
||||
DesktopNotificationController::Notification::Notification(
|
||||
const shared_ptr<NotificationData>& data)
|
||||
const std::shared_ptr<NotificationData>& data)
|
||||
: data_(data) {
|
||||
DCHECK(data != nullptr);
|
||||
}
|
||||
|
@ -424,16 +423,14 @@ void DesktopNotificationController::Notification::Set(std::wstring caption,
|
|||
data_->controller->StartAnimation();
|
||||
}
|
||||
|
||||
DesktopNotificationController::NotificationLink::NotificationLink(
|
||||
DesktopNotificationController* controller)
|
||||
: shared_ptr(make_shared<NotificationData>()) {
|
||||
get()->controller = controller;
|
||||
}
|
||||
|
||||
DesktopNotificationController::NotificationLink::~NotificationLink() {
|
||||
auto* p = get();
|
||||
if (p)
|
||||
p->controller = nullptr;
|
||||
DesktopNotificationController::ToastInstance::ToastInstance(
|
||||
HWND hwnd,
|
||||
std::shared_ptr<NotificationData> data) {
|
||||
this->hwnd = hwnd;
|
||||
this->data = std::move(data);
|
||||
}
|
||||
DesktopNotificationController::ToastInstance::~ToastInstance() = default;
|
||||
DesktopNotificationController::ToastInstance::ToastInstance(ToastInstance&&) =
|
||||
default;
|
||||
|
||||
} // namespace electron
|
||||
|
|
|
@ -28,39 +28,35 @@ class DesktopNotificationController {
|
|||
|
||||
// Event handlers -- override to receive the events
|
||||
private:
|
||||
class Toast;
|
||||
DesktopNotificationController(const DesktopNotificationController&) = delete;
|
||||
|
||||
struct ToastInstance {
|
||||
ToastInstance(HWND, std::shared_ptr<NotificationData>);
|
||||
~ToastInstance();
|
||||
ToastInstance(ToastInstance&&);
|
||||
ToastInstance(const ToastInstance&) = delete;
|
||||
ToastInstance& operator=(ToastInstance&&) = default;
|
||||
|
||||
HWND hwnd;
|
||||
std::shared_ptr<NotificationData> data;
|
||||
};
|
||||
|
||||
virtual void OnNotificationClosed(const Notification& notification) {}
|
||||
virtual void OnNotificationClicked(const Notification& notification) {}
|
||||
virtual void OnNotificationDismissed(const Notification& notification) {}
|
||||
|
||||
private:
|
||||
static HINSTANCE RegisterWndClasses();
|
||||
void StartAnimation();
|
||||
HFONT GetCaptionFont();
|
||||
HFONT GetBodyFont();
|
||||
|
||||
private:
|
||||
enum TimerID { TimerID_Animate = 1 };
|
||||
|
||||
static constexpr int toast_margin_ = 20;
|
||||
|
||||
// Wrapper around `NotificationData` which makes sure that
|
||||
// the `controller` member is cleared when the controller object
|
||||
// stops tracking the notification
|
||||
struct NotificationLink : std::shared_ptr<NotificationData> {
|
||||
explicit NotificationLink(DesktopNotificationController* controller);
|
||||
~NotificationLink();
|
||||
|
||||
NotificationLink(NotificationLink&&) = default;
|
||||
NotificationLink(const NotificationLink&) = delete;
|
||||
NotificationLink& operator=(NotificationLink&&) = default;
|
||||
};
|
||||
|
||||
struct ToastInstance {
|
||||
HWND hwnd;
|
||||
NotificationLink data;
|
||||
};
|
||||
|
||||
class Toast;
|
||||
void InitializeFonts();
|
||||
void ClearAssets();
|
||||
void AnimateAll();
|
||||
void CheckQueue();
|
||||
void CreateToast(std::shared_ptr<NotificationData>&& data);
|
||||
HWND GetToast(const NotificationData* data) const;
|
||||
void DestroyToast(ToastInstance* inst);
|
||||
|
||||
static LRESULT CALLBACK WndProc(HWND hwnd,
|
||||
UINT message,
|
||||
|
@ -71,23 +67,13 @@ class DesktopNotificationController {
|
|||
GetWindowLongPtr(hwnd, 0));
|
||||
}
|
||||
|
||||
DesktopNotificationController(const DesktopNotificationController&) = delete;
|
||||
|
||||
void InitializeFonts();
|
||||
void ClearAssets();
|
||||
void AnimateAll();
|
||||
void CheckQueue();
|
||||
void CreateToast(NotificationLink&& data);
|
||||
HWND GetToast(const NotificationData* data) const;
|
||||
void DestroyToast(ToastInstance* inst);
|
||||
|
||||
private:
|
||||
static constexpr int toast_margin_ = 20;
|
||||
static const TCHAR class_name_[];
|
||||
|
||||
enum TimerID { TimerID_Animate = 1 };
|
||||
HWND hwnd_controller_ = NULL;
|
||||
HFONT caption_font_ = NULL, body_font_ = NULL;
|
||||
std::vector<ToastInstance> instances_;
|
||||
std::deque<NotificationLink> queue_;
|
||||
std::deque<std::shared_ptr<NotificationData>> queue_;
|
||||
bool is_animating_ = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -113,8 +113,7 @@ void OffScreenWebContentsView::CreateView(gfx::NativeView context) {}
|
|||
|
||||
content::RenderWidgetHostViewBase*
|
||||
OffScreenWebContentsView::CreateViewForWidget(
|
||||
content::RenderWidgetHost* render_widget_host,
|
||||
bool is_guest_view_hack) {
|
||||
content::RenderWidgetHost* render_widget_host) {
|
||||
if (render_widget_host->GetView()) {
|
||||
return static_cast<content::RenderWidgetHostViewBase*>(
|
||||
render_widget_host->GetView());
|
||||
|
|
|
@ -54,8 +54,7 @@ class OffScreenWebContentsView : public content::WebContentsView,
|
|||
gfx::Rect GetViewBounds() const override;
|
||||
void CreateView(gfx::NativeView context) override;
|
||||
content::RenderWidgetHostViewBase* CreateViewForWidget(
|
||||
content::RenderWidgetHost* render_widget_host,
|
||||
bool is_guest_view_hack) override;
|
||||
content::RenderWidgetHost* render_widget_host) override;
|
||||
content::RenderWidgetHostViewBase* CreateViewForChildWidget(
|
||||
content::RenderWidgetHost* render_widget_host) override;
|
||||
void SetPageTitle(const base::string16& title) override;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "base/memory/ref_counted_memory.h"
|
||||
#include "base/strings/string_util.h"
|
||||
|
@ -62,7 +63,7 @@ class BundledDataSource : public content::URLDataSource {
|
|||
|
||||
void StartDataRequest(const GURL& url,
|
||||
const content::WebContents::Getter& wc_getter,
|
||||
const GotDataCallback& callback) override {
|
||||
GotDataCallback callback) override {
|
||||
const std::string path = content::URLDataSource::URLToRequestPath(url);
|
||||
// Serve request from local bundle.
|
||||
std::string bundled_path_prefix(kChromeUIDevToolsBundledPath);
|
||||
|
@ -70,12 +71,12 @@ class BundledDataSource : public content::URLDataSource {
|
|||
if (base::StartsWith(path, bundled_path_prefix,
|
||||
base::CompareCase::INSENSITIVE_ASCII)) {
|
||||
StartBundledDataRequest(path.substr(bundled_path_prefix.length()),
|
||||
callback);
|
||||
std::move(callback));
|
||||
return;
|
||||
}
|
||||
|
||||
// We do not handle remote and custom requests.
|
||||
callback.Run(nullptr);
|
||||
std::move(callback).Run(nullptr);
|
||||
}
|
||||
|
||||
std::string GetMimeType(const std::string& path) override {
|
||||
|
@ -89,18 +90,16 @@ class BundledDataSource : public content::URLDataSource {
|
|||
bool ShouldServeMimeTypeAsContentTypeHeader() override { return true; }
|
||||
|
||||
void StartBundledDataRequest(const std::string& path,
|
||||
const GotDataCallback& callback) {
|
||||
GotDataCallback callback) {
|
||||
std::string filename = PathWithoutParams(path);
|
||||
base::StringPiece resource =
|
||||
content::DevToolsFrontendHost::GetFrontendResource(filename);
|
||||
scoped_refptr<base::RefCountedMemory> bytes =
|
||||
content::DevToolsFrontendHost::GetFrontendResourceBytes(filename);
|
||||
|
||||
DLOG_IF(WARNING, resource.empty())
|
||||
DLOG_IF(WARNING, !bytes)
|
||||
<< "Unable to find dev tool resource: " << filename
|
||||
<< ". If you compiled with debug_devtools=1, try running with "
|
||||
"--debug-devtools.";
|
||||
scoped_refptr<base::RefCountedStaticMemory> bytes(
|
||||
new base::RefCountedStaticMemory(resource.data(), resource.length()));
|
||||
callback.Run(bytes.get());
|
||||
std::move(callback).Run(bytes);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -166,9 +166,8 @@ bool MenuBar::AcceleratorPressed(const ui::Accelerator& accelerator) {
|
|||
electron::KeyboardCodeFromCharCode(button->accelerator(), &shifted);
|
||||
|
||||
if (keycode == accelerator.key_code()) {
|
||||
const gfx::Point p(0, 0);
|
||||
auto event = accelerator.ToKeyEvent();
|
||||
OnMenuButtonClicked(button, p, &event);
|
||||
ButtonPressed(button, event);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -255,9 +254,7 @@ const char* MenuBar::GetClassName() const {
|
|||
return kViewClassName;
|
||||
}
|
||||
|
||||
void MenuBar::OnMenuButtonClicked(views::Button* source,
|
||||
const gfx::Point& point,
|
||||
const ui::Event* event) {
|
||||
void MenuBar::ButtonPressed(views::Button* source, const ui::Event& event) {
|
||||
// Hide the accelerator when a submenu is activated.
|
||||
SetAcceleratorVisibility(false);
|
||||
|
||||
|
@ -276,10 +273,9 @@ void MenuBar::OnMenuButtonClicked(views::Button* source,
|
|||
|
||||
// Deleted in MenuDelegate::OnMenuClosed
|
||||
MenuDelegate* menu_delegate = new MenuDelegate(this);
|
||||
menu_delegate->RunMenu(menu_model_->GetSubmenuModelAt(id), source,
|
||||
event != nullptr && event->IsKeyEvent()
|
||||
? ui::MENU_SOURCE_KEYBOARD
|
||||
: ui::MENU_SOURCE_MOUSE);
|
||||
menu_delegate->RunMenu(
|
||||
menu_model_->GetSubmenuModelAt(id), source,
|
||||
event.IsKeyEvent() ? ui::MENU_SOURCE_KEYBOARD : ui::MENU_SOURCE_MOUSE);
|
||||
menu_delegate->AddObserver(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "shell/browser/ui/views/menu_delegate.h"
|
||||
#include "shell/browser/ui/views/root_view.h"
|
||||
#include "ui/views/accessible_pane_view.h"
|
||||
#include "ui/views/controls/button/menu_button_listener.h"
|
||||
#include "ui/views/controls/button/button.h"
|
||||
#include "ui/views/focus/focus_manager.h"
|
||||
#include "ui/views/view.h"
|
||||
|
||||
|
@ -37,7 +37,7 @@ class MenuBarColorUpdater : public views::FocusChangeListener {
|
|||
};
|
||||
|
||||
class MenuBar : public views::AccessiblePaneView,
|
||||
public views::MenuButtonListener,
|
||||
public views::ButtonListener,
|
||||
public electron::MenuDelegate::Observer {
|
||||
public:
|
||||
static const char kViewClassName[];
|
||||
|
@ -78,10 +78,8 @@ class MenuBar : public views::AccessiblePaneView,
|
|||
// views::View:
|
||||
const char* GetClassName() const override;
|
||||
|
||||
// views::MenuButtonListener:
|
||||
void OnMenuButtonClicked(views::Button* source,
|
||||
const gfx::Point& point,
|
||||
const ui::Event* event) override;
|
||||
// views::ButtonListener:
|
||||
void ButtonPressed(views::Button* source, const ui::Event& event) override;
|
||||
void OnThemeChanged() override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
namespace electron {
|
||||
|
||||
SubmenuButton::SubmenuButton(const base::string16& title,
|
||||
views::MenuButtonListener* menu_button_listener,
|
||||
views::ButtonListener* button_listener,
|
||||
const SkColor& background_color)
|
||||
: views::MenuButton(
|
||||
gfx::RemoveAcceleratorChar(title, '&', nullptr, nullptr),
|
||||
menu_button_listener),
|
||||
button_listener),
|
||||
background_color_(background_color) {
|
||||
#if defined(OS_LINUX)
|
||||
// Dont' use native style border.
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace electron {
|
|||
class SubmenuButton : public views::MenuButton {
|
||||
public:
|
||||
SubmenuButton(const base::string16& title,
|
||||
views::MenuButtonListener* menu_button_listener,
|
||||
views::ButtonListener* button_listener,
|
||||
const SkColor& background_color);
|
||||
~SubmenuButton() override;
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ void WebViewGuestDelegate::AttachToIframe(
|
|||
// frame |embedder_frame| hosts the inner WebContents.
|
||||
embedder_web_contents_->AttachInnerWebContents(
|
||||
base::WrapUnique<content::WebContents>(guest_web_contents),
|
||||
embedder_frame);
|
||||
embedder_frame, false);
|
||||
|
||||
ResetZoomController();
|
||||
|
||||
|
@ -112,8 +112,7 @@ content::WebContents* WebViewGuestDelegate::CreateNewGuestWindow(
|
|||
guest_contents->GetRenderViewHost()->GetWidget();
|
||||
auto* guest_contents_impl =
|
||||
static_cast<content::WebContentsImpl*>(guest_contents.release());
|
||||
guest_contents_impl->GetView()->CreateViewForWidget(render_widget_host,
|
||||
false);
|
||||
guest_contents_impl->GetView()->CreateViewForWidget(render_widget_host);
|
||||
|
||||
return guest_contents_impl;
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@ ContentSettingsObserver::~ContentSettingsObserver() = default;
|
|||
|
||||
bool ContentSettingsObserver::AllowDatabase() {
|
||||
blink::WebFrame* frame = render_frame()->GetWebFrame();
|
||||
if (frame->GetSecurityOrigin().IsUnique() ||
|
||||
frame->Top()->GetSecurityOrigin().IsUnique())
|
||||
if (frame->GetSecurityOrigin().IsOpaque() ||
|
||||
frame->Top()->GetSecurityOrigin().IsOpaque())
|
||||
return false;
|
||||
auto origin = blink::WebStringToGURL(frame->GetSecurityOrigin().ToString());
|
||||
if (!origin.IsStandard())
|
||||
|
@ -32,8 +32,8 @@ bool ContentSettingsObserver::AllowDatabase() {
|
|||
|
||||
bool ContentSettingsObserver::AllowStorage(bool local) {
|
||||
blink::WebFrame* frame = render_frame()->GetWebFrame();
|
||||
if (frame->GetSecurityOrigin().IsUnique() ||
|
||||
frame->Top()->GetSecurityOrigin().IsUnique())
|
||||
if (frame->GetSecurityOrigin().IsOpaque() ||
|
||||
frame->Top()->GetSecurityOrigin().IsOpaque())
|
||||
return false;
|
||||
auto origin = blink::WebStringToGURL(frame->GetSecurityOrigin().ToString());
|
||||
if (!origin.IsStandard())
|
||||
|
@ -41,11 +41,10 @@ bool ContentSettingsObserver::AllowStorage(bool local) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ContentSettingsObserver::AllowIndexedDB(
|
||||
const blink::WebSecurityOrigin& security_origin) {
|
||||
bool ContentSettingsObserver::AllowIndexedDB() {
|
||||
blink::WebFrame* frame = render_frame()->GetWebFrame();
|
||||
if (frame->GetSecurityOrigin().IsUnique() ||
|
||||
frame->Top()->GetSecurityOrigin().IsUnique())
|
||||
if (frame->GetSecurityOrigin().IsOpaque() ||
|
||||
frame->Top()->GetSecurityOrigin().IsOpaque())
|
||||
return false;
|
||||
auto origin = blink::WebStringToGURL(frame->GetSecurityOrigin().ToString());
|
||||
if (!origin.IsStandard())
|
||||
|
|
|
@ -20,7 +20,7 @@ class ContentSettingsObserver : public content::RenderFrameObserver,
|
|||
// blink::WebContentSettingsClient implementation.
|
||||
bool AllowDatabase() override;
|
||||
bool AllowStorage(bool local) override;
|
||||
bool AllowIndexedDB(const blink::WebSecurityOrigin& security_origin) override;
|
||||
bool AllowIndexedDB() override;
|
||||
|
||||
private:
|
||||
// content::RenderFrameObserver implementation.
|
||||
|
|
|
@ -156,7 +156,7 @@ void RendererClientBase::RenderThreadStarted() {
|
|||
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
if (command_line->HasSwitch(switches::kEnableSpellcheck))
|
||||
spellcheck_ = std::make_unique<SpellCheck>(®istry_, this);
|
||||
spellcheck_ = std::make_unique<SpellCheck>(this);
|
||||
#endif
|
||||
|
||||
blink::WebCustomElement::AddEmbedderCustomElementName("webview");
|
||||
|
@ -338,12 +338,11 @@ void RendererClientBase::DidSetUserAgent(const std::string& user_agent) {
|
|||
#endif
|
||||
}
|
||||
|
||||
blink::WebPrescientNetworking* RendererClientBase::GetPrescientNetworking() {
|
||||
if (!web_prescient_networking_impl_) {
|
||||
web_prescient_networking_impl_ =
|
||||
std::make_unique<network_hints::WebPrescientNetworkingImpl>();
|
||||
}
|
||||
return web_prescient_networking_impl_.get();
|
||||
std::unique_ptr<blink::WebPrescientNetworking>
|
||||
RendererClientBase::CreatePrescientNetworking(
|
||||
content::RenderFrame* render_frame) {
|
||||
return std::make_unique<network_hints::WebPrescientNetworkingImpl>(
|
||||
render_frame);
|
||||
}
|
||||
|
||||
void RendererClientBase::RunScriptsAtDocumentStart(
|
||||
|
|
|
@ -26,10 +26,6 @@
|
|||
class SpellCheck;
|
||||
#endif
|
||||
|
||||
namespace network_hints {
|
||||
class WebPrescientNetworkingImpl;
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
||||
namespace extensions {
|
||||
class ExtensionsClient;
|
||||
|
@ -71,7 +67,8 @@ class RendererClientBase : public content::ContentRendererClient
|
|||
content::RenderFrame* render_frame,
|
||||
int world_id) = 0;
|
||||
|
||||
blink::WebPrescientNetworking* GetPrescientNetworking() override;
|
||||
std::unique_ptr<blink::WebPrescientNetworking> CreatePrescientNetworking(
|
||||
content::RenderFrame* render_frame) override;
|
||||
bool isolated_world() const { return isolated_world_; }
|
||||
|
||||
// Get the context that the Electron API is running in.
|
||||
|
@ -113,9 +110,6 @@ class RendererClientBase : public content::ContentRendererClient
|
|||
#endif
|
||||
|
||||
private:
|
||||
std::unique_ptr<network_hints::WebPrescientNetworkingImpl>
|
||||
web_prescient_networking_impl_;
|
||||
|
||||
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
||||
std::unique_ptr<extensions::ExtensionsClient> extensions_client_;
|
||||
std::unique_ptr<AtomExtensionsRendererClient> extensions_renderer_client_;
|
||||
|
|
|
@ -9,9 +9,6 @@
|
|||
#include "base/command_line.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/threading/sequenced_task_runner_handle.h"
|
||||
#include "content/public/child/child_thread.h"
|
||||
#include "content/public/common/service_manager_connection.h"
|
||||
#include "content/public/common/simple_connection_filter.h"
|
||||
#include "content/public/utility/utility_thread.h"
|
||||
#include "mojo/public/cpp/bindings/service_factory.h"
|
||||
#include "services/proxy_resolver/proxy_resolver_factory_impl.h"
|
||||
|
@ -61,7 +58,8 @@ auto RunProxyResolver(
|
|||
|
||||
} // namespace
|
||||
|
||||
AtomContentUtilityClient::AtomContentUtilityClient() : elevated_(false) {
|
||||
AtomContentUtilityClient::AtomContentUtilityClient()
|
||||
: utility_process_running_elevated_(false) {
|
||||
#if BUILDFLAG(ENABLE_PRINTING) && defined(OS_WIN)
|
||||
printing_handler_ = std::make_unique<printing::PrintingHandler>();
|
||||
#endif
|
||||
|
@ -72,40 +70,27 @@ AtomContentUtilityClient::~AtomContentUtilityClient() = default;
|
|||
// The guts of this came from the chromium implementation
|
||||
// https://cs.chromium.org/chromium/src/chrome/utility/
|
||||
// chrome_content_utility_client.cc?sq=package:chromium&dr=CSs&g=0&l=142
|
||||
void AtomContentUtilityClient::UtilityThreadStarted() {
|
||||
void AtomContentUtilityClient::ExposeInterfacesToBrowser(
|
||||
mojo::BinderMap* binders) {
|
||||
#if defined(OS_WIN)
|
||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
elevated_ = command_line->HasSwitch(
|
||||
utility_process_running_elevated_ = command_line->HasSwitch(
|
||||
service_manager::switches::kNoSandboxAndElevatedPrivileges);
|
||||
#endif
|
||||
|
||||
content::ServiceManagerConnection* connection =
|
||||
content::ChildThread::Get()->GetServiceManagerConnection();
|
||||
|
||||
// NOTE: Some utility process instances are not connected to the Service
|
||||
// Manager. Nothing left to do in that case.
|
||||
if (!connection)
|
||||
return;
|
||||
|
||||
auto registry = std::make_unique<service_manager::BinderRegistry>();
|
||||
// If our process runs with elevated privileges, only add elevated Mojo
|
||||
// interfaces to the interface registry.
|
||||
if (!elevated_) {
|
||||
#if BUILDFLAG(ENABLE_PRINTING) && defined(OS_WIN)
|
||||
// TODO(crbug.com/798782): remove when the Cloud print chrome/service is
|
||||
// removed.
|
||||
registry->AddInterface(
|
||||
// interfaces to the BinderMap.
|
||||
if (!utility_process_running_elevated_) {
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
binders->Add(
|
||||
base::BindRepeating(printing::PdfToEmfConverterFactory::Create),
|
||||
base::ThreadTaskRunnerHandle::Get());
|
||||
#endif
|
||||
}
|
||||
|
||||
connection->AddConnectionFilter(
|
||||
std::make_unique<content::SimpleConnectionFilter>(std::move(registry)));
|
||||
#endif
|
||||
}
|
||||
|
||||
bool AtomContentUtilityClient::OnMessageReceived(const IPC::Message& message) {
|
||||
if (elevated_)
|
||||
if (utility_process_running_elevated_)
|
||||
return false;
|
||||
|
||||
#if BUILDFLAG(ENABLE_PRINTING) && defined(OS_WIN)
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "content/public/utility/content_utility_client.h"
|
||||
#include "mojo/public/cpp/bindings/binder_map.h"
|
||||
#include "printing/buildflags/buildflags.h"
|
||||
|
||||
#if BUILDFLAG(ENABLE_PRINTING) && defined(OS_WIN)
|
||||
|
@ -24,7 +25,7 @@ class AtomContentUtilityClient : public content::ContentUtilityClient {
|
|||
AtomContentUtilityClient();
|
||||
~AtomContentUtilityClient() override;
|
||||
|
||||
void UtilityThreadStarted() override;
|
||||
void ExposeInterfacesToBrowser(mojo::BinderMap* binders) override;
|
||||
bool OnMessageReceived(const IPC::Message& message) override;
|
||||
mojo::ServiceFactory* GetMainThreadServiceFactory() override;
|
||||
mojo::ServiceFactory* GetIOThreadServiceFactory() override;
|
||||
|
@ -34,7 +35,8 @@ class AtomContentUtilityClient : public content::ContentUtilityClient {
|
|||
std::unique_ptr<printing::PrintingHandler> printing_handler_;
|
||||
#endif
|
||||
|
||||
bool elevated_;
|
||||
// True if the utility process runs with elevated privileges.
|
||||
bool utility_process_running_elevated_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomContentUtilityClient);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue