Merge remote-tracking branch 'origin/master' into roller/chromium/master

This commit is contained in:
Jeremy Rose 2021-03-23 11:14:58 -07:00
commit 39e3576c48
68 changed files with 578 additions and 182 deletions

View file

@ -0,0 +1,26 @@
enum RecordingMode { "record-until-full", "record-continuously", "record-as-much-as-possible", "trace-to-console" };
dictionary TraceConfig {
Recordingmode recording_mode;
unsigned long trace_buffer_size_in_kb;
unsigned long trace_buffer_size_in_events;
boolean enable_argument_filter;
sequence<DOMString> included_categories;
sequence<DOMString> excluded_categories;
sequence<unsigned short> included_process_ids;
sequence<DOMString> histogram_names;
object memory_dump_config;
};
dictionary TraceCategoriesAndOptions {
DOMString categoryFilter;
DOMString traceOptions;
};
interface ContentTracing {
Promise<sequence<DOMString>> getCategories();
Promise<void> startRecording(TraceConfig config);
Promise<void> startRecording(TraceCategoriesAndOptions categoriesAndOptions);
Promise<DOMString> stopRecording(optional DOMString resultFilePath);
Promise<TraceBufferUsage> getTraceBufferUsage();
};

View file

@ -1114,6 +1114,8 @@ int32_t BaseWindow::GetID() const {
}
void BaseWindow::ResetBrowserViews() {
v8::HandleScope scope(isolate());
for (auto& item : browser_views_) {
gin::Handle<BrowserView> browser_view;
if (gin::ConvertFromV8(isolate(),

View file

@ -162,6 +162,9 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
v8::Locker locker(isolate);
v8::HandleScope scope(isolate);
gin_helper::CallMethod(this, "_onerror", "Failed to get sources.");
Unpin();
return;
}
@ -195,12 +198,19 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
v8::Locker locker(isolate);
v8::HandleScope scope(isolate);
gin_helper::CallMethod(this, "_onfinished", captured_sources_);
Unpin();
}
}
// static
gin::Handle<DesktopCapturer> DesktopCapturer::Create(v8::Isolate* isolate) {
return gin::CreateHandle(isolate, new DesktopCapturer(isolate));
auto handle = gin::CreateHandle(isolate, new DesktopCapturer(isolate));
// Keep reference alive until capturing has finished.
handle->Pin(isolate);
return handle;
}
gin::ObjectTemplateBuilder DesktopCapturer::GetObjectTemplateBuilder(

View file

@ -13,12 +13,14 @@
#include "chrome/browser/media/webrtc/native_desktop_media_list.h"
#include "gin/handle.h"
#include "gin/wrappable.h"
#include "shell/common/gin_helper/pinnable.h"
namespace electron {
namespace api {
class DesktopCapturer : public gin::Wrappable<DesktopCapturer>,
public gin_helper::Pinnable<DesktopCapturer>,
public DesktopMediaListObserver {
public:
struct Source {

View file

@ -88,7 +88,7 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
}
// If no preferred item is specified, try to show all of the menu items.
if (!positioning_item) {
if (!item) {
CGFloat windowBottom = CGRectGetMinY([view window].frame);
CGFloat lowestMenuPoint = windowBottom + position.y - [menu size].height;
CGFloat screenBottom = CGRectGetMinY([view window].screen.frame);

View file

@ -10,6 +10,7 @@
#include "base/command_line.h"
#include "base/stl_util.h"
#include "content/common/url_schemes.h"
#include "content/public/browser/child_process_security_policy.h"
#include "gin/object_template_builder.h"
#include "shell/browser/browser.h"
@ -124,6 +125,13 @@ void RegisterSchemesAsPrivileged(gin_helper::ErrorThrower thrower,
}
if (custom_scheme.options.allowServiceWorkers) {
service_worker_schemes.push_back(custom_scheme.scheme);
// There is no API to add service worker scheme, but there is an API to
// return const reference to the schemes vector.
// If in future the API is changed to return a copy instead of reference,
// the compilation will fail, and we should add a patch at that time.
auto& mutable_schemes = const_cast<std::vector<std::string>&>(
content::GetServiceWorkerSchemes());
mutable_schemes.push_back(custom_scheme.scheme);
}
if (custom_scheme.options.stream) {
g_streaming_schemes.push_back(custom_scheme.scheme);

View file

@ -915,6 +915,7 @@ WebContents::~WebContents() {
return;
}
inspectable_web_contents_->GetView()->SetDelegate(nullptr);
if (guest_delegate_)
guest_delegate_->WillDestroy();
@ -1761,6 +1762,7 @@ void WebContents::DevToolsOpened() {
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
DCHECK(inspectable_web_contents_);
DCHECK(inspectable_web_contents_->GetDevToolsWebContents());
auto handle = FromOrCreate(
isolate, inspectable_web_contents_->GetDevToolsWebContents());
devtools_web_contents_.Reset(isolate, handle.ToV8());

View file

@ -1363,22 +1363,26 @@ void ElectronBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
int render_process_id,
int render_frame_id,
NonNetworkURLLoaderFactoryMap* factories) {
content::RenderFrameHost* frame_host =
content::RenderFrameHost::FromID(render_process_id, render_frame_id);
content::WebContents* web_contents =
content::WebContents::FromRenderFrameHost(frame_host);
auto* render_process_host =
content::RenderProcessHost::FromID(render_process_id);
DCHECK(render_process_host);
if (!render_process_host || !render_process_host->GetBrowserContext())
return;
ProtocolRegistry::FromBrowserContext(render_process_host->GetBrowserContext())
->RegisterURLLoaderFactories(URLLoaderFactoryType::kDocumentSubResource,
factories);
if (web_contents) {
ProtocolRegistry::FromBrowserContext(web_contents->GetBrowserContext())
->RegisterURLLoaderFactories(URLLoaderFactoryType::kDocumentSubResource,
factories);
}
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
auto factory = extensions::CreateExtensionURLLoaderFactory(render_process_id,
render_frame_id);
if (factory)
factories->emplace(extensions::kExtensionScheme, std::move(factory));
content::RenderFrameHost* frame_host =
content::RenderFrameHost::FromID(render_process_id, render_frame_id);
content::WebContents* web_contents =
content::WebContents::FromRenderFrameHost(frame_host);
if (!web_contents)
return;

View file

@ -317,8 +317,9 @@ void NativeBrowserViewMac::UpdateDraggableRegions(
const auto window_content_view_height = NSHeight(window_content_view.bounds);
for (const auto& rect : drag_exclude_rects) {
const auto x = rect.x() + offset.x();
const auto y = window_content_view_height - rect.bottom() + offset.y();
const auto y = window_content_view_height - (rect.bottom() + offset.y());
const auto exclude_rect = NSMakeRect(x, y, rect.width(), rect.height());
const auto drag_region_view_exclude_rect =
[window_content_view convertRect:exclude_rect toView:drag_region_view];

View file

@ -206,6 +206,7 @@ class NativeWindow : public base::SupportsUserData,
virtual void SetTrafficLightPosition(base::Optional<gfx::Point> position) = 0;
virtual base::Optional<gfx::Point> GetTrafficLightPosition() const = 0;
virtual void RedrawTrafficLights() = 0;
virtual void UpdateFrame() = 0;
#endif
// Touchbar API

View file

@ -14,6 +14,7 @@
#include "base/mac/scoped_nsobject.h"
#include "shell/browser/native_window.h"
#include "ui/display/display_observer.h"
#include "ui/native_theme/native_theme_observer.h"
#include "ui/views/controls/native/native_view_host.h"
@ -27,7 +28,9 @@ namespace electron {
class RootViewMac;
class NativeWindowMac : public NativeWindow, public ui::NativeThemeObserver {
class NativeWindowMac : public NativeWindow,
public ui::NativeThemeObserver,
public display::DisplayObserver {
public:
NativeWindowMac(const gin_helper::Dictionary& options, NativeWindow* parent);
~NativeWindowMac() override;
@ -124,6 +127,7 @@ class NativeWindowMac : public NativeWindow, public ui::NativeThemeObserver {
void SetTrafficLightPosition(base::Optional<gfx::Point> position) override;
base::Optional<gfx::Point> GetTrafficLightPosition() const override;
void RedrawTrafficLights() override;
void UpdateFrame() override;
void SetTouchBar(
std::vector<gin_helper::PersistentDictionary> items) override;
void RefreshTouchBarItem(const std::string& item_id) override;
@ -188,6 +192,10 @@ class NativeWindowMac : public NativeWindow, public ui::NativeThemeObserver {
// ui::NativeThemeObserver:
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
// display::DisplayObserver:
void OnDisplayMetricsChanged(const display::Display& display,
uint32_t changed_metrics) override;
private:
// Add custom layers to the content view.
void AddContentViewLayers();

View file

@ -39,6 +39,7 @@
#include "shell/common/process_util.h"
#include "skia/ext/skia_utils_mac.h"
#include "third_party/webrtc/modules/desktop_capture/mac/window_list_utils.h"
#include "ui/display/screen.h"
#include "ui/gfx/skia_util.h"
#include "ui/gl/gpu_switching_manager.h"
#include "ui/views/background.h"
@ -258,6 +259,7 @@ NativeWindowMac::NativeWindowMac(const gin_helper::Dictionary& options,
NativeWindow* parent)
: NativeWindow(options, parent), root_view_(new RootViewMac(this)) {
ui::NativeTheme::GetInstanceForNativeUi()->AddObserver(this);
display::Screen::GetScreen()->AddObserver(this);
int width = 800, height = 600;
options.Get(options::kWidth, &width);
@ -882,6 +884,17 @@ void NativeWindowMac::SetExcludedFromShownWindowsMenu(bool excluded) {
[window setExcludedFromWindowsMenu:excluded];
}
void NativeWindowMac::OnDisplayMetricsChanged(const display::Display& display,
uint32_t changed_metrics) {
// We only want to force screen recalibration if we're in simpleFullscreen
// mode.
if (!is_simple_fullscreen_)
return;
base::PostTask(FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&NativeWindow::UpdateFrame, GetWeakPtr()));
}
void NativeWindowMac::SetSimpleFullScreen(bool simple_fullscreen) {
NSWindow* window = GetNativeWindow().GetNativeNSWindow();
@ -1396,6 +1409,13 @@ void NativeWindowMac::RedrawTrafficLights() {
[buttons_view_ setNeedsDisplayForButtons];
}
// In simpleFullScreen mode, update the frame for new bounds.
void NativeWindowMac::UpdateFrame() {
NSWindow* window = GetNativeWindow().GetNativeNSWindow();
NSRect fullscreenFrame = [window.screen frame];
[window setFrame:fullscreenFrame display:YES animate:YES];
}
void NativeWindowMac::SetTouchBar(
std::vector<gin_helper::PersistentDictionary> items) {
if (@available(macOS 10.12.2, *)) {
@ -1551,6 +1571,7 @@ void NativeWindowMac::NotifyWindowWillLeaveFullScreen() {
void NativeWindowMac::Cleanup() {
DCHECK(!IsClosed());
ui::NativeTheme::GetInstanceForNativeUi()->RemoveObserver(this);
display::Screen::GetScreen()->RemoveObserver(this);
[NSEvent removeMonitor:wheel_event_monitor_];
}

View file

@ -50,8 +50,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 14,0,0,20210315
PRODUCTVERSION 14,0,0,20210315
FILEVERSION 14,0,0,20210323
PRODUCTVERSION 14,0,0,20210323
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L

View file

@ -201,12 +201,6 @@ class InspectableWebContents
void AddDevToolsExtensionsToClient();
#endif
bool frontend_loaded_ = false;
scoped_refptr<content::DevToolsAgentHost> agent_host_;
std::unique_ptr<content::DevToolsFrontendHost> frontend_host_;
std::unique_ptr<DevToolsEmbedderMessageDispatcher>
embedder_message_dispatcher_;
DevToolsContentsResizingStrategy contents_resizing_strategy_;
gfx::Rect devtools_bounds_;
bool can_dock_ = true;
@ -228,6 +222,12 @@ class InspectableWebContents
bool is_guest_;
std::unique_ptr<InspectableWebContentsView> view_;
bool frontend_loaded_ = false;
scoped_refptr<content::DevToolsAgentHost> agent_host_;
std::unique_ptr<content::DevToolsFrontendHost> frontend_host_;
std::unique_ptr<DevToolsEmbedderMessageDispatcher>
embedder_message_dispatcher_;
class NetworkResourceLoader;
std::set<std::unique_ptr<NetworkResourceLoader>, base::UniquePtrComparator>
loaders_;