chore: bump chromium to e836cbe709f3cd703f233de8eb6cc6ec99b72c9d (#27475)
Co-authored-by: deepak1556 <hop2deep@gmail.com> Co-authored-by: Jeremy Rose <nornagon@nornagon.net>
This commit is contained in:
parent
44460e84c0
commit
e46446e7e4
93 changed files with 705 additions and 896 deletions
|
@ -9,7 +9,6 @@
|
|||
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "chrome/common/extensions/command.h"
|
||||
#include "gin/dictionary.h"
|
||||
#include "gin/object_template_builder.h"
|
||||
#include "shell/browser/api/electron_api_system_preferences.h"
|
||||
|
@ -22,7 +21,6 @@
|
|||
#include "base/mac/mac_util.h"
|
||||
#endif
|
||||
|
||||
using extensions::Command;
|
||||
using extensions::GlobalShortcutListener;
|
||||
|
||||
namespace {
|
||||
|
@ -46,15 +44,6 @@ bool RegisteringMediaKeyForUntrustedClient(const ui::Accelerator& accelerator) {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MapHasMediaKeys(
|
||||
const std::map<ui::Accelerator, base::Closure>& accelerator_map) {
|
||||
auto media_key = std::find_if(
|
||||
accelerator_map.begin(), accelerator_map.end(),
|
||||
[](const auto& ac) { return Command::IsMediaKey(ac.first); });
|
||||
|
||||
return media_key != accelerator_map.end();
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
@ -112,12 +101,8 @@ bool GlobalShortcut::Register(const ui::Accelerator& accelerator,
|
|||
return false;
|
||||
}
|
||||
#if defined(OS_MAC)
|
||||
if (Command::IsMediaKey(accelerator)) {
|
||||
if (RegisteringMediaKeyForUntrustedClient(accelerator))
|
||||
return false;
|
||||
|
||||
GlobalShortcutListener::SetShouldUseInternalMediaKeyHandling(false);
|
||||
}
|
||||
if (RegisteringMediaKeyForUntrustedClient(accelerator))
|
||||
return false;
|
||||
#endif
|
||||
|
||||
if (!GlobalShortcutListener::GetInstance()->RegisterAccelerator(accelerator,
|
||||
|
@ -138,13 +123,6 @@ void GlobalShortcut::Unregister(const ui::Accelerator& accelerator) {
|
|||
if (accelerator_callback_map_.erase(accelerator) == 0)
|
||||
return;
|
||||
|
||||
#if defined(OS_MAC)
|
||||
if (Command::IsMediaKey(accelerator) &&
|
||||
!MapHasMediaKeys(accelerator_callback_map_)) {
|
||||
GlobalShortcutListener::SetShouldUseInternalMediaKeyHandling(true);
|
||||
}
|
||||
#endif
|
||||
|
||||
GlobalShortcutListener::GetInstance()->UnregisterAccelerator(accelerator,
|
||||
this);
|
||||
}
|
||||
|
|
|
@ -136,8 +136,8 @@ v8::Local<v8::Promise> NetLog::StartLogging(base::FilePath log_path,
|
|||
->GetNetworkContext();
|
||||
|
||||
network_context->CreateNetLogExporter(mojo::MakeRequest(&net_log_exporter_));
|
||||
net_log_exporter_.set_connection_error_handler(
|
||||
base::BindOnce(&NetLog::OnConnectionError, base::Unretained(this)));
|
||||
net_log_exporter_.set_connection_error_handler(base::BindOnce(
|
||||
&NetLog::OnConnectionError, weak_ptr_factory_.GetWeakPtr()));
|
||||
|
||||
base::PostTaskAndReplyWithResult(
|
||||
file_task_runner_.get(), FROM_HERE,
|
||||
|
|
|
@ -74,6 +74,7 @@
|
|||
#include "mojo/public/cpp/system/platform_handle.h"
|
||||
#include "ppapi/buildflags/buildflags.h"
|
||||
#include "printing/buildflags/buildflags.h"
|
||||
#include "services/service_manager/public/cpp/interface_provider.h"
|
||||
#include "shell/browser/api/electron_api_browser_window.h"
|
||||
#include "shell/browser/api/electron_api_debugger.h"
|
||||
#include "shell/browser/api/electron_api_session.h"
|
||||
|
@ -1372,6 +1373,8 @@ void WebContents::RenderFrameCreated(
|
|||
static_cast<content::RenderWidgetHostImpl*>(rwhv->GetRenderWidgetHost());
|
||||
if (rwh_impl)
|
||||
rwh_impl->disable_hidden_ = !background_throttling_;
|
||||
|
||||
WebFrameMain::RenderFrameCreated(render_frame_host);
|
||||
}
|
||||
|
||||
void WebContents::RenderViewDeleted(content::RenderViewHost* render_view_host) {
|
||||
|
@ -1577,11 +1580,19 @@ void WebContents::MessageTo(bool internal,
|
|||
const std::string& channel,
|
||||
blink::CloneableMessage arguments) {
|
||||
TRACE_EVENT1("electron", "WebContents::MessageTo", "channel", channel);
|
||||
auto* web_contents = FromID(web_contents_id);
|
||||
auto* target_web_contents = FromID(web_contents_id);
|
||||
|
||||
if (web_contents) {
|
||||
web_contents->SendIPCMessageWithSender(internal, channel,
|
||||
std::move(arguments), ID());
|
||||
if (target_web_contents) {
|
||||
content::RenderFrameHost* frame = target_web_contents->MainFrame();
|
||||
DCHECK(frame);
|
||||
|
||||
v8::HandleScope handle_scope(JavascriptEnvironment::GetIsolate());
|
||||
gin::Handle<WebFrameMain> web_frame_main =
|
||||
WebFrameMain::From(JavascriptEnvironment::GetIsolate(), frame);
|
||||
|
||||
int32_t sender_id = ID();
|
||||
web_frame_main->GetRendererApi()->Message(internal, channel,
|
||||
std::move(arguments), sender_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1967,9 +1978,6 @@ void WebContents::LoadURL(const GURL& url,
|
|||
// Calling LoadURLWithParams() can trigger JS which destroys |this|.
|
||||
auto weak_this = GetWeakPtr();
|
||||
|
||||
// Required to make beforeunload handler work.
|
||||
NotifyUserActivation();
|
||||
|
||||
params.transition_type = ui::PAGE_TRANSITION_TYPED;
|
||||
params.should_clear_history_list = true;
|
||||
params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
|
||||
|
@ -1984,6 +1992,9 @@ void WebContents::LoadURL(const GURL& url,
|
|||
if (!weak_this)
|
||||
return;
|
||||
|
||||
// Required to make beforeunload handler work.
|
||||
NotifyUserActivation();
|
||||
|
||||
// Set the background color of RenderWidgetHostView.
|
||||
// We have to call it right after LoadURL because the RenderViewHost is only
|
||||
// created after loading a page.
|
||||
|
@ -2674,30 +2685,6 @@ bool WebContents::IsFocused() const {
|
|||
}
|
||||
#endif
|
||||
|
||||
bool WebContents::SendIPCMessage(bool internal,
|
||||
const std::string& channel,
|
||||
v8::Local<v8::Value> args) {
|
||||
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
||||
blink::CloneableMessage message;
|
||||
if (!gin::ConvertFromV8(isolate, args, &message)) {
|
||||
isolate->ThrowException(v8::Exception::Error(
|
||||
gin::StringToV8(isolate, "Failed to serialize arguments")));
|
||||
return false;
|
||||
}
|
||||
return SendIPCMessageWithSender(internal, channel, std::move(message));
|
||||
}
|
||||
|
||||
bool WebContents::SendIPCMessageWithSender(bool internal,
|
||||
const std::string& channel,
|
||||
blink::CloneableMessage args,
|
||||
int32_t sender_id) {
|
||||
auto* frame_host = web_contents()->GetMainFrame();
|
||||
mojo::AssociatedRemote<mojom::ElectronRenderer> electron_renderer;
|
||||
frame_host->GetRemoteAssociatedInterfaces()->GetInterface(&electron_renderer);
|
||||
electron_renderer->Message(internal, channel, std::move(args), sender_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
void WebContents::SendInputEvent(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> input_event) {
|
||||
content::RenderWidgetHostView* view =
|
||||
|
@ -3111,12 +3098,10 @@ void WebContents::GrantOriginAccess(const GURL& url) {
|
|||
}
|
||||
|
||||
void WebContents::NotifyUserActivation() {
|
||||
auto* frame = web_contents()->GetMainFrame();
|
||||
if (!frame)
|
||||
return;
|
||||
mojo::AssociatedRemote<mojom::ElectronRenderer> renderer;
|
||||
frame->GetRemoteAssociatedInterfaces()->GetInterface(&renderer);
|
||||
renderer->NotifyUserActivation();
|
||||
content::RenderFrameHost* frame = web_contents()->GetMainFrame();
|
||||
if (frame)
|
||||
frame->NotifyUserActivation(
|
||||
blink::mojom::UserActivationNotificationType::kInteraction);
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> WebContents::TakeHeapSnapshot(
|
||||
|
@ -3139,18 +3124,23 @@ v8::Local<v8::Promise> WebContents::TakeHeapSnapshot(
|
|||
return handle;
|
||||
}
|
||||
|
||||
if (!frame_host->IsRenderFrameCreated()) {
|
||||
promise.RejectWithErrorMessage("takeHeapSnapshot failed");
|
||||
return handle;
|
||||
}
|
||||
|
||||
// This dance with `base::Owned` is to ensure that the interface stays alive
|
||||
// until the callback is called. Otherwise it would be closed at the end of
|
||||
// this function.
|
||||
auto electron_renderer =
|
||||
std::make_unique<mojo::AssociatedRemote<mojom::ElectronRenderer>>();
|
||||
frame_host->GetRemoteAssociatedInterfaces()->GetInterface(
|
||||
electron_renderer.get());
|
||||
std::make_unique<mojo::Remote<mojom::ElectronRenderer>>();
|
||||
frame_host->GetRemoteInterfaces()->GetInterface(
|
||||
electron_renderer->BindNewPipeAndPassReceiver());
|
||||
auto* raw_ptr = electron_renderer.get();
|
||||
(*raw_ptr)->TakeHeapSnapshot(
|
||||
mojo::WrapPlatformFile(base::ScopedPlatformFile(file.TakePlatformFile())),
|
||||
base::BindOnce(
|
||||
[](mojo::AssociatedRemote<mojom::ElectronRenderer>* ep,
|
||||
[](mojo::Remote<mojom::ElectronRenderer>* ep,
|
||||
gin_helper::Promise<void> promise, bool success) {
|
||||
if (success) {
|
||||
promise.Resolve();
|
||||
|
@ -3606,7 +3596,6 @@ v8::Local<v8::ObjectTemplate> WebContents::FillObjectTemplate(
|
|||
.SetMethod("stopFindInPage", &WebContents::StopFindInPage)
|
||||
.SetMethod("focus", &WebContents::Focus)
|
||||
.SetMethod("isFocused", &WebContents::IsFocused)
|
||||
.SetMethod("_send", &WebContents::SendIPCMessage)
|
||||
.SetMethod("sendInputEvent", &WebContents::SendInputEvent)
|
||||
.SetMethod("beginFrameSubscription", &WebContents::BeginFrameSubscription)
|
||||
.SetMethod("endFrameSubscription", &WebContents::EndFrameSubscription)
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
#include "chrome/browser/printing/print_view_manager_basic.h"
|
||||
#include "components/printing/common/print_messages.h"
|
||||
#include "shell/browser/printing/print_preview_message_handler.h"
|
||||
#endif
|
||||
|
||||
|
@ -250,16 +249,6 @@ class WebContents : public gin::Wrappable<WebContents>,
|
|||
void Focus();
|
||||
bool IsFocused() const;
|
||||
|
||||
// Send messages to browser.
|
||||
bool SendIPCMessage(bool internal,
|
||||
const std::string& channel,
|
||||
v8::Local<v8::Value> args);
|
||||
|
||||
bool SendIPCMessageWithSender(bool internal,
|
||||
const std::string& channel,
|
||||
blink::CloneableMessage args,
|
||||
int32_t sender_id = 0);
|
||||
|
||||
// Send WebInputEvent to the page.
|
||||
void SendInputEvent(v8::Isolate* isolate, v8::Local<v8::Value> input_event);
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "electron/shell/common/api/api.mojom.h"
|
||||
#include "gin/object_template_builder.h"
|
||||
#include "services/service_manager/public/cpp/interface_provider.h"
|
||||
#include "shell/browser/api/message_port.h"
|
||||
#include "shell/browser/browser.h"
|
||||
#include "shell/browser/javascript_environment.h"
|
||||
|
@ -28,7 +29,6 @@
|
|||
#include "shell/common/gin_helper/promise.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "shell/common/v8_value_serializer.h"
|
||||
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
|
@ -179,11 +179,25 @@ void WebFrameMain::Send(v8::Isolate* isolate,
|
|||
if (!CheckRenderFrame())
|
||||
return;
|
||||
|
||||
mojo::AssociatedRemote<mojom::ElectronRenderer> electron_renderer;
|
||||
render_frame_->GetRemoteAssociatedInterfaces()->GetInterface(
|
||||
&electron_renderer);
|
||||
electron_renderer->Message(internal, channel, std::move(message),
|
||||
0 /* sender_id */);
|
||||
GetRendererApi()->Message(internal, channel, std::move(message),
|
||||
0 /* sender_id */);
|
||||
}
|
||||
|
||||
const mojo::Remote<mojom::ElectronRenderer>& WebFrameMain::GetRendererApi() {
|
||||
if (!renderer_api_) {
|
||||
pending_receiver_ = renderer_api_.BindNewPipeAndPassReceiver();
|
||||
if (render_frame_->IsRenderFrameCreated()) {
|
||||
render_frame_->GetRemoteInterfaces()->GetInterface(
|
||||
std::move(pending_receiver_));
|
||||
}
|
||||
renderer_api_.set_disconnect_handler(base::BindOnce(
|
||||
&WebFrameMain::OnRendererConnectionError, weak_factory_.GetWeakPtr()));
|
||||
}
|
||||
return renderer_api_;
|
||||
}
|
||||
|
||||
void WebFrameMain::OnRendererConnectionError() {
|
||||
renderer_api_.reset();
|
||||
}
|
||||
|
||||
void WebFrameMain::PostMessage(v8::Isolate* isolate,
|
||||
|
@ -215,11 +229,8 @@ void WebFrameMain::PostMessage(v8::Isolate* isolate,
|
|||
if (!CheckRenderFrame())
|
||||
return;
|
||||
|
||||
mojo::AssociatedRemote<mojom::ElectronRenderer> electron_renderer;
|
||||
render_frame_->GetRemoteAssociatedInterfaces()->GetInterface(
|
||||
&electron_renderer);
|
||||
electron_renderer->ReceivePostMessage(channel,
|
||||
std::move(transferable_message));
|
||||
GetRendererApi()->ReceivePostMessage(channel,
|
||||
std::move(transferable_message));
|
||||
}
|
||||
|
||||
int WebFrameMain::FrameTreeNodeID() const {
|
||||
|
@ -335,6 +346,19 @@ void WebFrameMain::RenderFrameDeleted(content::RenderFrameHost* rfh) {
|
|||
web_frame->MarkRenderFrameDisposed();
|
||||
}
|
||||
|
||||
void WebFrameMain::RenderFrameCreated(content::RenderFrameHost* rfh) {
|
||||
auto* web_frame = FromRenderFrameHost(rfh);
|
||||
if (web_frame)
|
||||
web_frame->Connect();
|
||||
}
|
||||
|
||||
void WebFrameMain::Connect() {
|
||||
if (pending_receiver_) {
|
||||
render_frame_->GetRemoteInterfaces()->GetInterface(
|
||||
std::move(pending_receiver_));
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Local<v8::ObjectTemplate> WebFrameMain::FillObjectTemplate(
|
||||
v8::Isolate* isolate,
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/process/process.h"
|
||||
#include "gin/handle.h"
|
||||
#include "gin/wrappable.h"
|
||||
|
@ -51,11 +52,14 @@ class WebFrameMain : public gin::Wrappable<WebFrameMain>,
|
|||
// Called to mark any RenderFrameHost as disposed by any WebFrameMain that
|
||||
// may be holding a weak reference.
|
||||
static void RenderFrameDeleted(content::RenderFrameHost* rfh);
|
||||
static void RenderFrameCreated(content::RenderFrameHost* rfh);
|
||||
|
||||
// Mark RenderFrameHost as disposed and to no longer access it. This can
|
||||
// occur upon frame navigation.
|
||||
void MarkRenderFrameDisposed();
|
||||
|
||||
const mojo::Remote<mojom::ElectronRenderer>& GetRendererApi();
|
||||
|
||||
// gin::Wrappable
|
||||
static gin::WrapperInfo kWrapperInfo;
|
||||
static v8::Local<v8::ObjectTemplate> FillObjectTemplate(
|
||||
|
@ -71,6 +75,7 @@ class WebFrameMain : public gin::Wrappable<WebFrameMain>,
|
|||
// WebFrameMain can outlive its RenderFrameHost pointer so we need to check
|
||||
// whether its been disposed of prior to accessing it.
|
||||
bool CheckRenderFrame() const;
|
||||
void Connect();
|
||||
|
||||
v8::Local<v8::Promise> ExecuteJavaScript(gin::Arguments* args,
|
||||
const base::string16& code);
|
||||
|
@ -100,12 +105,19 @@ class WebFrameMain : public gin::Wrappable<WebFrameMain>,
|
|||
std::vector<content::RenderFrameHost*> Frames() const;
|
||||
std::vector<content::RenderFrameHost*> FramesInSubtree() const;
|
||||
|
||||
void OnRendererConnectionError();
|
||||
|
||||
mojo::Remote<mojom::ElectronRenderer> renderer_api_;
|
||||
mojo::PendingReceiver<mojom::ElectronRenderer> pending_receiver_;
|
||||
|
||||
content::RenderFrameHost* render_frame_ = nullptr;
|
||||
|
||||
// Whether the RenderFrameHost has been removed and that it should no longer
|
||||
// be accessed.
|
||||
bool render_frame_disposed_ = false;
|
||||
|
||||
base::WeakPtrFactory<WebFrameMain> weak_factory_{this};
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(WebFrameMain);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue