chore: bump chromium to 106.0.5216.0 (main) (#34993)
This commit is contained in:
parent
e15e66f229
commit
97b353a30a
114 changed files with 886 additions and 779 deletions
|
@ -240,7 +240,7 @@ const char* const ElectronMainDelegate::kNonWildcardDomainNonPortSchemes[] = {
|
|||
const size_t ElectronMainDelegate::kNonWildcardDomainNonPortSchemesSize =
|
||||
std::size(kNonWildcardDomainNonPortSchemes);
|
||||
|
||||
bool ElectronMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
absl::optional<int> ElectronMainDelegate::BasicStartupComplete() {
|
||||
auto* command_line = base::CommandLine::ForCurrentProcess();
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
|
@ -318,7 +318,7 @@ bool ElectronMainDelegate::BasicStartupComplete(int* exit_code) {
|
|||
content_client_ = std::make_unique<ElectronContentClient>();
|
||||
SetContentClient(content_client_.get());
|
||||
|
||||
return false;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
void ElectronMainDelegate::PreSandboxStartup() {
|
||||
|
@ -411,7 +411,7 @@ void ElectronMainDelegate::SandboxInitialized(const std::string& process_type) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void ElectronMainDelegate::PreBrowserMain() {
|
||||
absl::optional<int> ElectronMainDelegate::PreBrowserMain() {
|
||||
// This is initialized early because the service manager reads some feature
|
||||
// flags and we need to make sure the feature list is initialized before the
|
||||
// service manager reads the features.
|
||||
|
@ -419,6 +419,7 @@ void ElectronMainDelegate::PreBrowserMain() {
|
|||
#if BUILDFLAG(IS_MAC)
|
||||
RegisterAtomCrApp();
|
||||
#endif
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
content::ContentBrowserClient*
|
||||
|
|
|
@ -32,10 +32,10 @@ class ElectronMainDelegate : public content::ContentMainDelegate {
|
|||
|
||||
protected:
|
||||
// content::ContentMainDelegate:
|
||||
bool BasicStartupComplete(int* exit_code) override;
|
||||
absl::optional<int> BasicStartupComplete() override;
|
||||
void PreSandboxStartup() override;
|
||||
void SandboxInitialized(const std::string& process_type) override;
|
||||
void PreBrowserMain() override;
|
||||
absl::optional<int> PreBrowserMain() override;
|
||||
content::ContentBrowserClient* CreateContentBrowserClient() override;
|
||||
content::ContentGpuClient* CreateContentGpuClient() override;
|
||||
content::ContentRendererClient* CreateContentRendererClient() override;
|
||||
|
|
|
@ -210,7 +210,7 @@ void Menu::Clear() {
|
|||
}
|
||||
|
||||
int Menu::GetIndexOfCommandId(int command_id) const {
|
||||
return model_->GetIndexOfCommandId(command_id);
|
||||
return model_->GetIndexOfCommandId(command_id).value_or(-1);
|
||||
}
|
||||
|
||||
int Menu::GetItemCount() const {
|
||||
|
|
|
@ -2868,7 +2868,7 @@ void WebContents::OnPDFCreated(
|
|||
gin_helper::Promise<v8::Local<v8::Value>> promise,
|
||||
PrintViewManagerElectron::PrintResult print_result,
|
||||
scoped_refptr<base::RefCountedMemory> data) {
|
||||
if (print_result != PrintViewManagerElectron::PrintResult::PRINT_SUCCESS) {
|
||||
if (print_result != PrintViewManagerElectron::PrintResult::kPrintSuccess) {
|
||||
promise.RejectWithErrorMessage(
|
||||
"Failed to generate PDF: " +
|
||||
PrintViewManagerElectron::PrintResultToString(print_result));
|
||||
|
|
|
@ -134,7 +134,8 @@ void ElectronBluetoothDelegate::ShowDevicePairPrompt(
|
|||
content::RenderFrameHost* frame,
|
||||
const std::u16string& device_identifier,
|
||||
PairPromptCallback callback,
|
||||
PairingKind pairing_kind) {
|
||||
PairingKind pairing_kind,
|
||||
const absl::optional<std::u16string>& pin) {
|
||||
NOTIMPLEMENTED();
|
||||
std::move(callback).Run(BluetoothDelegate::PairPromptResult(
|
||||
BluetoothDelegate::PairPromptStatus::kCancelled));
|
||||
|
|
|
@ -55,7 +55,8 @@ class ElectronBluetoothDelegate : public content::BluetoothDelegate {
|
|||
void ShowDevicePairPrompt(content::RenderFrameHost* frame,
|
||||
const std::u16string& device_identifier,
|
||||
PairPromptCallback callback,
|
||||
PairingKind pairing_kind) override;
|
||||
PairingKind pairing_kind,
|
||||
const absl::optional<std::u16string>& pin) override;
|
||||
blink::WebBluetoothDeviceId GetWebBluetoothDeviceId(
|
||||
content::RenderFrameHost* frame,
|
||||
const std::string& device_address) override;
|
||||
|
|
|
@ -1539,8 +1539,7 @@ void ElectronBrowserClient::OverrideURLLoaderFactoryParams(
|
|||
bool ElectronBrowserClient::PreSpawnChild(sandbox::TargetPolicy* policy,
|
||||
sandbox::mojom::Sandbox sandbox_type,
|
||||
ChildSpawnFlags flags) {
|
||||
// Allow crashpad to communicate via named pipe.
|
||||
sandbox::ResultCode result = policy->AddRule(
|
||||
sandbox::ResultCode result = policy->GetConfig()->AddRule(
|
||||
sandbox::SubSystem::kFiles, sandbox::Semantics::kFilesAllowAny,
|
||||
L"\\??\\pipe\\crashpad_*");
|
||||
if (result != sandbox::SBOX_ALL_OK)
|
||||
|
|
|
@ -82,6 +82,7 @@
|
|||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "base/win/dark_mode_support.h"
|
||||
#include "ui/base/l10n/l10n_util_win.h"
|
||||
#include "ui/display/win/dpi.h"
|
||||
#include "ui/gfx/system_fonts_win.h"
|
||||
|
@ -370,7 +371,6 @@ void ElectronBrowserMainParts::PostDestroyThreads() {
|
|||
void ElectronBrowserMainParts::ToolkitInitialized() {
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
auto linux_ui = ui::CreateLinuxUi();
|
||||
DCHECK(ui::LinuxInputMethodContextFactory::instance());
|
||||
|
||||
// Try loading gtk symbols used by Electron.
|
||||
electron::InitializeElectron_gtk(gtk::GetLibGtk());
|
||||
|
@ -440,6 +440,11 @@ int ElectronBrowserMainParts::PreMainMessageLoopRun() {
|
|||
SpellcheckServiceFactory::GetInstance();
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
// access ui native theme here to prevent blocking calls later
|
||||
base::win::AllowDarkModeForApp(true);
|
||||
#endif
|
||||
|
||||
content::WebUIControllerFactory::RegisterFactory(
|
||||
ElectronWebUIControllerFactory::GetInstance());
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <utility>
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/containers/contains.h"
|
||||
#include "chrome/common/chrome_features.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "services/device/public/cpp/hid/hid_switches.h"
|
||||
|
@ -106,6 +107,7 @@ void ElectronHidDelegate::AddObserver(content::BrowserContext* browser_context,
|
|||
}
|
||||
|
||||
void ElectronHidDelegate::RemoveObserver(
|
||||
content::BrowserContext* browser_context,
|
||||
content::HidDelegate::Observer* observer) {
|
||||
observer_list_.RemoveObserver(observer);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,8 @@ class ElectronHidDelegate : public content::HidDelegate,
|
|||
content::BrowserContext* browser_context) override;
|
||||
void AddObserver(content::BrowserContext* browser_context,
|
||||
content::HidDelegate::Observer* observer) override;
|
||||
void RemoveObserver(content::HidDelegate::Observer* observer) override;
|
||||
void RemoveObserver(content::BrowserContext* browser_context,
|
||||
content::HidDelegate::Observer* observer) override;
|
||||
const device::mojom::HidDeviceInfo* GetDeviceInfo(
|
||||
content::BrowserContext* browser_context,
|
||||
const std::string& guid) override;
|
||||
|
|
|
@ -63,27 +63,27 @@ void PrintViewManagerElectron::BindPrintManagerHost(
|
|||
// static
|
||||
std::string PrintViewManagerElectron::PrintResultToString(PrintResult result) {
|
||||
switch (result) {
|
||||
case PRINT_SUCCESS:
|
||||
case kPrintSuccess:
|
||||
return std::string(); // no error message
|
||||
case PRINTING_FAILED:
|
||||
case kPrintFailure:
|
||||
return "Printing failed";
|
||||
case INVALID_PRINTER_SETTINGS:
|
||||
case kInvalidPrinterSettings:
|
||||
return "Show invalid printer settings error";
|
||||
case INVALID_MEMORY_HANDLE:
|
||||
case kInvalidMemoryHandle:
|
||||
return "Invalid memory handle";
|
||||
case METAFILE_MAP_ERROR:
|
||||
case kMetafileMapError:
|
||||
return "Map to shared memory error";
|
||||
case METAFILE_INVALID_HEADER:
|
||||
case kMetafileInvalidHeader:
|
||||
return "Invalid metafile header";
|
||||
case METAFILE_GET_DATA_ERROR:
|
||||
case kMetafileGetDataError:
|
||||
return "Get data from metafile error";
|
||||
case SIMULTANEOUS_PRINT_ACTIVE:
|
||||
case kSimultaneousPrintActive:
|
||||
return "The previous printing job hasn't finished";
|
||||
case PAGE_RANGE_SYNTAX_ERROR:
|
||||
case kPageRangeSyntaxError:
|
||||
return "Page range syntax error";
|
||||
case PAGE_RANGE_INVALID_RANGE:
|
||||
case kPageRangeInvalidRange:
|
||||
return "Page range is invalid (start > end)";
|
||||
case PAGE_COUNT_EXCEEDED:
|
||||
case kPageCountExceeded:
|
||||
return "Page range exceeds page count";
|
||||
default:
|
||||
NOTREACHED();
|
||||
|
@ -99,39 +99,31 @@ void PrintViewManagerElectron::PrintToPdf(
|
|||
DCHECK(callback);
|
||||
|
||||
if (callback_) {
|
||||
std::move(callback).Run(SIMULTANEOUS_PRINT_ACTIVE,
|
||||
std::move(callback).Run(kSimultaneousPrintActive,
|
||||
base::MakeRefCounted<base::RefCountedString>());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!rfh->IsRenderFrameLive()) {
|
||||
std::move(callback).Run(PRINTING_FAILED,
|
||||
std::move(callback).Run(kPrintFailure,
|
||||
base::MakeRefCounted<base::RefCountedString>());
|
||||
return;
|
||||
}
|
||||
|
||||
absl::variant<printing::PageRanges, print_to_pdf::PageRangeError>
|
||||
absl::variant<printing::PageRanges, print_to_pdf::PdfPrintResult>
|
||||
parsed_ranges = print_to_pdf::TextPageRangesToPageRanges(page_ranges);
|
||||
if (absl::holds_alternative<print_to_pdf::PageRangeError>(parsed_ranges)) {
|
||||
PrintResult print_result;
|
||||
switch (absl::get<print_to_pdf::PageRangeError>(parsed_ranges)) {
|
||||
case print_to_pdf::PageRangeError::kSyntaxError:
|
||||
print_result = PAGE_RANGE_SYNTAX_ERROR;
|
||||
break;
|
||||
case print_to_pdf::PageRangeError::kInvalidRange:
|
||||
print_result = PAGE_RANGE_INVALID_RANGE;
|
||||
break;
|
||||
}
|
||||
std::move(callback).Run(print_result,
|
||||
base::MakeRefCounted<base::RefCountedString>());
|
||||
if (absl::holds_alternative<print_to_pdf::PdfPrintResult>(parsed_ranges)) {
|
||||
DCHECK_NE(absl::get<print_to_pdf::PdfPrintResult>(parsed_ranges),
|
||||
print_to_pdf::PdfPrintResult::kPrintSuccess);
|
||||
std::move(callback).Run(
|
||||
static_cast<PrintResult>(
|
||||
absl::get<print_to_pdf::PdfPrintResult>(parsed_ranges)),
|
||||
base::MakeRefCounted<base::RefCountedString>());
|
||||
return;
|
||||
}
|
||||
|
||||
printing_rfh_ = rfh;
|
||||
print_pages_params->pages = absl::get<printing::PageRanges>(parsed_ranges);
|
||||
auto cookie = print_pages_params->params->document_cookie;
|
||||
set_cookie(cookie);
|
||||
headless_jobs_.emplace_back(cookie);
|
||||
callback_ = std::move(callback);
|
||||
|
||||
// There is no need for a weak pointer here since the mojo proxy is held
|
||||
|
@ -147,26 +139,32 @@ void PrintViewManagerElectron::OnDidPrintWithParams(
|
|||
if (result->is_failure_reason()) {
|
||||
switch (result->get_failure_reason()) {
|
||||
case printing::mojom::PrintFailureReason::kGeneralFailure:
|
||||
ReleaseJob(PRINTING_FAILED);
|
||||
FailJob(kPrintFailure);
|
||||
return;
|
||||
case printing::mojom::PrintFailureReason::kInvalidPageRange:
|
||||
ReleaseJob(PAGE_COUNT_EXCEEDED);
|
||||
FailJob(kPageCountExceeded);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
auto& content = *result->get_params()->content;
|
||||
if (!content.metafile_data_region.IsValid()) {
|
||||
ReleaseJob(INVALID_MEMORY_HANDLE);
|
||||
FailJob(kInvalidMemoryHandle);
|
||||
return;
|
||||
}
|
||||
|
||||
base::ReadOnlySharedMemoryMapping map = content.metafile_data_region.Map();
|
||||
if (!map.IsValid()) {
|
||||
ReleaseJob(METAFILE_MAP_ERROR);
|
||||
FailJob(kMetafileMapError);
|
||||
return;
|
||||
}
|
||||
data_ = std::string(static_cast<const char*>(map.memory()), map.size());
|
||||
ReleaseJob(PRINT_SUCCESS);
|
||||
|
||||
std::string data =
|
||||
std::string(static_cast<const char*>(map.memory()), map.size());
|
||||
std::move(callback_).Run(kPrintSuccess,
|
||||
base::RefCountedString::TakeString(&data));
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
void PrintViewManagerElectron::GetDefaultPrintSettings(
|
||||
|
@ -201,7 +199,7 @@ void PrintViewManagerElectron::ShowInvalidPrinterSettingsError() {
|
|||
return;
|
||||
}
|
||||
|
||||
ReleaseJob(INVALID_PRINTER_SETTINGS);
|
||||
FailJob(kInvalidPrinterSettings);
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
|
@ -248,12 +246,7 @@ void PrintViewManagerElectron::RenderFrameDeleted(
|
|||
if (printing_rfh_ != render_frame_host)
|
||||
return;
|
||||
|
||||
if (callback_) {
|
||||
std::move(callback_).Run(PRINTING_FAILED,
|
||||
base::MakeRefCounted<base::RefCountedString>());
|
||||
}
|
||||
|
||||
Reset();
|
||||
FailJob(kPrintFailure);
|
||||
}
|
||||
|
||||
void PrintViewManagerElectron::DidGetPrintedPagesCount(int32_t cookie,
|
||||
|
@ -270,17 +263,14 @@ void PrintViewManagerElectron::Reset() {
|
|||
data_.clear();
|
||||
}
|
||||
|
||||
void PrintViewManagerElectron::ReleaseJob(PrintResult result) {
|
||||
void PrintViewManagerElectron::FailJob(PrintResult result) {
|
||||
DCHECK_NE(result, kPrintSuccess);
|
||||
if (callback_) {
|
||||
DCHECK(result == PRINT_SUCCESS || data_.empty());
|
||||
std::move(callback_).Run(result,
|
||||
base::RefCountedString::TakeString(&data_));
|
||||
if (printing_rfh_ && printing_rfh_->IsRenderFrameLive()) {
|
||||
GetPrintRenderFrame(printing_rfh_)->PrintingDone(result == PRINT_SUCCESS);
|
||||
}
|
||||
|
||||
Reset();
|
||||
base::MakeRefCounted<base::RefCountedString>());
|
||||
}
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
WEB_CONTENTS_USER_DATA_KEY_IMPL(PrintViewManagerElectron);
|
||||
|
|
|
@ -26,17 +26,17 @@ class PrintViewManagerElectron
|
|||
public content::WebContentsUserData<PrintViewManagerElectron> {
|
||||
public:
|
||||
enum PrintResult {
|
||||
PRINT_SUCCESS,
|
||||
PRINTING_FAILED,
|
||||
INVALID_PRINTER_SETTINGS,
|
||||
INVALID_MEMORY_HANDLE,
|
||||
METAFILE_MAP_ERROR,
|
||||
METAFILE_INVALID_HEADER,
|
||||
METAFILE_GET_DATA_ERROR,
|
||||
SIMULTANEOUS_PRINT_ACTIVE,
|
||||
PAGE_RANGE_SYNTAX_ERROR,
|
||||
PAGE_RANGE_INVALID_RANGE,
|
||||
PAGE_COUNT_EXCEEDED,
|
||||
kPrintSuccess,
|
||||
kPrintFailure,
|
||||
kInvalidPrinterSettings,
|
||||
kInvalidMemoryHandle,
|
||||
kMetafileMapError,
|
||||
kMetafileInvalidHeader,
|
||||
kMetafileGetDataError,
|
||||
kSimultaneousPrintActive,
|
||||
kPageRangeSyntaxError,
|
||||
kPageRangeInvalidRange,
|
||||
kPageCountExceeded,
|
||||
};
|
||||
|
||||
using PrintToPDFCallback =
|
||||
|
@ -91,8 +91,8 @@ class PrintViewManagerElectron
|
|||
CheckForCancelCallback callback) override;
|
||||
#endif
|
||||
|
||||
void FailJob(PrintResult result);
|
||||
void Reset();
|
||||
void ReleaseJob(PrintResult result);
|
||||
|
||||
raw_ptr<content::RenderFrameHost> printing_rfh_ = nullptr;
|
||||
PrintToPDFCallback callback_;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "base/bind.h"
|
||||
#include "base/callback.h"
|
||||
#include "services/network/public/cpp/session_cookie_delete_predicate.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
|
@ -37,9 +38,4 @@ bool SpecialStoragePolicy::HasSessionOnlyOrigins() {
|
|||
return false;
|
||||
}
|
||||
|
||||
network::DeleteCookiePredicate
|
||||
SpecialStoragePolicy::CreateDeleteCookieOnExitPredicate() {
|
||||
return network::DeleteCookiePredicate();
|
||||
}
|
||||
|
||||
} // namespace electron
|
||||
|
|
|
@ -20,7 +20,6 @@ class SpecialStoragePolicy : public storage::SpecialStoragePolicy {
|
|||
bool HasIsolatedStorage(const GURL& origin) override;
|
||||
bool IsStorageSessionOnly(const GURL& origin) override;
|
||||
bool HasSessionOnlyOrigins() override;
|
||||
network::DeleteCookiePredicate CreateDeleteCookieOnExitPredicate() override;
|
||||
|
||||
protected:
|
||||
~SpecialStoragePolicy() override;
|
||||
|
|
|
@ -71,8 +71,8 @@ bool StringToAccelerator(const std::string& shortcut,
|
|||
|
||||
void GenerateAcceleratorTable(AcceleratorTable* table,
|
||||
electron::ElectronMenuModel* model) {
|
||||
int count = model->GetItemCount();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
size_t count = model->GetItemCount();
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
electron::ElectronMenuModel::ItemType type = model->GetTypeAt(i);
|
||||
if (type == electron::ElectronMenuModel::TYPE_SUBMENU) {
|
||||
auto* submodel = model->GetSubmenuModelAt(i);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
namespace accelerator_util {
|
||||
|
||||
typedef struct {
|
||||
int position;
|
||||
size_t position;
|
||||
electron::ElectronMenuModel* model;
|
||||
} MenuItem;
|
||||
typedef std::map<ui::Accelerator, MenuItem> AcceleratorTable;
|
||||
|
|
|
@ -27,42 +27,43 @@ ElectronMenuModel::ElectronMenuModel(Delegate* delegate)
|
|||
|
||||
ElectronMenuModel::~ElectronMenuModel() = default;
|
||||
|
||||
void ElectronMenuModel::SetToolTip(int index, const std::u16string& toolTip) {
|
||||
void ElectronMenuModel::SetToolTip(size_t index,
|
||||
const std::u16string& toolTip) {
|
||||
int command_id = GetCommandIdAt(index);
|
||||
toolTips_[command_id] = toolTip;
|
||||
}
|
||||
|
||||
std::u16string ElectronMenuModel::GetToolTipAt(int index) {
|
||||
std::u16string ElectronMenuModel::GetToolTipAt(size_t index) {
|
||||
const int command_id = GetCommandIdAt(index);
|
||||
const auto iter = toolTips_.find(command_id);
|
||||
return iter == std::end(toolTips_) ? std::u16string() : iter->second;
|
||||
}
|
||||
|
||||
void ElectronMenuModel::SetRole(int index, const std::u16string& role) {
|
||||
void ElectronMenuModel::SetRole(size_t index, const std::u16string& role) {
|
||||
int command_id = GetCommandIdAt(index);
|
||||
roles_[command_id] = role;
|
||||
}
|
||||
|
||||
std::u16string ElectronMenuModel::GetRoleAt(int index) {
|
||||
std::u16string ElectronMenuModel::GetRoleAt(size_t index) {
|
||||
const int command_id = GetCommandIdAt(index);
|
||||
const auto iter = roles_.find(command_id);
|
||||
return iter == std::end(roles_) ? std::u16string() : iter->second;
|
||||
}
|
||||
|
||||
void ElectronMenuModel::SetSecondaryLabel(int index,
|
||||
void ElectronMenuModel::SetSecondaryLabel(size_t index,
|
||||
const std::u16string& sublabel) {
|
||||
int command_id = GetCommandIdAt(index);
|
||||
sublabels_[command_id] = sublabel;
|
||||
}
|
||||
|
||||
std::u16string ElectronMenuModel::GetSecondaryLabelAt(int index) const {
|
||||
std::u16string ElectronMenuModel::GetSecondaryLabelAt(size_t index) const {
|
||||
int command_id = GetCommandIdAt(index);
|
||||
const auto iter = sublabels_.find(command_id);
|
||||
return iter == std::end(sublabels_) ? std::u16string() : iter->second;
|
||||
}
|
||||
|
||||
bool ElectronMenuModel::GetAcceleratorAtWithParams(
|
||||
int index,
|
||||
size_t index,
|
||||
bool use_default_accelerator,
|
||||
ui::Accelerator* accelerator) const {
|
||||
if (delegate_) {
|
||||
|
@ -72,7 +73,7 @@ bool ElectronMenuModel::GetAcceleratorAtWithParams(
|
|||
return false;
|
||||
}
|
||||
|
||||
bool ElectronMenuModel::ShouldRegisterAcceleratorAt(int index) const {
|
||||
bool ElectronMenuModel::ShouldRegisterAcceleratorAt(size_t index) const {
|
||||
if (delegate_) {
|
||||
return delegate_->ShouldRegisterAcceleratorForCommandId(
|
||||
GetCommandIdAt(index));
|
||||
|
@ -80,7 +81,7 @@ bool ElectronMenuModel::ShouldRegisterAcceleratorAt(int index) const {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ElectronMenuModel::WorksWhenHiddenAt(int index) const {
|
||||
bool ElectronMenuModel::WorksWhenHiddenAt(size_t index) const {
|
||||
if (delegate_) {
|
||||
return delegate_->ShouldCommandIdWorkWhenHidden(GetCommandIdAt(index));
|
||||
}
|
||||
|
@ -88,7 +89,8 @@ bool ElectronMenuModel::WorksWhenHiddenAt(int index) const {
|
|||
}
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
bool ElectronMenuModel::GetSharingItemAt(int index, SharingItem* item) const {
|
||||
bool ElectronMenuModel::GetSharingItemAt(size_t index,
|
||||
SharingItem* item) const {
|
||||
if (delegate_)
|
||||
return delegate_->GetSharingItemForCommandId(GetCommandIdAt(index), item);
|
||||
return false;
|
||||
|
@ -118,7 +120,7 @@ void ElectronMenuModel::MenuWillShow() {
|
|||
}
|
||||
}
|
||||
|
||||
ElectronMenuModel* ElectronMenuModel::GetSubmenuModelAt(int index) {
|
||||
ElectronMenuModel* ElectronMenuModel::GetSubmenuModelAt(size_t index) {
|
||||
return static_cast<ElectronMenuModel*>(
|
||||
ui::SimpleMenuModel::GetSubmenuModelAt(index));
|
||||
}
|
||||
|
|
|
@ -81,20 +81,20 @@ class ElectronMenuModel : public ui::SimpleMenuModel {
|
|||
void AddObserver(Observer* obs) { observers_.AddObserver(obs); }
|
||||
void RemoveObserver(Observer* obs) { observers_.RemoveObserver(obs); }
|
||||
|
||||
void SetToolTip(int index, const std::u16string& toolTip);
|
||||
std::u16string GetToolTipAt(int index);
|
||||
void SetRole(int index, const std::u16string& role);
|
||||
std::u16string GetRoleAt(int index);
|
||||
void SetSecondaryLabel(int index, const std::u16string& sublabel);
|
||||
std::u16string GetSecondaryLabelAt(int index) const override;
|
||||
bool GetAcceleratorAtWithParams(int index,
|
||||
void SetToolTip(size_t index, const std::u16string& toolTip);
|
||||
std::u16string GetToolTipAt(size_t index);
|
||||
void SetRole(size_t index, const std::u16string& role);
|
||||
std::u16string GetRoleAt(size_t index);
|
||||
void SetSecondaryLabel(size_t index, const std::u16string& sublabel);
|
||||
std::u16string GetSecondaryLabelAt(size_t index) const override;
|
||||
bool GetAcceleratorAtWithParams(size_t index,
|
||||
bool use_default_accelerator,
|
||||
ui::Accelerator* accelerator) const;
|
||||
bool ShouldRegisterAcceleratorAt(int index) const;
|
||||
bool WorksWhenHiddenAt(int index) const;
|
||||
bool ShouldRegisterAcceleratorAt(size_t index) const;
|
||||
bool WorksWhenHiddenAt(size_t index) const;
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
// Return the SharingItem of menu item.
|
||||
bool GetSharingItemAt(int index, SharingItem* item) const;
|
||||
bool GetSharingItemAt(size_t index, SharingItem* item) const;
|
||||
// Set/Get the SharingItem of this menu.
|
||||
void SetSharingItem(SharingItem item);
|
||||
const absl::optional<SharingItem>& GetSharingItem() const;
|
||||
|
@ -109,7 +109,7 @@ class ElectronMenuModel : public ui::SimpleMenuModel {
|
|||
}
|
||||
|
||||
using SimpleMenuModel::GetSubmenuModelAt;
|
||||
ElectronMenuModel* GetSubmenuModelAt(int index);
|
||||
ElectronMenuModel* GetSubmenuModelAt(size_t index);
|
||||
|
||||
private:
|
||||
Delegate* delegate_; // weak ref.
|
||||
|
|
|
@ -150,7 +150,7 @@ void ExecuteCommand(ui::MenuModel* model, int id) {
|
|||
|
||||
if (event && event->type == GDK_BUTTON_RELEASE)
|
||||
event_flags = EventFlagsFromGdkState(event->button.state);
|
||||
model->ActivatedAt(id, event_flags);
|
||||
model->ActivatedAt(static_cast<int>(id), event_flags);
|
||||
|
||||
if (event)
|
||||
gdk_event_free(event);
|
||||
|
@ -163,7 +163,7 @@ void BuildSubmenuFromModel(ui::MenuModel* model,
|
|||
void* this_ptr) {
|
||||
std::map<int, GtkWidget*> radio_groups;
|
||||
GtkWidget* menu_item = nullptr;
|
||||
for (int i = 0; i < model->GetItemCount(); ++i) {
|
||||
for (size_t i = 0; i < model->GetItemCount(); ++i) {
|
||||
std::string label = ui::ConvertAcceleratorsFromWindowsStyle(
|
||||
base::UTF16ToUTF8(model->GetLabelAt(i)));
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ ElectronMenuModel* ModelForMenuItem(DbusmenuMenuitem* item) {
|
|||
g_object_get_data(G_OBJECT(item), "model"));
|
||||
}
|
||||
|
||||
bool GetMenuItemID(DbusmenuMenuitem* item, int* id) {
|
||||
bool GetMenuItemID(DbusmenuMenuitem* item, size_t* id) {
|
||||
gpointer id_ptr = g_object_get_data(G_OBJECT(item), "menu-id");
|
||||
if (id_ptr != nullptr) {
|
||||
*id = GPOINTER_TO_INT(id_ptr) - 1;
|
||||
|
@ -162,7 +162,7 @@ void SetMenuItemID(DbusmenuMenuitem* item, int id) {
|
|||
|
||||
std::string GetMenuModelStatus(ElectronMenuModel* model) {
|
||||
std::string ret;
|
||||
for (int i = 0; i < model->GetItemCount(); ++i) {
|
||||
for (size_t i = 0; i < model->GetItemCount(); ++i) {
|
||||
int status = model->GetTypeAt(i) | (model->IsVisibleAt(i) << 3) |
|
||||
(model->IsEnabledAt(i) << 4) |
|
||||
(model->IsItemCheckedAt(i) << 5);
|
||||
|
@ -231,7 +231,7 @@ void GlobalMenuBarX11::OnWindowUnmapped() {
|
|||
|
||||
void GlobalMenuBarX11::BuildMenuFromModel(ElectronMenuModel* model,
|
||||
DbusmenuMenuitem* parent) {
|
||||
for (int i = 0; i < model->GetItemCount(); ++i) {
|
||||
for (size_t i = 0; i < model->GetItemCount(); ++i) {
|
||||
DbusmenuMenuitem* item = menuitem_new();
|
||||
menuitem_property_set_bool(item, kPropertyVisible, model->IsVisibleAt(i));
|
||||
|
||||
|
@ -309,14 +309,14 @@ void GlobalMenuBarX11::RegisterAccelerator(DbusmenuMenuitem* item,
|
|||
|
||||
void GlobalMenuBarX11::OnItemActivated(DbusmenuMenuitem* item,
|
||||
unsigned int timestamp) {
|
||||
int id;
|
||||
size_t id;
|
||||
ElectronMenuModel* model = ModelForMenuItem(item);
|
||||
if (model && GetMenuItemID(item, &id))
|
||||
model->ActivatedAt(id, 0);
|
||||
}
|
||||
|
||||
void GlobalMenuBarX11::OnSubMenuShow(DbusmenuMenuitem* item) {
|
||||
int id;
|
||||
size_t id;
|
||||
ElectronMenuModel* model = ModelForMenuItem(item);
|
||||
if (!model || !GetMenuItemID(item, &id))
|
||||
return;
|
||||
|
|
|
@ -81,7 +81,7 @@ void MenuBar::ActivateAccelerator(char16_t key) {
|
|||
static_cast<SubmenuButton*>(child)->Activate(nullptr);
|
||||
}
|
||||
|
||||
int MenuBar::GetItemCount() const {
|
||||
size_t MenuBar::GetItemCount() const {
|
||||
return menu_model_ ? menu_model_->GetItemCount() : 0;
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ bool MenuBar::GetMenuButtonFromScreenPoint(const gfx::Point& screenPoint,
|
|||
return false;
|
||||
|
||||
auto children = GetChildrenInZOrder();
|
||||
for (int i = 0, n = children.size(); i < n; ++i) {
|
||||
for (size_t i = 0, n = children.size(); i < n; ++i) {
|
||||
if (children[i]->GetBoundsInScreen().Contains(screenPoint) &&
|
||||
(menu_model_->GetTypeAt(i) == ElectronMenuModel::TYPE_SUBMENU)) {
|
||||
*menu_model = menu_model_->GetSubmenuModelAt(i);
|
||||
|
@ -174,7 +174,7 @@ const char* MenuBar::GetClassName() const {
|
|||
return kViewClassName;
|
||||
}
|
||||
|
||||
void MenuBar::ButtonPressed(int id, const ui::Event& event) {
|
||||
void MenuBar::ButtonPressed(size_t id, const ui::Event& event) {
|
||||
// Hide the accelerator when a submenu is activated.
|
||||
SetAcceleratorVisibility(pane_has_focus());
|
||||
|
||||
|
@ -193,7 +193,8 @@ void MenuBar::ButtonPressed(int id, const ui::Event& event) {
|
|||
SubmenuButton* source = nullptr;
|
||||
for (auto* child : children()) {
|
||||
auto* button = static_cast<SubmenuButton*>(child);
|
||||
if (button->GetID() == id) {
|
||||
int button_id = button->GetID();
|
||||
if (button_id >= 0 && static_cast<size_t>(button_id) == id) {
|
||||
source = button;
|
||||
break;
|
||||
}
|
||||
|
@ -222,7 +223,7 @@ void MenuBar::RefreshColorCache(const ui::NativeTheme* theme) {
|
|||
|
||||
void MenuBar::RebuildChildren() {
|
||||
RemoveAllChildViews();
|
||||
for (int i = 0, n = GetItemCount(); i < n; ++i) {
|
||||
for (size_t i = 0, n = GetItemCount(); i < n; ++i) {
|
||||
auto* button = new SubmenuButton(
|
||||
base::BindRepeating(&MenuBar::ButtonPressed, base::Unretained(this), i),
|
||||
menu_model_->GetLabelAt(i), background_color_);
|
||||
|
|
|
@ -43,7 +43,7 @@ class MenuBar : public views::AccessiblePaneView,
|
|||
void ActivateAccelerator(char16_t key);
|
||||
|
||||
// Returns there are how many items in the root menu.
|
||||
int GetItemCount() const;
|
||||
size_t GetItemCount() const;
|
||||
|
||||
// Get the menu under specified screen point.
|
||||
bool GetMenuButtonFromScreenPoint(const gfx::Point& point,
|
||||
|
@ -71,7 +71,7 @@ class MenuBar : public views::AccessiblePaneView,
|
|||
const char* GetClassName() const override;
|
||||
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
|
||||
|
||||
void ButtonPressed(int id, const ui::Event& event);
|
||||
void ButtonPressed(size_t id, const ui::Event& event);
|
||||
|
||||
void RebuildChildren();
|
||||
void UpdateViewColors();
|
||||
|
|
|
@ -14,7 +14,7 @@ MenuModelAdapter::~MenuModelAdapter() = default;
|
|||
bool MenuModelAdapter::GetAccelerator(int id,
|
||||
ui::Accelerator* accelerator) const {
|
||||
ui::MenuModel* model = menu_model_;
|
||||
int index = 0;
|
||||
size_t index = 0;
|
||||
if (ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index)) {
|
||||
return static_cast<ElectronMenuModel*>(model)->GetAcceleratorAtWithParams(
|
||||
index, true, accelerator);
|
||||
|
|
|
@ -33,7 +33,8 @@ void ExposeElectronRendererInterfacesToBrowser(
|
|||
electron::RendererClientBase* client,
|
||||
mojo::BinderMap* binders) {
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
binders->Add(base::BindRepeating(&BindSpellChecker, client),
|
||||
base::SequencedTaskRunnerHandle::Get());
|
||||
binders->Add<spellcheck::mojom::SpellChecker>(
|
||||
base::BindRepeating(&BindSpellChecker, client),
|
||||
base::SequencedTaskRunnerHandle::Get());
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/memory/ref_counted_memory.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/trace_event/trace_event.h"
|
||||
#include "content/public/renderer/render_frame.h"
|
||||
|
|
|
@ -94,7 +94,7 @@ void ElectronContentUtilityClient::ExposeInterfacesToBrowser(
|
|||
// interfaces to the BinderMap.
|
||||
if (!utility_process_running_elevated_) {
|
||||
#if BUILDFLAG(ENABLE_PRINTING) && BUILDFLAG(IS_WIN)
|
||||
binders->Add(
|
||||
binders->Add<printing::mojom::PdfToEmfConverterFactory>(
|
||||
base::BindRepeating(printing::PdfToEmfConverterFactory::Create),
|
||||
base::ThreadTaskRunnerHandle::Get());
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue