chore: bump chromium to 92.0.4511.0 (master) (#29173)

This commit is contained in:
electron-roller[bot] 2021-05-19 16:15:47 -07:00 committed by GitHub
parent d79ebc6dc6
commit 039f3d5cd2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
80 changed files with 426 additions and 322 deletions

View file

@ -328,8 +328,7 @@ Session::Session(v8::Isolate* isolate, ElectronBrowserContext* browser_context)
network_emulation_token_(base::UnguessableToken::Create()),
browser_context_(browser_context) {
// Observe DownloadManager to get download notifications.
content::BrowserContext::GetDownloadManager(browser_context)
->AddObserver(this);
browser_context->GetDownloadManager()->AddObserver(this);
new SessionPreferences(browser_context);
@ -352,8 +351,7 @@ Session::Session(v8::Isolate* isolate, ElectronBrowserContext* browser_context)
}
Session::~Session() {
content::BrowserContext::GetDownloadManager(browser_context())
->RemoveObserver(this);
browser_context()->GetDownloadManager()->RemoveObserver(this);
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
SpellcheckService* service =
@ -726,8 +724,7 @@ v8::Local<v8::Promise> Session::GetBlobData(v8::Isolate* isolate,
}
void Session::DownloadURL(const GURL& url) {
auto* download_manager =
content::BrowserContext::GetDownloadManager(browser_context());
auto* download_manager = browser_context()->GetDownloadManager();
auto download_params = std::make_unique<download::DownloadUrlParameters>(
url, MISSING_TRAFFIC_ANNOTATION);
download_manager->DownloadUrl(std::move(download_params));
@ -757,8 +754,7 @@ void Session::CreateInterruptedDownload(const gin_helper::Dictionary& options) {
isolate_, "Must pass an offset value less than length.")));
return;
}
auto* download_manager =
content::BrowserContext::GetDownloadManager(browser_context());
auto* download_manager = browser_context()->GetDownloadManager();
download_manager->GetNextId(base::BindRepeating(
&DownloadIdCallback, download_manager, path, url_chain, mime_type, offset,
length, last_modified, etag, base::Time::FromDoubleT(start_time)));

View file

@ -162,11 +162,11 @@
#endif
#if BUILDFLAG(ENABLE_PRINTING)
#include "chrome/browser/printing/print_view_manager_basic.h"
#include "components/printing/browser/print_manager_utils.h"
#include "printing/backend/print_backend.h" // nogncheck
#include "printing/mojom/print.mojom.h"
#include "shell/browser/printing/print_preview_message_handler.h"
#include "shell/browser/printing/print_view_manager_electron.h"
#if defined(OS_WIN)
#include "printing/backend/win_helper.h"
@ -557,7 +557,7 @@ void AppendToFile(const base::FilePath& path, const std::string& content) {
base::BlockingType::WILL_BLOCK);
DCHECK(!path.empty());
base::AppendToFile(path, content.data(), content.size());
base::AppendToFile(path, content);
}
PrefService* GetPrefService(content::WebContents* web_contents) {
@ -886,7 +886,7 @@ void WebContents::InitWithWebContents(content::WebContents* web_contents,
#if BUILDFLAG(ENABLE_PRINTING)
PrintPreviewMessageHandler::CreateForWebContents(web_contents);
printing::PrintViewManagerBasic::CreateForWebContents(web_contents);
PrintViewManagerElectron::CreateForWebContents(web_contents);
printing::CreateCompositeClientIfNeeded(web_contents,
browser_context->GetUserAgent());
#endif
@ -2014,8 +2014,7 @@ void WebContents::ReloadIgnoringCache() {
void WebContents::DownloadURL(const GURL& url) {
auto* browser_context = web_contents()->GetBrowserContext();
auto* download_manager =
content::BrowserContext::GetDownloadManager(browser_context);
auto* download_manager = browser_context->GetDownloadManager();
std::unique_ptr<download::DownloadUrlParameters> download_params(
content::DownloadRequestUtils::CreateDownloadForWebContentsMainFrame(
web_contents(), url, MISSING_TRAFFIC_ANNOTATION));
@ -2366,7 +2365,7 @@ void WebContents::OnGetDefaultPrinter(
bool silent,
std::u16string default_printer) {
// The content::WebContents might be already deleted at this point, and the
// PrintViewManagerBasic class does not do null check.
// PrintViewManagerElectron class does not do null check.
if (!web_contents()) {
if (print_callback)
std::move(print_callback).Run(false, "failed");
@ -2386,7 +2385,10 @@ void WebContents::OnGetDefaultPrinter(
print_settings.SetStringKey(printing::kSettingDeviceName, printer_name);
auto* print_view_manager =
printing::PrintViewManagerBasic::FromWebContents(web_contents());
PrintViewManagerElectron::FromWebContents(web_contents());
if (!print_view_manager)
return;
auto* focused_frame = web_contents()->GetFocusedFrame();
auto* rfh = focused_frame && focused_frame->HasSelection()
? focused_frame

View file

@ -43,8 +43,8 @@
#include "ui/gfx/image/image.h"
#if BUILDFLAG(ENABLE_PRINTING)
#include "chrome/browser/printing/print_view_manager_basic.h"
#include "shell/browser/printing/print_preview_message_handler.h"
#include "shell/browser/printing/print_view_manager_electron.h"
#endif
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)

View file

@ -31,8 +31,8 @@ void SavePageHandler::OnDownloadCreated(content::DownloadManager* manager,
bool SavePageHandler::Handle(const base::FilePath& full_path,
const content::SavePageType& save_type) {
auto* download_manager = content::BrowserContext::GetDownloadManager(
web_contents_->GetBrowserContext());
auto* download_manager =
web_contents_->GetBrowserContext()->GetDownloadManager();
download_manager->AddObserver(this);
// Chromium will create a 'foo_files' directory under the directory of saving
// page 'foo.html' for holding other resource files of 'foo.html'.

View file

@ -500,11 +500,12 @@ void Browser::ShowAboutPanel() {
void Browser::SetAboutPanelOptions(base::DictionaryValue options) {
about_panel_options_.Clear();
for (auto& pair : options) {
std::string& key = pair.first;
if (!key.empty() && pair.second->is_string()) {
for (const auto& pair : options.DictItems()) {
std::string key = std::string(pair.first);
if (!key.empty() && pair.second.is_string()) {
key[0] = base::ToUpperASCII(key[0]);
about_panel_options_.Set(key, std::move(pair.second));
auto val = std::make_unique<base::Value>(pair.second.Clone());
about_panel_options_.Set(key, std::move(val));
}
}
}

View file

@ -168,8 +168,7 @@ bool FormatCommandLineString(std::wstring* exe,
}
if (!launch_args.empty()) {
std::u16string joined_launch_args =
base::JoinString(launch_args, base::UTF8ToUTF16(" "));
std::u16string joined_launch_args = base::JoinString(launch_args, u" ");
*exe = base::StringPrintf(L"%ls %ls", exe->c_str(),
base::UTF16ToWide(joined_launch_args).c_str());
}

View file

@ -281,7 +281,7 @@ ElectronBrowserContext::CreateZoomLevelDelegate(
content::DownloadManagerDelegate*
ElectronBrowserContext::GetDownloadManagerDelegate() {
if (!download_manager_delegate_.get()) {
auto* download_manager = content::BrowserContext::GetDownloadManager(this);
auto* download_manager = this->GetDownloadManager();
download_manager_delegate_ =
std::make_unique<ElectronDownloadManagerDelegate>(download_manager);
}

View file

@ -475,12 +475,12 @@ void ElectronBrowserMainParts::WillRunMainMessageLoop(
Browser::Get()->SetMainMessageLoopQuitClosure(run_loop->QuitClosure());
}
void ElectronBrowserMainParts::PostMainMessageLoopStart() {
void ElectronBrowserMainParts::PostCreateMainMessageLoop() {
#if defined(USE_OZONE)
if (features::IsUsingOzonePlatform()) {
auto shutdown_cb =
base::BindOnce(base::RunLoop::QuitCurrentWhenIdleClosureDeprecated());
ui::OzonePlatform::GetInstance()->PostMainMessageLoopStart(
ui::OzonePlatform::GetInstance()->PostCreateMainMessageLoop(
std::move(shutdown_cb));
}
#endif
@ -503,8 +503,7 @@ void ElectronBrowserMainParts::PostMainMessageLoopRun() {
// Shutdown the DownloadManager before destroying Node to prevent
// DownloadItem callbacks from crashing.
for (auto& iter : ElectronBrowserContext::browser_context_map()) {
auto* download_manager =
content::BrowserContext::GetDownloadManager(iter.second.get());
auto* download_manager = iter.second.get()->GetDownloadManager();
if (download_manager) {
download_manager->Shutdown();
}
@ -528,12 +527,12 @@ void ElectronBrowserMainParts::PostMainMessageLoopRun() {
}
#if !defined(OS_MAC)
void ElectronBrowserMainParts::PreMainMessageLoopStart() {
PreMainMessageLoopStartCommon();
void ElectronBrowserMainParts::PreCreateMainMessageLoop() {
PreCreateMainMessageLoopCommon();
}
#endif
void ElectronBrowserMainParts::PreMainMessageLoopStartCommon() {
void ElectronBrowserMainParts::PreCreateMainMessageLoopCommon() {
#if defined(OS_MAC)
InitializeMainNib();
RegisterURLHandler();

View file

@ -99,14 +99,14 @@ class ElectronBrowserMainParts : public content::BrowserMainParts {
int PreMainMessageLoopRun() override;
void WillRunMainMessageLoop(
std::unique_ptr<base::RunLoop>& run_loop) override;
void PostMainMessageLoopStart() override;
void PostCreateMainMessageLoop() override;
void PostMainMessageLoopRun() override;
void PreMainMessageLoopStart() override;
void PreCreateMainMessageLoop() override;
void PostCreateThreads() override;
void PostDestroyThreads() override;
private:
void PreMainMessageLoopStartCommon();
void PreCreateMainMessageLoopCommon();
#if defined(OS_POSIX)
// Set signal handlers.

View file

@ -14,13 +14,13 @@
namespace electron {
void ElectronBrowserMainParts::PreMainMessageLoopStart() {
void ElectronBrowserMainParts::PreCreateMainMessageLoop() {
// Set our own application delegate.
ElectronApplicationDelegate* delegate =
[[ElectronApplicationDelegate alloc] init];
[NSApp setDelegate:delegate];
PreMainMessageLoopStartCommon();
PreCreateMainMessageLoopCommon();
// Prevent Cocoa from turning command-line arguments into
// |-application:openFiles:|, since we already handle them directly.

View file

@ -60,19 +60,19 @@ void GracefulShutdownHandler(int signal) {
} while (bytes_written < sizeof(signal));
}
// See comment in |PostMainMessageLoopStart()|, where sigaction is called.
// See comment in |PostCreateMainMessageLoop()|, where sigaction is called.
void SIGHUPHandler(int signal) {
RAW_CHECK(signal == SIGHUP);
GracefulShutdownHandler(signal);
}
// See comment in |PostMainMessageLoopStart()|, where sigaction is called.
// See comment in |PostCreateMainMessageLoop()|, where sigaction is called.
void SIGINTHandler(int signal) {
RAW_CHECK(signal == SIGINT);
GracefulShutdownHandler(signal);
}
// See comment in |PostMainMessageLoopStart()|, where sigaction is called.
// See comment in |PostCreateMainMessageLoop()|, where sigaction is called.
void SIGTERMHandler(int signal) {
RAW_CHECK(signal == SIGTERM);
GracefulShutdownHandler(signal);

View file

@ -18,9 +18,9 @@
#include "v8/include/v8.h"
#if BUILDFLAG(ENABLE_PRINTING)
#include "chrome/browser/printing/print_view_manager_basic.h"
#include "components/printing/browser/print_manager_utils.h"
#include "shell/browser/printing/print_preview_message_handler.h"
#include "shell/browser/printing/print_view_manager_electron.h"
#endif
#if BUILDFLAG(ENABLE_PDF_VIEWER)
@ -81,7 +81,7 @@ void ElectronExtensionsAPIClient::AttachWebContentsHelpers(
content::WebContents* web_contents) const {
#if BUILDFLAG(ENABLE_PRINTING)
electron::PrintPreviewMessageHandler::CreateForWebContents(web_contents);
printing::PrintViewManagerBasic::CreateForWebContents(web_contents);
electron::PrintViewManagerElectron::CreateForWebContents(web_contents);
#endif
#if BUILDFLAG(ENABLE_PDF_VIEWER)

View file

@ -40,7 +40,7 @@ base::ListValue NSArrayToListValue(NSArray* arr) {
result.AppendBoolean([value boolValue]);
else if (strcmp(objc_type, @encode(double)) == 0 ||
strcmp(objc_type, @encode(float)) == 0)
result.AppendDouble([value doubleValue]);
result.Append([value doubleValue]);
else
result.AppendInteger([value intValue]);
} else if ([value isKindOfClass:[NSArray class]]) {

View file

@ -189,7 +189,15 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
DCHECK(render_widget_host_);
DCHECK(!render_widget_host_->GetView());
set_current_device_scale_factor(kDefaultScaleFactor);
// Initialize a display struct as needed, to cache the scale factor.
if (display_list_.displays().empty()) {
display_list_ = display::DisplayList(
{display::Display(display::kDefaultDisplayId)},
display::kDefaultDisplayId, display::kDefaultDisplayId);
}
display::Display current_display = *display_list_.GetCurrentDisplayIterator();
current_display.set_device_scale_factor(kDefaultScaleFactor);
display_list_.UpdateDisplay(current_display);
delegated_frame_host_allocator_.GenerateId();
delegated_frame_host_surface_id_ =
@ -476,7 +484,7 @@ void OffScreenRenderWidgetHostView::GetScreenInfo(
screen_info->depth = 24;
screen_info->depth_per_component = 8;
screen_info->orientation_angle = 0;
screen_info->device_scale_factor = current_device_scale_factor();
screen_info->device_scale_factor = GetCurrentDeviceScaleFactor();
screen_info->orientation_type =
blink::mojom::ScreenOrientation::kLandscapePrimary;
screen_info->rect = gfx::Rect(size_);
@ -516,7 +524,7 @@ void OffScreenRenderWidgetHostView::ImeCompositionRangeChanged(
gfx::Size OffScreenRenderWidgetHostView::GetCompositorViewportPixelSize() {
return gfx::ScaleToCeiledSize(GetRequestedRendererSize(),
current_device_scale_factor());
GetCurrentDeviceScaleFactor());
}
content::RenderWidgetHostViewBase*
@ -672,12 +680,13 @@ void OffScreenRenderWidgetHostView::OnPaint(const gfx::Rect& damage_rect,
}
gfx::Size OffScreenRenderWidgetHostView::SizeInPixels() {
float sf = GetCurrentDeviceScaleFactor();
if (IsPopupWidget()) {
return gfx::ToFlooredSize(gfx::ConvertSizeToPixels(
popup_position_.size(), current_device_scale_factor()));
return gfx::ToFlooredSize(
gfx::ConvertSizeToPixels(popup_position_.size(), sf));
} else {
return gfx::ToFlooredSize(gfx::ConvertSizeToPixels(
GetViewBounds().size(), current_device_scale_factor()));
return gfx::ToFlooredSize(
gfx::ConvertSizeToPixels(GetViewBounds().size(), sf));
}
}
@ -693,6 +702,7 @@ void OffScreenRenderWidgetHostView::CompositeFrame(
if (proxy_views_.empty() && !popup_host_view_) {
frame = GetBacking();
} else {
float sf = GetCurrentDeviceScaleFactor();
frame.allocN32Pixels(size_in_pixels.width(), size_in_pixels.height(),
false);
if (!GetBacking().drawsNothing()) {
@ -702,8 +712,7 @@ void OffScreenRenderWidgetHostView::CompositeFrame(
if (popup_host_view_ && !popup_host_view_->GetBacking().drawsNothing()) {
gfx::Rect rect = popup_host_view_->popup_position_;
gfx::Point origin_in_pixels =
gfx::ToFlooredPoint(gfx::ConvertPointToPixels(
rect.origin(), current_device_scale_factor()));
gfx::ToFlooredPoint(gfx::ConvertPointToPixels(rect.origin(), sf));
canvas.writePixels(popup_host_view_->GetBacking(), origin_in_pixels.x(),
origin_in_pixels.y());
}
@ -711,8 +720,7 @@ void OffScreenRenderWidgetHostView::CompositeFrame(
for (auto* proxy_view : proxy_views_) {
gfx::Rect rect = proxy_view->GetBounds();
gfx::Point origin_in_pixels =
gfx::ToFlooredPoint(gfx::ConvertPointToPixels(
rect.origin(), current_device_scale_factor()));
gfx::ToFlooredPoint(gfx::ConvertPointToPixels(rect.origin(), sf));
canvas.writePixels(*proxy_view->GetBitmap(), origin_in_pixels.x(),
origin_in_pixels.y());
}
@ -729,13 +737,13 @@ void OffScreenRenderWidgetHostView::CompositeFrame(
void OffScreenRenderWidgetHostView::OnPopupPaint(const gfx::Rect& damage_rect) {
InvalidateBounds(gfx::ToEnclosingRect(
gfx::ConvertRectToPixels(damage_rect, current_device_scale_factor())));
gfx::ConvertRectToPixels(damage_rect, GetCurrentDeviceScaleFactor())));
}
void OffScreenRenderWidgetHostView::OnProxyViewPaint(
const gfx::Rect& damage_rect) {
InvalidateBounds(gfx::ToEnclosingRect(
gfx::ConvertRectToPixels(damage_rect, current_device_scale_factor())));
gfx::ConvertRectToPixels(damage_rect, GetCurrentDeviceScaleFactor())));
}
void OffScreenRenderWidgetHostView::HoldResize() {
@ -984,10 +992,18 @@ void OffScreenRenderWidgetHostView::ResizeRootLayer(bool force) {
display::Display display =
display::Screen::GetScreen()->GetDisplayNearestView(GetNativeView());
const float scaleFactor = display.device_scale_factor();
const bool scaleFactorDidChange =
(scaleFactor != current_device_scale_factor());
float sf = GetCurrentDeviceScaleFactor();
const bool scaleFactorDidChange = scaleFactor != sf;
set_current_device_scale_factor(scaleFactor);
// Initialize a display struct as needed, to cache the scale factor.
if (display_list_.displays().empty()) {
display_list_ = display::DisplayList(
{display::Display(display::kDefaultDisplayId)},
display::kDefaultDisplayId, display::kDefaultDisplayId);
}
display::Display current_display = *display_list_.GetCurrentDisplayIterator();
current_display.set_device_scale_factor(scaleFactor);
display_list_.UpdateDisplay(current_display);
gfx::Size size;
if (!IsPopupWidget())
@ -1001,14 +1017,13 @@ void OffScreenRenderWidgetHostView::ResizeRootLayer(bool force) {
GetRootLayer()->SetBounds(gfx::Rect(size));
const gfx::Size& size_in_pixels = gfx::ToFlooredSize(
gfx::ConvertSizeToPixels(size, current_device_scale_factor()));
const gfx::Size& size_in_pixels =
gfx::ToFlooredSize(gfx::ConvertSizeToPixels(size, sf));
if (compositor_) {
compositor_allocator_.GenerateId();
compositor_surface_id_ = compositor_allocator_.GetCurrentLocalSurfaceId();
compositor_->SetScaleAndSize(current_device_scale_factor(), size_in_pixels,
compositor_surface_id_);
compositor_->SetScaleAndSize(sf, size_in_pixels, compositor_surface_id_);
}
delegated_frame_host_allocator_.GenerateId();

View file

@ -0,0 +1,37 @@
// Copyright 2020 Microsoft, Inc. All rights reserved.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/browser/printing/print_view_manager_electron.h"
#include <utility>
#include "build/build_config.h"
namespace electron {
PrintViewManagerElectron::PrintViewManagerElectron(
content::WebContents* web_contents)
: PrintViewManagerBase(web_contents) {}
PrintViewManagerElectron::~PrintViewManagerElectron() {}
void PrintViewManagerElectron::SetupScriptedPrintPreview(
SetupScriptedPrintPreviewCallback callback) {
std::move(callback).Run();
}
void PrintViewManagerElectron::ShowScriptedPrintPreview(
bool source_is_modifiable) {}
void PrintViewManagerElectron::RequestPrintPreview(
printing::mojom::RequestPrintPreviewParamsPtr params) {}
void PrintViewManagerElectron::CheckForCancel(int32_t preview_ui_id,
int32_t request_id,
CheckForCancelCallback callback) {
}
WEB_CONTENTS_USER_DATA_KEY_IMPL(PrintViewManagerElectron)
} // namespace electron

View file

@ -0,0 +1,41 @@
// Copyright 2020 Microsoft, Inc. All rights reserved.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef SHELL_BROWSER_PRINTING_PRINT_VIEW_MANAGER_ELECTRON_H_
#define SHELL_BROWSER_PRINTING_PRINT_VIEW_MANAGER_ELECTRON_H_
#include "base/macros.h"
#include "build/build_config.h"
#include "chrome/browser/printing/print_view_manager_base.h"
#include "content/public/browser/web_contents_user_data.h"
namespace electron {
class PrintViewManagerElectron
: public printing::PrintViewManagerBase,
public content::WebContentsUserData<PrintViewManagerElectron> {
public:
~PrintViewManagerElectron() override;
void SetupScriptedPrintPreview(
SetupScriptedPrintPreviewCallback callback) override;
void ShowScriptedPrintPreview(bool source_is_modifiable) override;
void RequestPrintPreview(
printing::mojom::RequestPrintPreviewParamsPtr params) override;
void CheckForCancel(int32_t preview_ui_id,
int32_t request_id,
CheckForCancelCallback callback) override;
private:
friend class content::WebContentsUserData<PrintViewManagerElectron>;
explicit PrintViewManagerElectron(content::WebContents* web_contents);
WEB_CONTENTS_USER_DATA_KEY_DECL();
DISALLOW_COPY_AND_ASSIGN(PrintViewManagerElectron);
};
} // namespace electron
#endif // SHELL_BROWSER_PRINTING_PRINT_VIEW_MANAGER_ELECTRON_H_