mirror of
https://github.com/electron/electron.git
synced 2026-02-26 03:01:17 -05:00
Compare commits
11 Commits
v34.0.0-be
...
v34.0.0-be
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7284f0262 | ||
|
|
b33ea0d72d | ||
|
|
c63613f290 | ||
|
|
dc0c6c6f3f | ||
|
|
a92b3944a1 | ||
|
|
5ca3f950e9 | ||
|
|
99f2bab4a4 | ||
|
|
c0d1c3481a | ||
|
|
5a0e1ccf73 | ||
|
|
d8a7c57506 | ||
|
|
a30cf5b551 |
@@ -37,7 +37,10 @@ Process: [Main](../glossary.md#main-process)<br />
|
||||
to load unsigned libraries. Unless you specifically need this capability, it is best to leave this disabled.
|
||||
Default is `false`.
|
||||
* `respondToAuthRequestsFromMainProcess` boolean (optional) - With this flag, all HTTP 401 and 407 network
|
||||
requests created via the [net module](net.md) will allow responding to them via the [`app#login`](app.md#event-login) event in the main process instead of the default [`login`](client-request.md#event-login) event on the [`ClientRequest`](client-request.md) object.
|
||||
requests created via the [net module](net.md) will allow responding to them via the
|
||||
[`app#login`](app.md#event-login) event in the main process instead of the default
|
||||
[`login`](client-request.md#event-login) event on the [`ClientRequest`](client-request.md) object. Default is
|
||||
`false`.
|
||||
|
||||
Returns [`UtilityProcess`](utility-process.md#class-utilityprocess)
|
||||
|
||||
|
||||
@@ -111,14 +111,14 @@ The nonstandard `path` property of the Web `File` object was added in an early v
|
||||
```js
|
||||
// Before (renderer)
|
||||
|
||||
const file = document.querySelector('input[type=file]')
|
||||
const file = document.querySelector('input[type=file]').files[0]
|
||||
alert(`Uploaded file path was: ${file.path}`)
|
||||
```
|
||||
|
||||
```js
|
||||
// After (renderer)
|
||||
|
||||
const file = document.querySelector('input[type=file]')
|
||||
const file = document.querySelector('input[type=file]').files[0]
|
||||
electron.showFilePath(file)
|
||||
|
||||
// (preload)
|
||||
|
||||
@@ -9,7 +9,7 @@ check out our [Electron Versioning](./electron-versioning.md) doc.
|
||||
|
||||
| Electron | Alpha | Beta | Stable | EOL | Chrome | Node | Supported |
|
||||
| ------- | ----- | ------- | ------ | ------ | ---- | ---- | ---- |
|
||||
| 34.0.0 | 2024-Oct-17 | 2024-Nov-13 | 2024-Jan-14 | 2025-Jun-24 | M132 | TBD | ✅ |
|
||||
| 34.0.0 | 2024-Oct-17 | 2024-Nov-13 | 2025-Jan-14 | 2025-Jun-24 | M132 | TBD | ✅ |
|
||||
| 33.0.0 | 2024-Aug-22 | 2024-Sep-18 | 2024-Oct-15 | 2025-Apr-29 | M130 | v20.18 | ✅ |
|
||||
| 32.0.0 | 2024-Jun-14 | 2024-Jul-24 | 2024-Aug-20 | 2025-Mar-04 | M128 | v20.16 | ✅ |
|
||||
| 31.0.0 | 2024-Apr-18 | 2024-May-15 | 2024-Jun-11 | 2025-Jan-14 | M126 | v20.14 | ✅ |
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/containers/extend.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "content/public/common/content_constants.h"
|
||||
@@ -98,21 +99,6 @@ bool IsWidevineAvailable(
|
||||
}
|
||||
#endif // BUILDFLAG(ENABLE_WIDEVINE)
|
||||
|
||||
void AppendDelimitedSwitchToVector(const std::string_view cmd_switch,
|
||||
std::vector<std::string>* append_me) {
|
||||
auto* command_line = base::CommandLine::ForCurrentProcess();
|
||||
auto switch_value = command_line->GetSwitchValueASCII(cmd_switch);
|
||||
if (!switch_value.empty()) {
|
||||
constexpr std::string_view delimiter{",", 1};
|
||||
auto tokens =
|
||||
base::SplitString(switch_value, delimiter, base::TRIM_WHITESPACE,
|
||||
base::SPLIT_WANT_NONEMPTY);
|
||||
append_me->reserve(append_me->size() + tokens.size());
|
||||
std::move(std::begin(tokens), std::end(tokens),
|
||||
std::back_inserter(*append_me));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
ElectronContentClient::ElectronContentClient() = default;
|
||||
@@ -149,16 +135,19 @@ void ElectronContentClient::AddAdditionalSchemes(Schemes* schemes) {
|
||||
//
|
||||
// We use this for registration to network utility process
|
||||
if (IsUtilityProcess()) {
|
||||
AppendDelimitedSwitchToVector(switches::kServiceWorkerSchemes,
|
||||
&schemes->service_worker_schemes);
|
||||
AppendDelimitedSwitchToVector(switches::kStandardSchemes,
|
||||
&schemes->standard_schemes);
|
||||
AppendDelimitedSwitchToVector(switches::kSecureSchemes,
|
||||
&schemes->secure_schemes);
|
||||
AppendDelimitedSwitchToVector(switches::kBypassCSPSchemes,
|
||||
&schemes->csp_bypassing_schemes);
|
||||
AppendDelimitedSwitchToVector(switches::kCORSSchemes,
|
||||
&schemes->cors_enabled_schemes);
|
||||
const auto& cmd = *base::CommandLine::ForCurrentProcess();
|
||||
auto append_cli_schemes = [&cmd](auto& appendme, const auto key) {
|
||||
base::Extend(appendme, base::SplitString(cmd.GetSwitchValueASCII(key),
|
||||
",", base::TRIM_WHITESPACE,
|
||||
base::SPLIT_WANT_NONEMPTY));
|
||||
};
|
||||
|
||||
using namespace switches;
|
||||
append_cli_schemes(schemes->cors_enabled_schemes, kCORSSchemes);
|
||||
append_cli_schemes(schemes->csp_bypassing_schemes, kBypassCSPSchemes);
|
||||
append_cli_schemes(schemes->secure_schemes, kSecureSchemes);
|
||||
append_cli_schemes(schemes->service_worker_schemes, kServiceWorkerSchemes);
|
||||
append_cli_schemes(schemes->standard_schemes, kStandardSchemes);
|
||||
}
|
||||
|
||||
if (electron::fuses::IsGrantFileProtocolExtraPrivilegesEnabled()) {
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace electron {
|
||||
|
||||
namespace {
|
||||
|
||||
const char kRelauncherProcess[] = "relauncher";
|
||||
constexpr std::string_view kRelauncherProcess = "relauncher";
|
||||
|
||||
constexpr std::string_view kElectronDisableSandbox{"ELECTRON_DISABLE_SANDBOX"};
|
||||
constexpr std::string_view kElectronEnableStackDumping{
|
||||
|
||||
@@ -776,7 +776,7 @@ base::OnceClosure App::SelectClientCertificate(
|
||||
std::move((*shared_identities)[0]),
|
||||
base::BindRepeating(&GotPrivateKey, shared_delegate, std::move(cert)));
|
||||
}
|
||||
return base::OnceClosure();
|
||||
return {};
|
||||
}
|
||||
|
||||
void App::OnGpuInfoUpdate() {
|
||||
@@ -944,7 +944,7 @@ std::string App::GetSystemLocale(gin_helper::ErrorThrower thrower) const {
|
||||
thrower.ThrowError(
|
||||
"app.getSystemLocale() can only be called "
|
||||
"after app is ready");
|
||||
return std::string();
|
||||
return {};
|
||||
}
|
||||
return static_cast<BrowserProcessImpl*>(g_browser_process)->GetSystemLocale();
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ void FilterCookieWithStatuses(
|
||||
// Parse dictionary property to CanonicalCookie time correctly.
|
||||
base::Time ParseTimeProperty(const std::optional<double>& value) {
|
||||
if (!value) // empty time means ignoring the parameter
|
||||
return base::Time();
|
||||
return {};
|
||||
if (*value == 0) // FromSecondsSinceUnixEpoch would convert 0 to empty Time
|
||||
return base::Time::UnixEpoch();
|
||||
return base::Time::FromSecondsSinceUnixEpoch(*value);
|
||||
|
||||
@@ -99,7 +99,7 @@ std::string ReadClientId() {
|
||||
if (GetClientIdPath(&client_id_path) &&
|
||||
(!base::ReadFileToStringWithMaxSize(client_id_path, &client_id, 36) ||
|
||||
client_id.size() != 36))
|
||||
return std::string();
|
||||
return {};
|
||||
return client_id;
|
||||
}
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ gin::Handle<DataPipeHolder> DataPipeHolder::From(v8::Isolate* isolate,
|
||||
if (gin::ConvertFromV8(isolate, object.ToLocalChecked(), &handle))
|
||||
return handle;
|
||||
}
|
||||
return gin::Handle<DataPipeHolder>();
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace electron::api
|
||||
|
||||
@@ -209,7 +209,7 @@ const GURL& DownloadItem::GetURL() const {
|
||||
|
||||
v8::Local<v8::Value> DownloadItem::GetURLChain() const {
|
||||
if (!CheckAlive())
|
||||
return v8::Local<v8::Value>();
|
||||
return {};
|
||||
return gin::ConvertToV8(isolate_, download_item_->GetUrlChain());
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,8 @@ Menu::~Menu() {
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
bool InvokeBoolMethod(const Menu* menu,
|
||||
const char* method,
|
||||
int command_id,
|
||||
@@ -84,6 +86,8 @@ bool InvokeBoolMethod(const Menu* menu,
|
||||
return gin::ConvertFromV8(isolate, val, &ret) ? ret : default_value;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool Menu::IsCommandIdChecked(int command_id) const {
|
||||
return InvokeBoolMethod(this, "_isCommandIdChecked", command_id);
|
||||
}
|
||||
|
||||
@@ -63,8 +63,7 @@ scoped_refptr<base::SequencedTaskRunner> CreateFileTaskRunner() {
|
||||
}
|
||||
|
||||
base::File OpenFileForWriting(base::FilePath path) {
|
||||
return base::File(path,
|
||||
base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE);
|
||||
return {path, base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE};
|
||||
}
|
||||
|
||||
void ResolvePromiseWithNetError(gin_helper::Promise<void> promise,
|
||||
@@ -93,7 +92,7 @@ v8::Local<v8::Promise> NetLog::StartLogging(base::FilePath log_path,
|
||||
gin::Arguments* args) {
|
||||
if (log_path.empty()) {
|
||||
args->ThrowTypeError("The first parameter must be a valid string");
|
||||
return v8::Local<v8::Promise>();
|
||||
return {};
|
||||
}
|
||||
|
||||
net::NetLogCaptureMode capture_mode = net::NetLogCaptureMode::kDefault;
|
||||
@@ -106,7 +105,7 @@ v8::Local<v8::Promise> NetLog::StartLogging(base::FilePath log_path,
|
||||
if (!gin::ConvertFromV8(args->isolate(), capture_mode_v8,
|
||||
&capture_mode)) {
|
||||
args->ThrowTypeError("Invalid value for captureMode");
|
||||
return v8::Local<v8::Promise>();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
v8::Local<v8::Value> max_file_size_v8;
|
||||
@@ -114,14 +113,14 @@ v8::Local<v8::Promise> NetLog::StartLogging(base::FilePath log_path,
|
||||
if (!gin::ConvertFromV8(args->isolate(), max_file_size_v8,
|
||||
&max_file_size)) {
|
||||
args->ThrowTypeError("Invalid value for maxFileSize");
|
||||
return v8::Local<v8::Promise>();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (net_log_exporter_) {
|
||||
args->ThrowTypeError("There is already a net log running");
|
||||
return v8::Local<v8::Promise>();
|
||||
return {};
|
||||
}
|
||||
|
||||
pending_start_promise_ =
|
||||
|
||||
@@ -81,7 +81,7 @@ gin::Handle<Notification> Notification::New(gin_helper::ErrorThrower thrower,
|
||||
gin::Arguments* args) {
|
||||
if (!Browser::Get()->is_ready()) {
|
||||
thrower.ThrowError("Cannot create Notification before app is ready");
|
||||
return gin::Handle<Notification>();
|
||||
return {};
|
||||
}
|
||||
return gin::CreateHandle(thrower.isolate(), new Notification(args));
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ gin::Handle<Protocol> Protocol::Create(
|
||||
// static
|
||||
gin::Handle<Protocol> Protocol::New(gin_helper::ErrorThrower thrower) {
|
||||
thrower.ThrowError("Protocol cannot be created from JS");
|
||||
return gin::Handle<Protocol>();
|
||||
return {};
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
@@ -53,13 +53,13 @@ v8::Local<v8::Value> EncryptString(v8::Isolate* isolate,
|
||||
if (!electron::Browser::Get()->is_ready()) {
|
||||
gin_helper::ErrorThrower(isolate).ThrowError(
|
||||
"safeStorage cannot be used before app is ready");
|
||||
return v8::Local<v8::Value>();
|
||||
return {};
|
||||
}
|
||||
gin_helper::ErrorThrower(isolate).ThrowError(
|
||||
"Error while encrypting the text provided to "
|
||||
"safeStorage.encryptString. "
|
||||
"Encryption is not available.");
|
||||
return v8::Local<v8::Value>();
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string ciphertext;
|
||||
@@ -69,7 +69,7 @@ v8::Local<v8::Value> EncryptString(v8::Isolate* isolate,
|
||||
gin_helper::ErrorThrower(isolate).ThrowError(
|
||||
"Error while encrypting the text provided to "
|
||||
"safeStorage.encryptString.");
|
||||
return v8::Local<v8::Value>();
|
||||
return {};
|
||||
}
|
||||
|
||||
return node::Buffer::Copy(isolate, ciphertext.c_str(), ciphertext.size())
|
||||
|
||||
@@ -82,7 +82,7 @@ gfx::Point Screen::GetCursorScreenPoint(v8::Isolate* isolate) {
|
||||
thrower.ThrowError(
|
||||
"screen.getCursorScreenPoint() cannot be called before a window has "
|
||||
"been created.");
|
||||
return gfx::Point();
|
||||
return {};
|
||||
}
|
||||
#endif
|
||||
return screen_->GetCursorScreenPoint();
|
||||
|
||||
@@ -132,7 +132,7 @@ v8::Local<v8::Value> ServiceWorkerContext::GetWorkerInfoFromID(
|
||||
auto iter = info_map.find(version_id);
|
||||
if (iter == info_map.end()) {
|
||||
thrower.ThrowError("Could not find service worker with that version_id");
|
||||
return v8::Local<v8::Value>();
|
||||
return {};
|
||||
}
|
||||
return ServiceWorkerRunningInfoToDict(thrower.isolate(),
|
||||
std::move(iter->second));
|
||||
|
||||
@@ -1583,7 +1583,7 @@ std::optional<gin::Handle<Session>> Session::FromPath(
|
||||
gin::Handle<Session> Session::New() {
|
||||
gin_helper::ErrorThrower(JavascriptEnvironment::GetIsolate())
|
||||
.ThrowError("Session objects cannot be created with 'new'");
|
||||
return gin::Handle<Session>();
|
||||
return {};
|
||||
}
|
||||
|
||||
void Session::FillObjectTemplate(v8::Isolate* isolate,
|
||||
|
||||
@@ -154,7 +154,7 @@ std::string SystemPreferences::GetMediaAccessStatus(
|
||||
DeviceAccessStatus::DeviceAccessStatus_Allowed);
|
||||
} else {
|
||||
thrower.ThrowError("Invalid media type");
|
||||
return std::string();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,13 +67,13 @@ gin::Handle<Tray> Tray::New(gin_helper::ErrorThrower thrower,
|
||||
gin::Arguments* args) {
|
||||
if (!Browser::Get()->is_ready()) {
|
||||
thrower.ThrowError("Cannot create Tray before app is ready");
|
||||
return gin::Handle<Tray>();
|
||||
return {};
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
if (!guid.has_value() && args->Length() > 1) {
|
||||
thrower.ThrowError("Invalid GUID format");
|
||||
return gin::Handle<Tray>();
|
||||
return {};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -85,7 +85,7 @@ gin::Handle<Tray> Tray::New(gin_helper::ErrorThrower thrower,
|
||||
if (try_catch.HasCaught()) {
|
||||
delete tray;
|
||||
try_catch.ReThrow();
|
||||
return gin::Handle<Tray>();
|
||||
return {};
|
||||
}
|
||||
|
||||
auto handle = gin::CreateHandle(args->isolate(), tray);
|
||||
@@ -264,7 +264,7 @@ void Tray::SetTitle(const std::string& title,
|
||||
|
||||
std::string Tray::GetTitle() {
|
||||
if (!CheckAlive())
|
||||
return std::string();
|
||||
return {};
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
return tray_icon_->GetTitle();
|
||||
#else
|
||||
@@ -388,7 +388,7 @@ void Tray::SetContextMenu(gin_helper::ErrorThrower thrower,
|
||||
|
||||
gfx::Rect Tray::GetBounds() {
|
||||
if (!CheckAlive())
|
||||
return gfx::Rect();
|
||||
return {};
|
||||
return tray_icon_->GetBounds();
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
|
||||
namespace electron {
|
||||
|
||||
namespace {
|
||||
|
||||
base::IDMap<api::UtilityProcessWrapper*, base::ProcessId>&
|
||||
GetAllUtilityProcessWrappers() {
|
||||
static base::NoDestructor<
|
||||
@@ -52,6 +54,8 @@ GetAllUtilityProcessWrappers() {
|
||||
return *s_all_utility_process_wrappers;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace api {
|
||||
|
||||
gin::WrapperInfo UtilityProcessWrapper::kWrapperInfo = {
|
||||
@@ -411,7 +415,7 @@ gin::Handle<UtilityProcessWrapper> UtilityProcessWrapper::Create(
|
||||
gin_helper::Dictionary dict;
|
||||
if (!args->GetNext(&dict)) {
|
||||
args->ThrowTypeError("Options must be an object.");
|
||||
return gin::Handle<UtilityProcessWrapper>();
|
||||
return {};
|
||||
}
|
||||
|
||||
std::u16string display_name;
|
||||
@@ -425,19 +429,19 @@ gin::Handle<UtilityProcessWrapper> UtilityProcessWrapper::Create(
|
||||
dict.Get("modulePath", ¶ms->script);
|
||||
if (dict.Has("args") && !dict.Get("args", ¶ms->args)) {
|
||||
args->ThrowTypeError("Invalid value for args");
|
||||
return gin::Handle<UtilityProcessWrapper>();
|
||||
return {};
|
||||
}
|
||||
|
||||
gin_helper::Dictionary opts;
|
||||
if (dict.Get("options", &opts)) {
|
||||
if (opts.Has("env") && !opts.Get("env", &env_map)) {
|
||||
args->ThrowTypeError("Invalid value for env");
|
||||
return gin::Handle<UtilityProcessWrapper>();
|
||||
return {};
|
||||
}
|
||||
|
||||
if (opts.Has("execArgv") && !opts.Get("execArgv", ¶ms->exec_args)) {
|
||||
args->ThrowTypeError("Invalid value for execArgv");
|
||||
return gin::Handle<UtilityProcessWrapper>();
|
||||
return {};
|
||||
}
|
||||
|
||||
opts.Get("serviceName", &display_name);
|
||||
|
||||
@@ -282,7 +282,7 @@ void View::SetBounds(const gfx::Rect& bounds) {
|
||||
|
||||
gfx::Rect View::GetBounds() {
|
||||
if (!view_)
|
||||
return gfx::Rect();
|
||||
return {};
|
||||
return view_->bounds();
|
||||
}
|
||||
|
||||
@@ -429,7 +429,7 @@ gin::Handle<View> View::Create(v8::Isolate* isolate) {
|
||||
if (gin::ConvertFromV8(isolate, obj, &view))
|
||||
return view;
|
||||
}
|
||||
return gin::Handle<View>();
|
||||
return {};
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
@@ -1984,7 +1984,7 @@ gin::Handle<gin_helper::internal::Event> WebContents::MakeEventWithSender(
|
||||
ReplyChannel::Create(isolate, std::move(callback))
|
||||
->SendError("WebContents was destroyed");
|
||||
}
|
||||
return gin::Handle<gin_helper::internal::Event>();
|
||||
return {};
|
||||
}
|
||||
gin::Handle<gin_helper::internal::Event> event =
|
||||
gin_helper::internal::Event::New(isolate);
|
||||
@@ -2542,7 +2542,7 @@ std::vector<content::NavigationEntry*> WebContents::GetHistory() const {
|
||||
// If the history is empty, it contains only one entry and that is
|
||||
// "InitialEntry"
|
||||
if (history_length == 1 && controller.GetEntryAtIndex(0)->IsInitialEntry())
|
||||
return std::vector<content::NavigationEntry*>();
|
||||
return {};
|
||||
|
||||
std::vector<content::NavigationEntry*> history;
|
||||
history.reserve(history_length);
|
||||
@@ -2629,7 +2629,7 @@ std::string WebContents::GetMediaSourceID(
|
||||
content::WebContents* request_web_contents) {
|
||||
auto* frame_host = web_contents()->GetPrimaryMainFrame();
|
||||
if (!frame_host)
|
||||
return std::string();
|
||||
return {};
|
||||
|
||||
content::DesktopMediaID media_id(
|
||||
content::DesktopMediaID::TYPE_WEB_CONTENTS,
|
||||
@@ -2639,7 +2639,7 @@ std::string WebContents::GetMediaSourceID(
|
||||
|
||||
auto* request_frame_host = request_web_contents->GetPrimaryMainFrame();
|
||||
if (!request_frame_host)
|
||||
return std::string();
|
||||
return {};
|
||||
|
||||
std::string id =
|
||||
content::DesktopStreamsRegistry::GetInstance()->RegisterStream(
|
||||
@@ -2761,7 +2761,7 @@ bool WebContents::IsDevToolsOpened() {
|
||||
|
||||
std::u16string WebContents::GetDevToolsTitle() {
|
||||
if (type_ == Type::kRemote)
|
||||
return std::u16string();
|
||||
return {};
|
||||
|
||||
DCHECK(inspectable_web_contents_);
|
||||
return inspectable_web_contents_->GetDevToolsTitle();
|
||||
@@ -3641,7 +3641,7 @@ gfx::Size WebContents::GetSizeForNewRenderView(content::WebContents* wc) {
|
||||
}
|
||||
}
|
||||
|
||||
return gfx::Size();
|
||||
return {};
|
||||
}
|
||||
|
||||
void WebContents::SetZoomLevel(double level) {
|
||||
|
||||
@@ -66,7 +66,7 @@ gin::Handle<WebContents> WebContentsView::GetWebContents(v8::Isolate* isolate) {
|
||||
if (api_web_contents_)
|
||||
return gin::CreateHandle(isolate, api_web_contents_.get());
|
||||
else
|
||||
return gin::Handle<WebContents>();
|
||||
return {};
|
||||
}
|
||||
|
||||
void WebContentsView::SetBackgroundColor(std::optional<WrappedSkColor> color) {
|
||||
@@ -152,7 +152,7 @@ gin::Handle<WebContentsView> WebContentsView::Create(
|
||||
if (gin::ConvertFromV8(isolate, web_contents_view_obj, &web_contents_view))
|
||||
return web_contents_view;
|
||||
}
|
||||
return gin::Handle<WebContentsView>();
|
||||
return {};
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
@@ -91,15 +91,16 @@ namespace electron::api {
|
||||
// FrameTreeNodeId -> WebFrameMain*
|
||||
// Using FrameTreeNode allows us to track frame across navigations. This
|
||||
// is most similar to how <iframe> works.
|
||||
typedef std::unordered_map<content::FrameTreeNodeId,
|
||||
WebFrameMain*,
|
||||
content::FrameTreeNodeId::Hasher>
|
||||
FrameTreeNodeIdMap;
|
||||
using FrameTreeNodeIdMap = std::unordered_map<content::FrameTreeNodeId,
|
||||
WebFrameMain*,
|
||||
content::FrameTreeNodeId::Hasher>;
|
||||
|
||||
// Token -> WebFrameMain*
|
||||
// Maps exact RFH to a WebFrameMain instance.
|
||||
typedef std::map<content::GlobalRenderFrameHostToken, WebFrameMain*>
|
||||
FrameTokenMap;
|
||||
using FrameTokenMap =
|
||||
std::map<content::GlobalRenderFrameHostToken, WebFrameMain*>;
|
||||
|
||||
namespace {
|
||||
|
||||
FrameTreeNodeIdMap& GetFrameTreeNodeIdMap() {
|
||||
static base::NoDestructor<FrameTreeNodeIdMap> instance;
|
||||
@@ -110,6 +111,8 @@ FrameTokenMap& GetFrameTokenMap() {
|
||||
return *instance;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
WebFrameMain* WebFrameMain::FromFrameTreeNodeId(
|
||||
content::FrameTreeNodeId frame_tree_node_id) {
|
||||
@@ -345,7 +348,7 @@ content::FrameTreeNodeId WebFrameMain::FrameTreeNodeID() const {
|
||||
|
||||
std::string WebFrameMain::Name() const {
|
||||
if (!CheckRenderFrame())
|
||||
return std::string();
|
||||
return {};
|
||||
return render_frame_->GetFrameName();
|
||||
}
|
||||
|
||||
@@ -377,7 +380,7 @@ GURL WebFrameMain::URL() const {
|
||||
|
||||
std::string WebFrameMain::Origin() const {
|
||||
if (!CheckRenderFrame())
|
||||
return std::string();
|
||||
return {};
|
||||
return render_frame_->GetLastCommittedOrigin().Serialize();
|
||||
}
|
||||
|
||||
@@ -432,14 +435,14 @@ void WebFrameMain::DOMContentLoaded() {
|
||||
|
||||
// static
|
||||
gin::Handle<WebFrameMain> WebFrameMain::New(v8::Isolate* isolate) {
|
||||
return gin::Handle<WebFrameMain>();
|
||||
return {};
|
||||
}
|
||||
|
||||
// static
|
||||
gin::Handle<WebFrameMain> WebFrameMain::From(v8::Isolate* isolate,
|
||||
content::RenderFrameHost* rfh) {
|
||||
if (!rfh)
|
||||
return gin::Handle<WebFrameMain>();
|
||||
return {};
|
||||
|
||||
auto* web_frame = FromRenderFrameHost(rfh);
|
||||
if (web_frame)
|
||||
|
||||
@@ -723,11 +723,11 @@ gin::Handle<WebRequest> WebRequest::From(
|
||||
v8::Isolate* isolate,
|
||||
content::BrowserContext* browser_context) {
|
||||
if (!browser_context)
|
||||
return gin::Handle<WebRequest>();
|
||||
return {};
|
||||
auto* user_data =
|
||||
static_cast<UserData*>(browser_context->GetUserData(kUserDataKey));
|
||||
if (!user_data)
|
||||
return gin::Handle<WebRequest>();
|
||||
return {};
|
||||
return gin::CreateHandle(isolate, user_data->data.get());
|
||||
}
|
||||
|
||||
|
||||
@@ -225,7 +225,7 @@ std::vector<blink::MessagePortChannel> MessagePort::DisentanglePorts(
|
||||
const std::vector<gin::Handle<MessagePort>>& ports,
|
||||
bool* threw_exception) {
|
||||
if (ports.empty())
|
||||
return std::vector<blink::MessagePortChannel>();
|
||||
return {};
|
||||
|
||||
std::unordered_set<MessagePort*> visited;
|
||||
|
||||
@@ -244,7 +244,7 @@ std::vector<blink::MessagePortChannel> MessagePort::DisentanglePorts(
|
||||
gin_helper::ErrorThrower(isolate).ThrowError(
|
||||
"Port at index " + base::NumberToString(i) + " is " + type + ".");
|
||||
*threw_exception = true;
|
||||
return std::vector<blink::MessagePortChannel>();
|
||||
return {};
|
||||
}
|
||||
visited.insert(port);
|
||||
}
|
||||
|
||||
@@ -66,9 +66,9 @@ std::optional<std::string> GetXdgAppOutput(
|
||||
&success_code);
|
||||
|
||||
if (!ran_ok || success_code != EXIT_SUCCESS)
|
||||
return std::optional<std::string>();
|
||||
return {};
|
||||
|
||||
return std::make_optional(reply);
|
||||
return reply;
|
||||
}
|
||||
|
||||
bool SetDefaultWebClient(const std::string& protocol) {
|
||||
|
||||
@@ -97,7 +97,7 @@ bool IsValidCustomProtocol(const std::wstring& scheme) {
|
||||
std::wstring GetAppInfoHelperForProtocol(ASSOCSTR assoc_str, const GURL& url) {
|
||||
const std::wstring url_scheme = base::ASCIIToWide(url.scheme_piece());
|
||||
if (!IsValidCustomProtocol(url_scheme))
|
||||
return std::wstring();
|
||||
return {};
|
||||
|
||||
wchar_t out_buffer[1024];
|
||||
DWORD buffer_size = std::size(out_buffer);
|
||||
@@ -106,7 +106,7 @@ std::wstring GetAppInfoHelperForProtocol(ASSOCSTR assoc_str, const GURL& url) {
|
||||
nullptr, out_buffer, &buffer_size);
|
||||
if (FAILED(hr)) {
|
||||
DLOG(WARNING) << "AssocQueryString failed!";
|
||||
return std::wstring();
|
||||
return {};
|
||||
}
|
||||
return std::wstring(out_buffer);
|
||||
}
|
||||
@@ -251,7 +251,7 @@ std::unique_ptr<FileVersionInfo> FetchFileVersionInfo() {
|
||||
electron::ScopedAllowBlockingForElectron allow_blocking;
|
||||
return FileVersionInfo::CreateFileVersionInfo(path);
|
||||
}
|
||||
return std::unique_ptr<FileVersionInfo>();
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -594,7 +594,7 @@ ElectronBrowserClient::GetGeneratedCodeCacheSettings(
|
||||
// If we pass 0 for size, disk_cache will pick a default size using the
|
||||
// heuristics based on available disk size. These are implemented in
|
||||
// disk_cache::PreferredCacheSize in net/disk_cache/cache_util.cc.
|
||||
return content::GeneratedCodeCacheSettings(true, 0, cache_path);
|
||||
return {true, 0, cache_path};
|
||||
}
|
||||
|
||||
void ElectronBrowserClient::AllowCertificateError(
|
||||
@@ -627,7 +627,7 @@ base::OnceClosure ElectronBrowserClient::SelectClientCertificate(
|
||||
std::move(client_certs), std::move(delegate));
|
||||
}
|
||||
|
||||
return base::OnceClosure();
|
||||
return {};
|
||||
}
|
||||
|
||||
bool ElectronBrowserClient::CanCreateWindow(
|
||||
@@ -792,7 +792,7 @@ ElectronBrowserClient::CreateClientCertStore(
|
||||
#elif BUILDFLAG(IS_MAC)
|
||||
return std::make_unique<net::ClientCertStoreMac>();
|
||||
#elif defined(USE_OPENSSL)
|
||||
return std::unique_ptr<net::ClientCertStore>();
|
||||
return ();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -801,7 +801,7 @@ ElectronBrowserClient::OverrideSystemLocationProvider() {
|
||||
#if BUILDFLAG(OVERRIDE_LOCATION_PROVIDER)
|
||||
return std::make_unique<FakeLocationProvider>();
|
||||
#else
|
||||
return nullptr;
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -983,7 +983,7 @@ base::FilePath ElectronBrowserClient::GetDefaultDownloadDirectory() {
|
||||
base::FilePath download_path;
|
||||
if (base::PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &download_path))
|
||||
return download_path;
|
||||
return base::FilePath();
|
||||
return {};
|
||||
}
|
||||
|
||||
scoped_refptr<network::SharedURLLoaderFactory>
|
||||
|
||||
@@ -484,7 +484,7 @@ ElectronBrowserContext::CreateZoomLevelDelegate(
|
||||
if (!IsOffTheRecord()) {
|
||||
return std::make_unique<ZoomLevelDelegate>(prefs(), partition_path);
|
||||
}
|
||||
return std::unique_ptr<content::ZoomLevelDelegate>();
|
||||
return {};
|
||||
}
|
||||
|
||||
content::DownloadManagerDelegate*
|
||||
|
||||
@@ -163,7 +163,7 @@ std::u16string MediaStringProvider(media::MessageId id) {
|
||||
return u"Communications";
|
||||
#endif
|
||||
default:
|
||||
return std::u16string();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ class ElectronPermissionManager::PendingRequest {
|
||||
return content::RenderFrameHost::FromID(render_frame_host_id_);
|
||||
}
|
||||
|
||||
bool IsComplete() const { return remaining_results_ == 0; }
|
||||
[[nodiscard]] bool IsComplete() const { return remaining_results_ == 0; }
|
||||
|
||||
void RunCallback() {
|
||||
if (!callback_.is_null()) {
|
||||
@@ -278,8 +278,7 @@ ElectronPermissionManager::GetPermissionResultForOriginWithoutContext(
|
||||
const url::Origin& embedding_origin) {
|
||||
blink::mojom::PermissionStatus status = GetPermissionStatus(
|
||||
permission, requesting_origin.GetURL(), embedding_origin.GetURL());
|
||||
return content::PermissionResult(
|
||||
status, content::PermissionStatusSource::UNSPECIFIED);
|
||||
return {status, content::PermissionStatusSource::UNSPECIFIED};
|
||||
}
|
||||
|
||||
void ElectronPermissionManager::CheckBluetoothDevicePair(
|
||||
|
||||
@@ -54,7 +54,7 @@ ElectronWebUIControllerFactory::CreateWebUIControllerForURL(
|
||||
if (host == chrome::kChromeUIAccessibilityHost)
|
||||
return std::make_unique<ElectronAccessibilityUI>(web_ui);
|
||||
|
||||
return std::unique_ptr<content::WebUIController>();
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace electron
|
||||
|
||||
@@ -49,10 +49,10 @@ namespace extensions {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr char kCouldNotLoadFileError[] = "Could not load file: '*'.";
|
||||
constexpr char kDuplicateFileSpecifiedError[] =
|
||||
constexpr std::string_view kCouldNotLoadFileError = "Could not load file: '*'.";
|
||||
constexpr std::string_view kDuplicateFileSpecifiedError =
|
||||
"Duplicate file specified: '*'.";
|
||||
constexpr char kEmptyMatchesError[] =
|
||||
constexpr std::string_view kEmptyMatchesError =
|
||||
"Script with ID '*' must specify 'matches'.";
|
||||
constexpr char kExactlyOneOfCssAndFilesError[] =
|
||||
"Exactly one of 'css' and 'files' must be specified.";
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -39,7 +40,7 @@ namespace extensions {
|
||||
|
||||
namespace tabs = api::tabs;
|
||||
|
||||
const char kFrameNotFoundError[] = "No frame with id * in tab *.";
|
||||
constexpr std::string_view kFrameNotFoundError = "No frame with id * in tab *.";
|
||||
const char kPerOriginOnlyInAutomaticError[] =
|
||||
"Can only set scope to "
|
||||
"\"per-origin\" in \"automatic\" mode.";
|
||||
|
||||
@@ -87,6 +87,8 @@ void ElectronExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
|
||||
management_policy_ = std::make_unique<ManagementPolicy>();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
std::unique_ptr<base::Value::Dict> ParseManifest(
|
||||
const std::string_view manifest_contents) {
|
||||
JSONStringValueDeserializer deserializer(manifest_contents);
|
||||
@@ -95,11 +97,13 @@ std::unique_ptr<base::Value::Dict> ParseManifest(
|
||||
|
||||
if (!manifest.get() || !manifest->is_dict()) {
|
||||
LOG(ERROR) << "Failed to parse extension manifest.";
|
||||
return std::unique_ptr<base::Value::Dict>();
|
||||
return {};
|
||||
}
|
||||
return std::make_unique<base::Value::Dict>(std::move(*manifest).TakeDict());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void ElectronExtensionSystem::LoadComponentExtensions() {
|
||||
std::string utf8_error;
|
||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
|
||||
@@ -165,14 +165,14 @@ base::FilePath ElectronExtensionsBrowserClient::GetBundleResourcePath(
|
||||
*resource_id = 0;
|
||||
base::FilePath chrome_resources_path;
|
||||
if (!base::PathService::Get(chrome::DIR_RESOURCES, &chrome_resources_path))
|
||||
return base::FilePath();
|
||||
return {};
|
||||
|
||||
// Since component extension resources are included in
|
||||
// component_extension_resources.pak file in |chrome_resources_path|,
|
||||
// calculate the extension |request_relative_path| against
|
||||
// |chrome_resources_path|.
|
||||
if (!chrome_resources_path.IsParent(extension_resources_path))
|
||||
return base::FilePath();
|
||||
return {};
|
||||
|
||||
base::FilePath request_relative_path =
|
||||
extensions::file_util::ExtensionURLToRelativeFilePath(request.url);
|
||||
@@ -180,7 +180,7 @@ base::FilePath ElectronExtensionsBrowserClient::GetBundleResourcePath(
|
||||
->GetComponentExtensionResourceManager()
|
||||
->IsComponentExtensionResource(extension_resources_path,
|
||||
request_relative_path, resource_id)) {
|
||||
return base::FilePath();
|
||||
return {};
|
||||
}
|
||||
DCHECK_NE(0, *resource_id);
|
||||
|
||||
|
||||
@@ -531,7 +531,7 @@ bool FileSelectHelper::IsAcceptTypeValid(const std::string& accept_type) {
|
||||
base::FilePath FileSelectHelper::GetSanitizedFileName(
|
||||
const base::FilePath& suggested_filename) {
|
||||
if (suggested_filename.empty())
|
||||
return base::FilePath();
|
||||
return {};
|
||||
return net::GenerateFileName(
|
||||
GURL(), std::string(), std::string(), suggested_filename.AsUTF8Unsafe(),
|
||||
std::string(), l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME));
|
||||
|
||||
@@ -90,10 +90,10 @@ using blink::mojom::PermissionStatus;
|
||||
// }
|
||||
const char kDefaultLastPickedDirectoryKey[] = "default-id";
|
||||
const char kCustomLastPickedDirectoryKey[] = "custom-id";
|
||||
const char kPathKey[] = "path";
|
||||
const char kPathTypeKey[] = "path-type";
|
||||
const char kDisplayNameKey[] = "display-name";
|
||||
const char kTimestampKey[] = "timestamp";
|
||||
constexpr std::string_view kPathKey = "path";
|
||||
constexpr std::string_view kPathTypeKey = "path-type";
|
||||
constexpr std::string_view kDisplayNameKey = "display-name";
|
||||
constexpr std::string_view kTimestampKey = "timestamp";
|
||||
|
||||
constexpr base::TimeDelta kPermissionRevocationTimeout = base::Seconds(5);
|
||||
|
||||
|
||||
@@ -40,12 +40,14 @@ gin::IsolateHolder CreateIsolateHolder(v8::Isolate* isolate) {
|
||||
// This is necessary for important aspects of Node.js
|
||||
// including heap and cpu profilers to function properly.
|
||||
|
||||
return gin::IsolateHolder(base::SingleThreadTaskRunner::GetCurrentDefault(),
|
||||
gin::IsolateHolder::kSingleThread,
|
||||
gin::IsolateHolder::IsolateType::kUtility,
|
||||
std::move(create_params),
|
||||
gin::IsolateHolder::IsolateCreationMode::kNormal,
|
||||
nullptr, nullptr, isolate);
|
||||
return {base::SingleThreadTaskRunner::GetCurrentDefault(),
|
||||
gin::IsolateHolder::kSingleThread,
|
||||
gin::IsolateHolder::IsolateType::kUtility,
|
||||
std::move(create_params),
|
||||
gin::IsolateHolder::IsolateCreationMode::kNormal,
|
||||
nullptr,
|
||||
nullptr,
|
||||
isolate};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -10,24 +10,22 @@
|
||||
#include <string>
|
||||
|
||||
// Unity data typedefs.
|
||||
typedef struct _UnityInspector UnityInspector;
|
||||
typedef UnityInspector* (*unity_inspector_get_default_func)();
|
||||
typedef gboolean (*unity_inspector_get_unity_running_func)(
|
||||
UnityInspector* self);
|
||||
using UnityInspector = struct _UnityInspector;
|
||||
using unity_inspector_get_default_func = UnityInspector* (*)();
|
||||
using unity_inspector_get_unity_running_func =
|
||||
gboolean (*)(UnityInspector* self);
|
||||
|
||||
typedef struct _UnityLauncherEntry UnityLauncherEntry;
|
||||
typedef UnityLauncherEntry* (*unity_launcher_entry_get_for_desktop_id_func)(
|
||||
const gchar* desktop_id);
|
||||
typedef void (*unity_launcher_entry_set_count_func)(UnityLauncherEntry* self,
|
||||
gint64 value);
|
||||
typedef void (*unity_launcher_entry_set_count_visible_func)(
|
||||
UnityLauncherEntry* self,
|
||||
gboolean value);
|
||||
typedef void (*unity_launcher_entry_set_progress_func)(UnityLauncherEntry* self,
|
||||
gdouble value);
|
||||
typedef void (*unity_launcher_entry_set_progress_visible_func)(
|
||||
UnityLauncherEntry* self,
|
||||
gboolean value);
|
||||
using UnityLauncherEntry = struct _UnityLauncherEntry;
|
||||
using unity_launcher_entry_get_for_desktop_id_func =
|
||||
UnityLauncherEntry* (*)(const gchar* desktop_id);
|
||||
using unity_launcher_entry_set_count_func = void (*)(UnityLauncherEntry* self,
|
||||
gint64 value);
|
||||
using unity_launcher_entry_set_count_visible_func =
|
||||
void (*)(UnityLauncherEntry* self, gboolean value);
|
||||
using unity_launcher_entry_set_progress_func =
|
||||
void (*)(UnityLauncherEntry* self, gdouble value);
|
||||
using unity_launcher_entry_set_progress_visible_func =
|
||||
void (*)(UnityLauncherEntry* self, gboolean value);
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
@@ -334,7 +334,7 @@ extensions::SizeConstraints NativeWindow::GetSizeConstraints() const {
|
||||
if (size_constraints_)
|
||||
return *size_constraints_;
|
||||
if (!content_size_constraints_)
|
||||
return extensions::SizeConstraints();
|
||||
return {};
|
||||
// Convert content size constraints to window size constraints.
|
||||
extensions::SizeConstraints constraints;
|
||||
if (content_size_constraints_->HasMaximumSize()) {
|
||||
@@ -368,7 +368,7 @@ extensions::SizeConstraints NativeWindow::GetContentSizeConstraints() const {
|
||||
if (content_size_constraints_)
|
||||
return *content_size_constraints_;
|
||||
if (!size_constraints_)
|
||||
return extensions::SizeConstraints();
|
||||
return {};
|
||||
// Convert window size constraints to content size constraints.
|
||||
// Note that we are not caching the results, because Chromium reccalculates
|
||||
// window frame size everytime when min/max sizes are passed, and we must
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "base/location.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/numerics/safe_conversions.h"
|
||||
#include "base/task/single_thread_task_runner.h"
|
||||
#include "base/time/time.h"
|
||||
#include "components/input/cursor_manager.h"
|
||||
@@ -115,9 +116,9 @@ ui::MouseEvent UiMouseEventFromWebMouseEvent(blink::WebMouseEvent event) {
|
||||
|
||||
ui::MouseWheelEvent UiMouseWheelEventFromWebMouseEvent(
|
||||
blink::WebMouseWheelEvent event) {
|
||||
return ui::MouseWheelEvent(UiMouseEventFromWebMouseEvent(event),
|
||||
std::floor(event.delta_x),
|
||||
std::floor(event.delta_y));
|
||||
return {UiMouseEventFromWebMouseEvent(event),
|
||||
base::ClampFloor<int>(event.delta_x),
|
||||
base::ClampFloor<int>(event.delta_y)};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -135,15 +136,15 @@ class ElectronDelegatedFrameHostClient
|
||||
const ElectronDelegatedFrameHostClient&) = delete;
|
||||
|
||||
// content::DelegatedFrameHostClient
|
||||
ui::Layer* DelegatedFrameHostGetLayer() const override {
|
||||
[[nodiscard]] ui::Layer* DelegatedFrameHostGetLayer() const override {
|
||||
return view_->root_layer();
|
||||
}
|
||||
|
||||
bool DelegatedFrameHostIsVisible() const override {
|
||||
[[nodiscard]] bool DelegatedFrameHostIsVisible() const override {
|
||||
return view_->IsShowing();
|
||||
}
|
||||
|
||||
SkColor DelegatedFrameHostGetGutterColor() const override {
|
||||
[[nodiscard]] SkColor DelegatedFrameHostGetGutterColor() const override {
|
||||
if (view_->render_widget_host()->delegate() &&
|
||||
view_->render_widget_host()->delegate()->IsFullscreen()) {
|
||||
return SK_ColorWHITE;
|
||||
@@ -156,7 +157,7 @@ class ElectronDelegatedFrameHostClient
|
||||
view_->render_widget_host()->DidProcessFrame(frame_token, activation_time);
|
||||
}
|
||||
|
||||
float GetDeviceScaleFactor() const override {
|
||||
[[nodiscard]] float GetDeviceScaleFactor() const override {
|
||||
return view_->GetDeviceScaleFactor();
|
||||
}
|
||||
|
||||
@@ -296,12 +297,12 @@ void OffScreenRenderWidgetHostView::SetBounds(const gfx::Rect& new_bounds) {
|
||||
}
|
||||
|
||||
gfx::NativeView OffScreenRenderWidgetHostView::GetNativeView() {
|
||||
return gfx::NativeView();
|
||||
return {};
|
||||
}
|
||||
|
||||
gfx::NativeViewAccessible
|
||||
OffScreenRenderWidgetHostView::GetNativeViewAccessible() {
|
||||
return gfx::NativeViewAccessible();
|
||||
return {};
|
||||
}
|
||||
|
||||
ui::TextInputClient* OffScreenRenderWidgetHostView::GetTextInputClient() {
|
||||
|
||||
@@ -74,19 +74,19 @@ gfx::Size OffScreenWebContentsView::GetSize() {
|
||||
#if !BUILDFLAG(IS_MAC)
|
||||
gfx::NativeView OffScreenWebContentsView::GetNativeView() const {
|
||||
if (!native_window_)
|
||||
return gfx::NativeView();
|
||||
return {};
|
||||
return native_window_->GetNativeView();
|
||||
}
|
||||
|
||||
gfx::NativeView OffScreenWebContentsView::GetContentNativeView() const {
|
||||
if (!native_window_)
|
||||
return gfx::NativeView();
|
||||
return {};
|
||||
return native_window_->GetNativeView();
|
||||
}
|
||||
|
||||
gfx::NativeWindow OffScreenWebContentsView::GetTopLevelNativeWindow() const {
|
||||
if (!native_window_)
|
||||
return gfx::NativeWindow();
|
||||
return {};
|
||||
return native_window_->GetNativeWindow();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -28,7 +28,7 @@ std::string PluginUtils::GetExtensionIdForMimeType(
|
||||
auto it = map.find(mime_type);
|
||||
if (it != map.end())
|
||||
return it->second;
|
||||
return std::string();
|
||||
return {};
|
||||
}
|
||||
|
||||
base::flat_map<std::string, std::string>
|
||||
|
||||
@@ -59,7 +59,7 @@ gfx::Size GetDefaultPrinterDPI(const std::u16string& device_name) {
|
||||
GtkPrintSettings* print_settings = gtk_print_settings_new();
|
||||
int dpi = gtk_print_settings_get_resolution(print_settings);
|
||||
g_object_unref(print_settings);
|
||||
return gfx::Size(dpi, dpi);
|
||||
return {dpi, dpi};
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -79,6 +79,8 @@ bool IsDeviceNameValid(const std::u16string& device_name) {
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// Duplicated from chrome/browser/printing/print_view_manager_common.cc
|
||||
content::RenderFrameHost* GetFullPagePlugin(content::WebContents* contents) {
|
||||
content::RenderFrameHost* full_page_plugin = nullptr;
|
||||
@@ -98,6 +100,8 @@ content::RenderFrameHost* GetFullPagePlugin(content::WebContents* contents) {
|
||||
return full_page_plugin;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// Pick the right RenderFrameHost based on the WebContents.
|
||||
// Modified from chrome/browser/printing/print_view_manager_common.cc
|
||||
content::RenderFrameHost* GetRenderFrameHostToUse(
|
||||
|
||||
@@ -23,6 +23,24 @@
|
||||
#include "base/posix/eintr_wrapper.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
// The argument separating arguments intended for the relauncher process from
|
||||
// those intended for the relaunched process. "---" is chosen instead of "--"
|
||||
// because CommandLine interprets "--" as meaning "end of switches", but
|
||||
// for many purposes, the relauncher process' CommandLine ought to interpret
|
||||
// arguments intended for the relaunched process, to get the correct settings
|
||||
// for such things as logging and the user-data-dir in case it affects crash
|
||||
// reporting.
|
||||
constexpr base::CommandLine::CharType kRelauncherArgSeparator[] =
|
||||
FILE_PATH_LITERAL("---");
|
||||
|
||||
// The "type" argument identifying a relauncher process ("--type=relauncher").
|
||||
constexpr base::CommandLine::CharType kRelauncherTypeArg[] =
|
||||
FILE_PATH_LITERAL("--type=relauncher");
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace relauncher {
|
||||
|
||||
namespace internal {
|
||||
@@ -31,9 +49,6 @@ namespace internal {
|
||||
const int kRelauncherSyncFD = STDERR_FILENO + 1;
|
||||
#endif
|
||||
|
||||
const CharType* kRelauncherTypeArg = FILE_PATH_LITERAL("--type=relauncher");
|
||||
const CharType* kRelauncherArgSeparator = FILE_PATH_LITERAL("---");
|
||||
|
||||
} // namespace internal
|
||||
|
||||
bool RelaunchApp(const StringVector& argv) {
|
||||
@@ -58,7 +73,7 @@ bool RelaunchAppWithHelper(const base::FilePath& helper,
|
||||
const StringVector& argv) {
|
||||
StringVector relaunch_argv;
|
||||
relaunch_argv.push_back(helper.value());
|
||||
relaunch_argv.push_back(internal::kRelauncherTypeArg);
|
||||
relaunch_argv.push_back(kRelauncherTypeArg);
|
||||
// Relauncher process has its own --type=relauncher which
|
||||
// is not recognized by the service_manager, explicitly set
|
||||
// the sandbox type to avoid CHECK failure in
|
||||
@@ -68,7 +83,7 @@ bool RelaunchAppWithHelper(const base::FilePath& helper,
|
||||
relaunch_argv.insert(relaunch_argv.end(), relauncher_args.begin(),
|
||||
relauncher_args.end());
|
||||
|
||||
relaunch_argv.push_back(internal::kRelauncherArgSeparator);
|
||||
relaunch_argv.push_back(kRelauncherArgSeparator);
|
||||
|
||||
relaunch_argv.insert(relaunch_argv.end(), argv.begin(), argv.end());
|
||||
|
||||
@@ -147,7 +162,7 @@ bool RelaunchAppWithHelper(const base::FilePath& helper,
|
||||
int RelauncherMain(const content::MainFunctionParams& main_parameters) {
|
||||
const StringVector& argv = electron::ElectronCommandLine::argv();
|
||||
|
||||
if (argv.size() < 4 || argv[1] != internal::kRelauncherTypeArg) {
|
||||
if (argv.size() < 4 || argv[1] != kRelauncherTypeArg) {
|
||||
LOG(ERROR) << "relauncher process invoked with unexpected arguments";
|
||||
return 1;
|
||||
}
|
||||
@@ -162,7 +177,7 @@ int RelauncherMain(const content::MainFunctionParams& main_parameters) {
|
||||
for (size_t argv_index = 2; argv_index < argv.size(); ++argv_index) {
|
||||
const StringType& arg(argv[argv_index]);
|
||||
if (!in_relauncher_args) {
|
||||
if (arg == internal::kRelauncherArgSeparator) {
|
||||
if (arg == kRelauncherArgSeparator) {
|
||||
in_relauncher_args = true;
|
||||
} else {
|
||||
relauncher_args.push_back(arg);
|
||||
|
||||
@@ -41,7 +41,6 @@ struct MainFunctionParams;
|
||||
|
||||
namespace relauncher {
|
||||
|
||||
using CharType = base::CommandLine::CharType;
|
||||
using StringType = base::CommandLine::StringType;
|
||||
using StringVector = base::CommandLine::StringVector;
|
||||
|
||||
@@ -83,18 +82,6 @@ namespace internal {
|
||||
extern const int kRelauncherSyncFD;
|
||||
#endif
|
||||
|
||||
// The "type" argument identifying a relauncher process ("--type=relauncher").
|
||||
extern const CharType* kRelauncherTypeArg;
|
||||
|
||||
// The argument separating arguments intended for the relauncher process from
|
||||
// those intended for the relaunched process. "---" is chosen instead of "--"
|
||||
// because CommandLine interprets "--" as meaning "end of switches", but
|
||||
// for many purposes, the relauncher process' CommandLine ought to interpret
|
||||
// arguments intended for the relaunched process, to get the correct settings
|
||||
// for such things as logging and the user-data-dir in case it affects crash
|
||||
// reporting.
|
||||
extern const CharType* kRelauncherArgSeparator;
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
StringType GetWaitEventName(base::ProcessId pid);
|
||||
|
||||
|
||||
@@ -19,8 +19,6 @@ namespace relauncher::internal {
|
||||
|
||||
namespace {
|
||||
|
||||
const CharType* kWaitEventName = L"ElectronRelauncherWaitEvent";
|
||||
|
||||
struct PROCESS_BASIC_INFORMATION {
|
||||
union {
|
||||
NTSTATUS ExitStatus;
|
||||
@@ -98,8 +96,8 @@ StringType AddQuoteForArg(const StringType& arg) {
|
||||
} // namespace
|
||||
|
||||
StringType GetWaitEventName(base::ProcessId pid) {
|
||||
return base::StrCat(
|
||||
{kWaitEventName, L"-", base::NumberToWString(static_cast<int>(pid))});
|
||||
return base::StrCat({L"ElectronRelauncherWaitEvent-",
|
||||
base::NumberToWString(static_cast<int>(pid))});
|
||||
}
|
||||
|
||||
StringType ArgvToCommandLineString(const StringVector& argv) {
|
||||
|
||||
@@ -245,7 +245,7 @@ gfx::Rect AutofillPopup::popup_bounds_in_view() {
|
||||
gfx::Point origin(popup_bounds_.origin());
|
||||
views::View::ConvertPointFromScreen(parent_, &origin);
|
||||
|
||||
return gfx::Rect(origin, popup_bounds_.size());
|
||||
return {origin, popup_bounds_.size()};
|
||||
}
|
||||
|
||||
void AutofillPopup::OnViewBoundsChanged(views::View* view) {
|
||||
@@ -280,9 +280,8 @@ int AutofillPopup::GetDesiredPopupWidth() {
|
||||
gfx::Rect AutofillPopup::GetRowBounds(int index) {
|
||||
int top = kPopupBorderThickness + index * kRowHeight;
|
||||
|
||||
return gfx::Rect(kPopupBorderThickness, top,
|
||||
popup_bounds_.width() - 2 * kPopupBorderThickness,
|
||||
kRowHeight);
|
||||
return {kPopupBorderThickness, top,
|
||||
popup_bounds_.width() - 2 * kPopupBorderThickness, kRowHeight};
|
||||
}
|
||||
|
||||
const gfx::FontList& AutofillPopup::GetValueFontListForRow(int index) const {
|
||||
|
||||
@@ -50,13 +50,13 @@ class TCPServerSocketFactory : public content::DevToolsSocketFactory {
|
||||
auto socket =
|
||||
std::make_unique<net::TCPServerSocket>(nullptr, net::NetLogSource());
|
||||
if (socket->ListenWithAddressAndPort(address_, port_, 10) != net::OK)
|
||||
return std::unique_ptr<net::ServerSocket>();
|
||||
return {};
|
||||
|
||||
return socket;
|
||||
}
|
||||
std::unique_ptr<net::ServerSocket> CreateForTethering(
|
||||
std::string* name) override {
|
||||
return std::unique_ptr<net::ServerSocket>();
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string address_;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/memory/ref_counted_memory.h"
|
||||
@@ -97,7 +98,7 @@ void ThemeDataSource::StartDataRequest(
|
||||
|
||||
// kColorsCssPath should stay consistent with COLORS_CSS_SELECTOR in
|
||||
// colors_css_updater.js.
|
||||
constexpr char kColorsCssPath[] = "colors.css";
|
||||
constexpr std::string_view kColorsCssPath = "colors.css";
|
||||
if (parsed_path == kColorsCssPath) {
|
||||
SendColorsCss(url, wc_getter, std::move(callback));
|
||||
return;
|
||||
|
||||
@@ -50,12 +50,12 @@ gfx::Insets ElectronDesktopWindowTreeHostLinux::CalculateInsetsInDIP(
|
||||
ui::PlatformWindowState window_state) const {
|
||||
// If we are not showing frame, the insets should be zero.
|
||||
if (native_window_view_->IsFullscreen()) {
|
||||
return gfx::Insets();
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!native_window_view_->has_frame() ||
|
||||
!native_window_view_->has_client_frame()) {
|
||||
return gfx::Insets();
|
||||
return {};
|
||||
}
|
||||
|
||||
auto* view = static_cast<ClientFrameViewLinux*>(
|
||||
|
||||
@@ -70,25 +70,26 @@ namespace electron {
|
||||
|
||||
namespace {
|
||||
|
||||
const char kChromeUIDevToolsURL[] =
|
||||
constexpr std::string_view kChromeUIDevToolsURL =
|
||||
"devtools://devtools/bundled/devtools_app.html?"
|
||||
"remoteBase=%s&"
|
||||
"can_dock=%s&"
|
||||
"toolbarColor=rgba(223,223,223,1)&"
|
||||
"textColor=rgba(0,0,0,1)&"
|
||||
"experiments=true";
|
||||
const char kChromeUIDevToolsRemoteFrontendBase[] =
|
||||
constexpr std::string_view kChromeUIDevToolsRemoteFrontendBase =
|
||||
"https://chrome-devtools-frontend.appspot.com/";
|
||||
const char kChromeUIDevToolsRemoteFrontendPath[] = "serve_file";
|
||||
constexpr std::string_view kChromeUIDevToolsRemoteFrontendPath = "serve_file";
|
||||
|
||||
const char kDevToolsBoundsPref[] = "electron.devtools.bounds";
|
||||
const char kDevToolsZoomPref[] = "electron.devtools.zoom";
|
||||
const char kDevToolsPreferences[] = "electron.devtools.preferences";
|
||||
constexpr std::string_view kDevToolsBoundsPref = "electron.devtools.bounds";
|
||||
constexpr std::string_view kDevToolsZoomPref = "electron.devtools.zoom";
|
||||
constexpr std::string_view kDevToolsPreferences =
|
||||
"electron.devtools.preferences";
|
||||
|
||||
const char kFrontendHostId[] = "id";
|
||||
const char kFrontendHostMethod[] = "method";
|
||||
const char kFrontendHostParams[] = "params";
|
||||
const char kTitleFormat[] = "Developer Tools - %s";
|
||||
constexpr std::string_view kFrontendHostId = "id";
|
||||
constexpr std::string_view kFrontendHostMethod = "method";
|
||||
constexpr std::string_view kFrontendHostParams = "params";
|
||||
constexpr std::string_view kTitleFormat = "Developer Tools - %s";
|
||||
|
||||
const size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ TrayIcon::TrayIcon() = default;
|
||||
TrayIcon::~TrayIcon() = default;
|
||||
|
||||
gfx::Rect TrayIcon::GetBounds() {
|
||||
return gfx::Rect();
|
||||
return {};
|
||||
}
|
||||
|
||||
void TrayIcon::NotifyClicked(const gfx::Rect& bounds,
|
||||
|
||||
@@ -154,8 +154,8 @@ gfx::Insets ClientFrameViewLinux::GetBorderDecorationInsets() const {
|
||||
}
|
||||
|
||||
gfx::Insets ClientFrameViewLinux::GetInputInsets() const {
|
||||
return gfx::Insets(
|
||||
host_supports_client_frame_shadow_ ? -kResizeOutsideBorderSize : 0);
|
||||
return gfx::Insets{
|
||||
host_supports_client_frame_shadow_ ? -kResizeOutsideBorderSize : 0};
|
||||
}
|
||||
|
||||
gfx::Rect ClientFrameViewLinux::GetWindowContentBounds() const {
|
||||
@@ -457,7 +457,7 @@ void ClientFrameViewLinux::LayoutButtonsOnSide(
|
||||
|
||||
gfx::Rect ClientFrameViewLinux::GetTitlebarBounds() const {
|
||||
if (frame_->IsFullscreen()) {
|
||||
return gfx::Rect();
|
||||
return {};
|
||||
}
|
||||
|
||||
int font_height = gfx::FontList().GetHeight();
|
||||
|
||||
@@ -24,36 +24,35 @@
|
||||
#include "ui/gfx/x/xproto.h"
|
||||
|
||||
// libdbusmenu-glib types
|
||||
typedef struct _DbusmenuMenuitem DbusmenuMenuitem;
|
||||
typedef DbusmenuMenuitem* (*dbusmenu_menuitem_new_func)();
|
||||
typedef DbusmenuMenuitem* (*dbusmenu_menuitem_new_with_id_func)(int id);
|
||||
using DbusmenuMenuitem = struct _DbusmenuMenuitem;
|
||||
using dbusmenu_menuitem_new_func = DbusmenuMenuitem* (*)();
|
||||
using dbusmenu_menuitem_new_with_id_func = DbusmenuMenuitem* (*)(int id);
|
||||
|
||||
typedef int (*dbusmenu_menuitem_get_id_func)(DbusmenuMenuitem* item);
|
||||
typedef GList* (*dbusmenu_menuitem_get_children_func)(DbusmenuMenuitem* item);
|
||||
typedef DbusmenuMenuitem* (*dbusmenu_menuitem_child_append_func)(
|
||||
DbusmenuMenuitem* parent,
|
||||
DbusmenuMenuitem* child);
|
||||
typedef DbusmenuMenuitem* (*dbusmenu_menuitem_property_set_func)(
|
||||
DbusmenuMenuitem* item,
|
||||
const char* property,
|
||||
const char* value);
|
||||
typedef DbusmenuMenuitem* (*dbusmenu_menuitem_property_set_variant_func)(
|
||||
DbusmenuMenuitem* item,
|
||||
const char* property,
|
||||
GVariant* value);
|
||||
typedef DbusmenuMenuitem* (*dbusmenu_menuitem_property_set_bool_func)(
|
||||
DbusmenuMenuitem* item,
|
||||
const char* property,
|
||||
bool value);
|
||||
typedef DbusmenuMenuitem* (*dbusmenu_menuitem_property_set_int_func)(
|
||||
DbusmenuMenuitem* item,
|
||||
const char* property,
|
||||
int value);
|
||||
using dbusmenu_menuitem_get_id_func = int (*)(DbusmenuMenuitem* item);
|
||||
using dbusmenu_menuitem_get_children_func = GList* (*)(DbusmenuMenuitem* item);
|
||||
using dbusmenu_menuitem_child_append_func =
|
||||
DbusmenuMenuitem* (*)(DbusmenuMenuitem* parent, DbusmenuMenuitem* child);
|
||||
using dbusmenu_menuitem_property_set_func =
|
||||
DbusmenuMenuitem* (*)(DbusmenuMenuitem* item,
|
||||
const char* property,
|
||||
const char* value);
|
||||
using dbusmenu_menuitem_property_set_variant_func =
|
||||
DbusmenuMenuitem* (*)(DbusmenuMenuitem* item,
|
||||
const char* property,
|
||||
GVariant* value);
|
||||
using dbusmenu_menuitem_property_set_bool_func =
|
||||
DbusmenuMenuitem* (*)(DbusmenuMenuitem* item,
|
||||
const char* property,
|
||||
bool value);
|
||||
using dbusmenu_menuitem_property_set_int_func =
|
||||
DbusmenuMenuitem* (*)(DbusmenuMenuitem* item,
|
||||
const char* property,
|
||||
int value);
|
||||
|
||||
typedef struct _DbusmenuServer DbusmenuServer;
|
||||
typedef DbusmenuServer* (*dbusmenu_server_new_func)(const char* object);
|
||||
typedef void (*dbusmenu_server_set_root_func)(DbusmenuServer* self,
|
||||
DbusmenuMenuitem* root);
|
||||
using DbusmenuServer = struct _DbusmenuServer;
|
||||
using dbusmenu_server_new_func = DbusmenuServer* (*)(const char* object);
|
||||
using dbusmenu_server_set_root_func = void (*)(DbusmenuServer* self,
|
||||
DbusmenuMenuitem* root);
|
||||
|
||||
namespace electron {
|
||||
|
||||
|
||||
@@ -338,7 +338,7 @@ bool OpaqueFrameView::IsFrameCondensed() const {
|
||||
}
|
||||
|
||||
gfx::Insets OpaqueFrameView::RestoredFrameBorderInsets() const {
|
||||
return gfx::Insets();
|
||||
return {};
|
||||
}
|
||||
|
||||
gfx::Insets OpaqueFrameView::RestoredFrameEdgeInsets() const {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -50,49 +51,49 @@
|
||||
|
||||
namespace {
|
||||
|
||||
static const char kTargetsDataFile[] = "targets-data.json";
|
||||
constexpr std::string_view kTargetsDataFile = "targets-data.json";
|
||||
|
||||
static const char kAccessibilityModeField[] = "a11yMode";
|
||||
static const char kBrowsersField[] = "browsers";
|
||||
static const char kErrorField[] = "error";
|
||||
static const char kFaviconUrlField[] = "faviconUrl";
|
||||
static const char kNameField[] = "name";
|
||||
static const char kPagesField[] = "pages";
|
||||
static const char kPidField[] = "pid";
|
||||
static const char kProcessIdField[] = "processId";
|
||||
static const char kRequestTypeField[] = "requestType";
|
||||
static const char kRoutingIdField[] = "routingId";
|
||||
static const char kSessionIdField[] = "sessionId";
|
||||
static const char kSupportedApiTypesField[] = "supportedApiTypes";
|
||||
static const char kTreeField[] = "tree";
|
||||
static const char kTypeField[] = "type";
|
||||
static const char kUrlField[] = "url";
|
||||
static const char kWidgetsField[] = "widgets";
|
||||
static const char kApiTypeField[] = "apiType";
|
||||
constexpr std::string_view kAccessibilityModeField = "a11yMode";
|
||||
constexpr std::string_view kBrowsersField = "browsers";
|
||||
constexpr std::string_view kErrorField = "error";
|
||||
constexpr std::string_view kFaviconUrlField = "faviconUrl";
|
||||
constexpr std::string_view kNameField = "name";
|
||||
constexpr std::string_view kPagesField = "pages";
|
||||
constexpr std::string_view kPidField = "pid";
|
||||
constexpr std::string_view kProcessIdField = "processId";
|
||||
constexpr std::string_view kRequestTypeField = "requestType";
|
||||
constexpr std::string_view kRoutingIdField = "routingId";
|
||||
constexpr std::string_view kSessionIdField = "sessionId";
|
||||
constexpr std::string_view kSupportedApiTypesField = "supportedApiTypes";
|
||||
constexpr std::string_view kTreeField = "tree";
|
||||
constexpr std::string_view kTypeField = "type";
|
||||
constexpr std::string_view kUrlField = "url";
|
||||
constexpr std::string_view kWidgetsField = "widgets";
|
||||
constexpr std::string_view kApiTypeField = "apiType";
|
||||
|
||||
#if defined(USE_AURA)
|
||||
static const char kWidgetIdField[] = "widgetId";
|
||||
static const char kWidget[] = "widget";
|
||||
constexpr std::string_view kWidgetIdField = "widgetId";
|
||||
constexpr std::string_view kWidget = "widget";
|
||||
#endif
|
||||
|
||||
// Global flags
|
||||
static const char kBrowser[] = "browser";
|
||||
static const char kCopyTree[] = "copyTree";
|
||||
static const char kHTML[] = "html";
|
||||
static const char kLocked[] = "locked";
|
||||
static const char kNative[] = "native";
|
||||
static const char kPage[] = "page";
|
||||
static const char kPDFPrinting[] = "pdfPrinting";
|
||||
static const char kScreenReader[] = "screenreader";
|
||||
static const char kShowOrRefreshTree[] = "showOrRefreshTree";
|
||||
static const char kText[] = "text";
|
||||
static const char kViewsAccessibility[] = "viewsAccessibility";
|
||||
static const char kWeb[] = "web";
|
||||
constexpr std::string_view kBrowser = "browser";
|
||||
constexpr std::string_view kCopyTree = "copyTree";
|
||||
constexpr std::string_view kHTML = "html";
|
||||
constexpr std::string_view kLocked = "locked";
|
||||
constexpr std::string_view kNative = "native";
|
||||
constexpr std::string_view kPage = "page";
|
||||
constexpr std::string_view kPDFPrinting = "pdfPrinting";
|
||||
constexpr std::string_view kScreenReader = "screenreader";
|
||||
constexpr std::string_view kShowOrRefreshTree = "showOrRefreshTree";
|
||||
constexpr std::string_view kText = "text";
|
||||
constexpr std::string_view kViewsAccessibility = "viewsAccessibility";
|
||||
constexpr std::string_view kWeb = "web";
|
||||
|
||||
// Possible global flag values
|
||||
static const char kDisabled[] = "disabled";
|
||||
static const char kOff[] = "off";
|
||||
static const char kOn[] = "on";
|
||||
constexpr std::string_view kDisabled = "disabled";
|
||||
constexpr std::string_view kOff = "off";
|
||||
constexpr std::string_view kOn = "on";
|
||||
|
||||
base::Value::Dict BuildTargetDescriptor(
|
||||
const GURL& url,
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr char kDeviceNameKey[] = "productName";
|
||||
constexpr char kDeviceIdKey[] = "deviceId";
|
||||
constexpr std::string_view kDeviceNameKey = "productName";
|
||||
constexpr std::string_view kDeviceIdKey = "deviceId";
|
||||
constexpr int kUsbClassMassStorage = 0x08;
|
||||
|
||||
bool CanStorePersistentEntry(const device::mojom::UsbDeviceInfo& device_info) {
|
||||
|
||||
@@ -53,8 +53,7 @@ namespace {
|
||||
|
||||
// If the device id wasn't specified then this is a screen capture request
|
||||
// (i.e. chooseDesktopMedia() API wasn't used to generate device id).
|
||||
return content::DesktopMediaID(content::DesktopMediaID::TYPE_SCREEN,
|
||||
-1 /* kFullDesktopScreenId */);
|
||||
return {content::DesktopMediaID::TYPE_SCREEN, -1 /* kFullDesktopScreenId */};
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
|
||||
@@ -22,11 +22,13 @@ namespace electron {
|
||||
namespace {
|
||||
|
||||
// Double that indicates the default zoom level.
|
||||
const char kPartitionDefaultZoomLevel[] = "partition.default_zoom_level";
|
||||
constexpr std::string_view kPartitionDefaultZoomLevel =
|
||||
"partition.default_zoom_level";
|
||||
|
||||
// Dictionary that maps hostnames to zoom levels. Hosts not in this pref will
|
||||
// be displayed at the default zoom level.
|
||||
const char kPartitionPerHostZoomLevels[] = "partition.per_host_zoom_levels";
|
||||
constexpr std::string_view kPartitionPerHostZoomLevels =
|
||||
"partition.per_host_zoom_levels";
|
||||
|
||||
std::string GetHash(const base::FilePath& partition_path) {
|
||||
size_t int_key = std::hash<base::FilePath>()(partition_path);
|
||||
|
||||
@@ -231,7 +231,7 @@ gfx::Image Clipboard::ReadImage(gin_helper::Arguments* args) {
|
||||
args->ThrowError(
|
||||
"clipboard.readImage is available only after app ready in the main "
|
||||
"process");
|
||||
return gfx::Image();
|
||||
return {};
|
||||
}
|
||||
|
||||
ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
|
||||
@@ -271,7 +271,7 @@ void Clipboard::WriteImage(const gfx::Image& image,
|
||||
#if !BUILDFLAG(IS_MAC)
|
||||
void Clipboard::WriteFindText(const std::u16string& text) {}
|
||||
std::u16string Clipboard::ReadFindText() {
|
||||
return std::u16string();
|
||||
return {};
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -323,7 +323,7 @@ gfx::Size NativeImage::GetSize(const std::optional<float> scale_factor) {
|
||||
float sf = scale_factor.value_or(1.0f);
|
||||
gfx::ImageSkiaRep image_rep = image_.AsImageSkia().GetRepresentation(sf);
|
||||
|
||||
return gfx::Size(image_rep.GetWidth(), image_rep.GetHeight());
|
||||
return {image_rep.GetWidth(), image_rep.GetHeight()};
|
||||
}
|
||||
|
||||
std::vector<float> NativeImage::GetScaleFactors() {
|
||||
@@ -489,7 +489,7 @@ gin::Handle<NativeImage> NativeImage::CreateFromBitmap(
|
||||
const gin_helper::Dictionary& options) {
|
||||
if (!node::Buffer::HasInstance(buffer)) {
|
||||
thrower.ThrowError("buffer must be a node Buffer");
|
||||
return gin::Handle<NativeImage>();
|
||||
return {};
|
||||
}
|
||||
|
||||
int width = 0;
|
||||
@@ -497,12 +497,12 @@ gin::Handle<NativeImage> NativeImage::CreateFromBitmap(
|
||||
|
||||
if (!options.Get("width", &width)) {
|
||||
thrower.ThrowError("width is required");
|
||||
return gin::Handle<NativeImage>();
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!options.Get("height", &height)) {
|
||||
thrower.ThrowError("height is required");
|
||||
return gin::Handle<NativeImage>();
|
||||
return {};
|
||||
}
|
||||
|
||||
if (width <= 0 || height <= 0)
|
||||
@@ -514,7 +514,7 @@ gin::Handle<NativeImage> NativeImage::CreateFromBitmap(
|
||||
const auto buffer_data = electron::util::as_byte_span(buffer);
|
||||
if (size_bytes != buffer_data.size()) {
|
||||
thrower.ThrowError("invalid buffer size");
|
||||
return gin::Handle<NativeImage>();
|
||||
return {};
|
||||
}
|
||||
|
||||
SkBitmap bitmap;
|
||||
@@ -536,7 +536,7 @@ gin::Handle<NativeImage> NativeImage::CreateFromBuffer(
|
||||
gin::Arguments* args) {
|
||||
if (!node::Buffer::HasInstance(buffer)) {
|
||||
thrower.ThrowError("buffer must be a node Buffer");
|
||||
return gin::Handle<NativeImage>();
|
||||
return {};
|
||||
}
|
||||
|
||||
int width = 0;
|
||||
|
||||
@@ -149,7 +149,7 @@ class BufferDataSource : public mojo::DataPipeProducer::DataSource {
|
||||
|
||||
private:
|
||||
// mojo::DataPipeProducer::DataSource:
|
||||
uint64_t GetLength() const override { return buffer_.size(); }
|
||||
[[nodiscard]] uint64_t GetLength() const override { return buffer_.size(); }
|
||||
ReadResult Read(uint64_t offset, base::span<char> buffer) override {
|
||||
ReadResult result;
|
||||
if (offset <= buffer_.size()) {
|
||||
@@ -532,14 +532,14 @@ gin::Handle<SimpleURLLoaderWrapper> SimpleURLLoaderWrapper::Create(
|
||||
gin_helper::Dictionary opts;
|
||||
if (!args->GetNext(&opts)) {
|
||||
args->ThrowTypeError("Expected a dictionary");
|
||||
return gin::Handle<SimpleURLLoaderWrapper>();
|
||||
return {};
|
||||
}
|
||||
auto request = std::make_unique<network::ResourceRequest>();
|
||||
opts.Get("method", &request->method);
|
||||
opts.Get("url", &request->url);
|
||||
if (!request->url.is_valid()) {
|
||||
args->ThrowTypeError("Invalid URL");
|
||||
return gin::Handle<SimpleURLLoaderWrapper>();
|
||||
return {};
|
||||
}
|
||||
request->site_for_cookies = net::SiteForCookies::FromUrl(request->url);
|
||||
opts.Get("referrer", &request->referrer);
|
||||
@@ -607,7 +607,7 @@ gin::Handle<SimpleURLLoaderWrapper> SimpleURLLoaderWrapper::Create(
|
||||
if (!net::HttpUtil::IsValidHeaderName(it.first) ||
|
||||
!net::HttpUtil::IsValidHeaderValue(it.second)) {
|
||||
args->ThrowTypeError("Invalid header name or value");
|
||||
return gin::Handle<SimpleURLLoaderWrapper>();
|
||||
return {};
|
||||
}
|
||||
request->headers.SetHeader(it.first, it.second);
|
||||
}
|
||||
|
||||
@@ -49,10 +49,10 @@ v8::Local<v8::Value> GetHiddenValue(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> value;
|
||||
v8::Maybe<bool> result = object->HasPrivate(context, privateKey);
|
||||
if (!(result.IsJust() && result.FromJust()))
|
||||
return v8::Local<v8::Value>();
|
||||
return {};
|
||||
if (object->GetPrivate(context, privateKey).ToLocal(&value))
|
||||
return value;
|
||||
return v8::Local<v8::Value>();
|
||||
return {};
|
||||
}
|
||||
|
||||
void SetHiddenValue(v8::Isolate* isolate,
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace asar {
|
||||
|
||||
namespace {
|
||||
|
||||
typedef std::map<base::FilePath, std::shared_ptr<Archive>> ArchiveMap;
|
||||
using ArchiveMap = std::map<base::FilePath, std::shared_ptr<Archive>>;
|
||||
|
||||
const base::FilePath::CharType kAsarExtension[] = FILE_PATH_LITERAL(".asar");
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ base::span<const APIPermissionInfo::InitInfo> GetPermissionInfos() {
|
||||
return base::make_span(permissions_to_register);
|
||||
}
|
||||
base::span<const Alias> GetPermissionAliases() {
|
||||
return base::span<const Alias>();
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -38,12 +38,12 @@ class ElectronPermissionMessageProvider
|
||||
const ElectronPermissionMessageProvider&) = delete;
|
||||
|
||||
// PermissionMessageProvider implementation.
|
||||
extensions::PermissionMessages GetPermissionMessages(
|
||||
[[nodiscard]] extensions::PermissionMessages GetPermissionMessages(
|
||||
const extensions::PermissionIDSet& permissions) const override {
|
||||
return extensions::PermissionMessages();
|
||||
}
|
||||
|
||||
bool IsPrivilegeIncrease(
|
||||
[[nodiscard]] bool IsPrivilegeIncrease(
|
||||
const extensions::PermissionSet& granted_permissions,
|
||||
const extensions::PermissionSet& requested_permissions,
|
||||
extensions::Manifest::Type extension_type) const override {
|
||||
@@ -52,10 +52,10 @@ class ElectronPermissionMessageProvider
|
||||
return false;
|
||||
}
|
||||
|
||||
extensions::PermissionIDSet GetAllPermissionIDs(
|
||||
[[nodiscard]] extensions::PermissionIDSet GetAllPermissionIDs(
|
||||
const extensions::PermissionSet& permissions,
|
||||
extensions::Manifest::Type extension_type) const override {
|
||||
return extensions::PermissionIDSet();
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -113,7 +113,7 @@ extensions::URLPatternSet
|
||||
ElectronExtensionsClient::GetPermittedChromeSchemeHosts(
|
||||
const extensions::Extension* extension,
|
||||
const extensions::APIPermissionSet& api_permissions) const {
|
||||
return extensions::URLPatternSet();
|
||||
return {};
|
||||
}
|
||||
|
||||
bool ElectronExtensionsClient::IsScriptableURL(const GURL& url,
|
||||
|
||||
@@ -200,6 +200,8 @@ struct Converter<blink::WebInputEvent::Modifiers> {
|
||||
}
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
std::vector<std::string_view> ModifiersToArray(int modifiers) {
|
||||
std::vector<std::string_view> modifier_strings;
|
||||
|
||||
@@ -210,6 +212,8 @@ std::vector<std::string_view> ModifiersToArray(int modifiers) {
|
||||
return modifier_strings;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
blink::WebInputEvent::Type GetWebInputEventType(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val) {
|
||||
blink::WebInputEvent::Type type = blink::WebInputEvent::Type::kUndefined;
|
||||
@@ -300,6 +304,8 @@ bool Converter<blink::WebKeyboardEvent>::FromV8(v8::Isolate* isolate,
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
int GetKeyLocationCode(const blink::WebInputEvent& key) {
|
||||
// https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/events/keyboard_event.h;l=46;drc=1ff6437e65b183e673b7b4f25060b74dc2ba5c37
|
||||
enum KeyLocationCode {
|
||||
@@ -318,6 +324,8 @@ int GetKeyLocationCode(const blink::WebInputEvent& key) {
|
||||
return kDomKeyLocationStandard;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
v8::Local<v8::Value> Converter<blink::WebKeyboardEvent>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const blink::WebKeyboardEvent& in) {
|
||||
|
||||
@@ -54,7 +54,7 @@ struct OffscreenReleaseHolderMonitor {
|
||||
holder_ = nullptr;
|
||||
}
|
||||
|
||||
bool IsTextureReleased() const { return holder_ == nullptr; }
|
||||
[[nodiscard]] bool IsTextureReleased() const { return holder_ == nullptr; }
|
||||
|
||||
v8::Persistent<v8::Value>* CreatePersistent(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> value) {
|
||||
|
||||
@@ -88,7 +88,7 @@ class RefCountedGlobal
|
||||
RefCountedGlobal(v8::Isolate* isolate, v8::Local<v8::Value> value)
|
||||
: handle_(isolate, value.As<T>()) {}
|
||||
|
||||
bool IsAlive() const { return !handle_.IsEmpty(); }
|
||||
[[nodiscard]] bool IsAlive() const { return !handle_.IsEmpty(); }
|
||||
|
||||
v8::Local<T> NewHandle(v8::Isolate* isolate) const {
|
||||
return v8::Local<T>::New(isolate, handle_);
|
||||
|
||||
@@ -64,7 +64,7 @@ v8::Local<v8::Value> CallMethod(v8::Isolate* isolate,
|
||||
return scope.Escape(CustomEmit(isolate, v8_object, method_name,
|
||||
std::forward<Args>(args)...));
|
||||
else
|
||||
return v8::Local<v8::Value>();
|
||||
return {};
|
||||
}
|
||||
|
||||
template <typename T, typename... Args>
|
||||
|
||||
@@ -101,7 +101,7 @@ class TrackableObject : public TrackableObjectBase, public EventEmitter<T> {
|
||||
if (weak_map_)
|
||||
return weak_map_->Values(isolate);
|
||||
else
|
||||
return std::vector<v8::Local<v8::Object>>();
|
||||
return {};
|
||||
}
|
||||
|
||||
// Removes this instance from the weak map.
|
||||
|
||||
@@ -25,16 +25,15 @@ v8::Local<v8::Object> WrappableBase::GetWrapper() const {
|
||||
if (!wrapper_.IsEmpty())
|
||||
return v8::Local<v8::Object>::New(isolate_, wrapper_);
|
||||
else
|
||||
return v8::Local<v8::Object>();
|
||||
return {};
|
||||
}
|
||||
|
||||
v8::MaybeLocal<v8::Object> WrappableBase::GetWrapper(
|
||||
v8::Isolate* isolate) const {
|
||||
if (!wrapper_.IsEmpty())
|
||||
return v8::MaybeLocal<v8::Object>(
|
||||
v8::Local<v8::Object>::New(isolate, wrapper_));
|
||||
return {v8::Local<v8::Object>::New(isolate, wrapper_)};
|
||||
else
|
||||
return v8::MaybeLocal<v8::Object>();
|
||||
return {};
|
||||
}
|
||||
|
||||
void WrappableBase::InitWithArgs(gin::Arguments* args) {
|
||||
|
||||
@@ -18,7 +18,7 @@ class HeapSnapshotOutputStream : public v8::OutputStream {
|
||||
DCHECK(file_);
|
||||
}
|
||||
|
||||
bool IsComplete() const { return is_complete_; }
|
||||
[[nodiscard]] bool IsComplete() const { return is_complete_; }
|
||||
|
||||
// v8::OutputStream
|
||||
int GetChunkSize() override { return 65536; }
|
||||
|
||||
@@ -25,7 +25,7 @@ std::optional<bool> IsUnsignedOrAdHocSigned(SecCodeRef code) {
|
||||
}
|
||||
if (status != errSecSuccess) {
|
||||
OSSTATUS_LOG(ERROR, status) << "SecCodeCopyStaticCode";
|
||||
return std::optional<bool>();
|
||||
return {};
|
||||
}
|
||||
// Copy the signing info from the SecStaticCodeRef.
|
||||
base::apple::ScopedCFTypeRef<CFDictionaryRef> signing_info;
|
||||
@@ -34,7 +34,7 @@ std::optional<bool> IsUnsignedOrAdHocSigned(SecCodeRef code) {
|
||||
signing_info.InitializeInto());
|
||||
if (status != errSecSuccess) {
|
||||
OSSTATUS_LOG(ERROR, status) << "SecCodeCopySigningInformation";
|
||||
return std::optional<bool>();
|
||||
return {};
|
||||
}
|
||||
// Look up the code signing flags. If the flags are absent treat this as
|
||||
// unsigned. This decision is consistent with the StaticCode source:
|
||||
@@ -51,7 +51,7 @@ std::optional<bool> IsUnsignedOrAdHocSigned(SecCodeRef code) {
|
||||
long long flags;
|
||||
if (!CFNumberGetValue(signing_info_flags, kCFNumberLongLongType, &flags)) {
|
||||
LOG(ERROR) << "CFNumberGetValue";
|
||||
return std::optional<bool>();
|
||||
return {};
|
||||
}
|
||||
if (static_cast<uint32_t>(flags) & kSecCodeSignatureAdhoc) {
|
||||
return true;
|
||||
|
||||
@@ -190,7 +190,7 @@ v8::MaybeLocal<v8::Promise> HostImportModuleDynamically(
|
||||
v8::Local<v8::FixedArray> v8_import_assertions) {
|
||||
if (node::Environment::GetCurrent(context) == nullptr) {
|
||||
if (electron::IsBrowserProcess() || electron::IsUtilityProcess())
|
||||
return v8::MaybeLocal<v8::Promise>();
|
||||
return {};
|
||||
return blink::V8Initializer::HostImportModuleDynamically(
|
||||
context, v8_host_defined_options, v8_referrer_resource_url,
|
||||
v8_specifier, v8_import_assertions);
|
||||
|
||||
@@ -27,7 +27,7 @@ v8::MaybeLocal<v8::Value> CompileAndCall(
|
||||
context, id, parameters, node::Realm::GetCurrent(context));
|
||||
|
||||
if (compiled.IsEmpty())
|
||||
return v8::MaybeLocal<v8::Value>();
|
||||
return {};
|
||||
|
||||
v8::Local<v8::Function> fn = compiled.ToLocalChecked().As<v8::Function>();
|
||||
v8::MaybeLocal<v8::Value> ret = fn->Call(
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
namespace platform_util {
|
||||
|
||||
namespace {
|
||||
|
||||
struct TrashItemResult {
|
||||
bool success;
|
||||
std::string error;
|
||||
@@ -24,6 +26,8 @@ TrashItemResult TrashItemOnBlockingThread(const base::FilePath& full_path) {
|
||||
return {success, error};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void TrashItem(const base::FilePath& full_path,
|
||||
base::OnceCallback<void(bool, const std::string&)> callback) {
|
||||
// XXX: is continue_on_shutdown right?
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
|
||||
namespace electron::util {
|
||||
|
||||
namespace {
|
||||
|
||||
struct ScaleFactorPair {
|
||||
const char* name;
|
||||
float scale;
|
||||
@@ -55,6 +57,22 @@ float GetScaleFactorFromPath(const base::FilePath& path) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
bool AddImageSkiaRepFromPath(gfx::ImageSkia* image,
|
||||
const base::FilePath& path,
|
||||
double scale_factor) {
|
||||
std::string file_contents;
|
||||
{
|
||||
electron::ScopedAllowBlockingForElectron allow_blocking;
|
||||
if (!asar::ReadFileToString(path, &file_contents))
|
||||
return false;
|
||||
}
|
||||
|
||||
return AddImageSkiaRepFromBuffer(image, base::as_byte_span(file_contents), 0,
|
||||
0, scale_factor);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool AddImageSkiaRepFromPNG(gfx::ImageSkia* image,
|
||||
const base::span<const uint8_t> data,
|
||||
double scale_factor) {
|
||||
@@ -114,20 +132,6 @@ bool AddImageSkiaRepFromBuffer(gfx::ImageSkia* image,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AddImageSkiaRepFromPath(gfx::ImageSkia* image,
|
||||
const base::FilePath& path,
|
||||
double scale_factor) {
|
||||
std::string file_contents;
|
||||
{
|
||||
electron::ScopedAllowBlockingForElectron allow_blocking;
|
||||
if (!asar::ReadFileToString(path, &file_contents))
|
||||
return false;
|
||||
}
|
||||
|
||||
return AddImageSkiaRepFromBuffer(image, base::as_byte_span(file_contents), 0,
|
||||
0, scale_factor);
|
||||
}
|
||||
|
||||
bool PopulateImageSkiaRepsFromPath(gfx::ImageSkia* image,
|
||||
const base::FilePath& path) {
|
||||
bool succeed = false;
|
||||
|
||||
@@ -152,7 +152,7 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext(
|
||||
"Electron contextBridge recursion depth exceeded. "
|
||||
"Nested objects "
|
||||
"deeper than 1000 are not supported.")));
|
||||
return v8::MaybeLocal<v8::Value>();
|
||||
return {};
|
||||
}
|
||||
|
||||
// Certain primitives always use the current contexts prototype and we can
|
||||
@@ -209,7 +209,7 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext(
|
||||
|
||||
if (!v8::Function::New(destination_context, ProxyFunctionWrapper, state)
|
||||
.ToLocal(&proxy_func))
|
||||
return v8::MaybeLocal<v8::Value>();
|
||||
return {};
|
||||
SetPrivate(destination_context, proxy_func.As<v8::Object>(),
|
||||
context_bridge::kOriginalFunctionPrivateKey, func);
|
||||
object_cache->CacheProxiedObject(value, proxy_func);
|
||||
@@ -372,11 +372,11 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext(
|
||||
arr->Get(source_context, i).ToLocalChecked(), value, object_cache,
|
||||
support_dynamic_properties, recursion_depth + 1, error_target);
|
||||
if (value_for_array.IsEmpty())
|
||||
return v8::MaybeLocal<v8::Value>();
|
||||
return {};
|
||||
|
||||
if (!IsTrue(cloned_arr->Set(destination_context, static_cast<int>(i),
|
||||
value_for_array.ToLocalChecked()))) {
|
||||
return v8::MaybeLocal<v8::Value>();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
object_cache->CacheProxiedObject(value, cloned_arr);
|
||||
@@ -408,7 +408,7 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext(
|
||||
object_value, source_context, destination_context, object_cache,
|
||||
support_dynamic_properties, recursion_depth + 1, error_target);
|
||||
if (passed_value.IsEmpty())
|
||||
return v8::MaybeLocal<v8::Value>();
|
||||
return {};
|
||||
return v8::MaybeLocal<v8::Value>(passed_value.ToLocalChecked());
|
||||
}
|
||||
|
||||
@@ -421,7 +421,7 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext(
|
||||
v8::Context::Scope error_scope(error_context);
|
||||
// V8 serializer will throw an error if required
|
||||
if (!gin::ConvertFromV8(error_context->GetIsolate(), value, &ret)) {
|
||||
return v8::MaybeLocal<v8::Value>();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -651,7 +651,7 @@ v8::MaybeLocal<v8::Object> CreateProxyForAPI(
|
||||
object_cache, support_dynamic_properties, recursion_depth + 1,
|
||||
error_target);
|
||||
if (passed_value.IsEmpty())
|
||||
return v8::MaybeLocal<v8::Object>();
|
||||
return {};
|
||||
proxy.Set(key, passed_value.ToLocalChecked());
|
||||
}
|
||||
|
||||
@@ -659,6 +659,8 @@ v8::MaybeLocal<v8::Object> CreateProxyForAPI(
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
void ExposeAPIInWorld(v8::Isolate* isolate,
|
||||
const int world_id,
|
||||
const std::string& key,
|
||||
@@ -819,6 +821,8 @@ bool IsCalledFromMainWorld(v8::Isolate* isolate) {
|
||||
return isolate->GetCurrentContext() == main_context;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace electron
|
||||
|
||||
@@ -107,11 +107,11 @@ class IPCRenderer final : public gin::Wrappable<IPCRenderer>,
|
||||
v8::Local<v8::Value> arguments) {
|
||||
if (!electron_ipc_remote_) {
|
||||
thrower.ThrowError(kIPCMethodCalledAfterContextReleasedError);
|
||||
return v8::Local<v8::Promise>();
|
||||
return {};
|
||||
}
|
||||
blink::CloneableMessage message;
|
||||
if (!electron::SerializeV8Value(isolate, arguments, &message)) {
|
||||
return v8::Local<v8::Promise>();
|
||||
return {};
|
||||
}
|
||||
gin_helper::Promise<blink::CloneableMessage> p(isolate);
|
||||
auto handle = p.GetHandle();
|
||||
@@ -189,11 +189,11 @@ class IPCRenderer final : public gin::Wrappable<IPCRenderer>,
|
||||
v8::Local<v8::Value> arguments) {
|
||||
if (!electron_ipc_remote_) {
|
||||
thrower.ThrowError(kIPCMethodCalledAfterContextReleasedError);
|
||||
return v8::Local<v8::Value>();
|
||||
return {};
|
||||
}
|
||||
blink::CloneableMessage message;
|
||||
if (!electron::SerializeV8Value(isolate, arguments, &message)) {
|
||||
return v8::Local<v8::Value>();
|
||||
return {};
|
||||
}
|
||||
|
||||
blink::CloneableMessage result;
|
||||
|
||||
@@ -58,7 +58,7 @@ class SpellCheckClient::SpellcheckRequest {
|
||||
SpellcheckRequest& operator=(const SpellcheckRequest&) = delete;
|
||||
~SpellcheckRequest() = default;
|
||||
|
||||
const std::u16string& text() const { return text_; }
|
||||
[[nodiscard]] const std::u16string& text() const { return text_; }
|
||||
blink::WebTextCheckingCompletion* completion() { return completion_.get(); }
|
||||
std::vector<Word>& wordlist() { return word_list_; }
|
||||
|
||||
|
||||
@@ -592,7 +592,7 @@ class WebFrameRenderer final : public gin::Wrappable<WebFrameRenderer>,
|
||||
|
||||
content::RenderFrame* render_frame;
|
||||
if (!MaybeGetRenderFrame(isolate, "insertCSS", &render_frame))
|
||||
return std::u16string();
|
||||
return {};
|
||||
|
||||
blink::WebFrame* web_frame = render_frame->GetWebFrame();
|
||||
if (web_frame->IsWebLocalFrame()) {
|
||||
@@ -602,7 +602,7 @@ class WebFrameRenderer final : public gin::Wrappable<WebFrameRenderer>,
|
||||
css_origin)
|
||||
.Utf16();
|
||||
}
|
||||
return std::u16string();
|
||||
return {};
|
||||
}
|
||||
|
||||
void RemoveInsertedCSS(v8::Isolate* isolate, const std::u16string& key) {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "electron/shell/renderer/electron_api_service_impl.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
@@ -32,7 +33,7 @@ namespace electron {
|
||||
|
||||
namespace {
|
||||
|
||||
const char kIpcKey[] = "ipcNative";
|
||||
constexpr std::string_view kIpcKey = "ipcNative";
|
||||
|
||||
// Gets the private object under kIpcKey
|
||||
v8::Local<v8::Object> GetIpcObject(v8::Local<v8::Context> context) {
|
||||
@@ -44,7 +45,7 @@ v8::Local<v8::Object> GetIpcObject(v8::Local<v8::Context> context) {
|
||||
global_object->GetPrivate(context, private_binding_key).ToLocalChecked();
|
||||
if (value.IsEmpty() || !value->IsObject()) {
|
||||
LOG(ERROR) << "Attempted to get the 'ipcNative' object but it was missing";
|
||||
return v8::Local<v8::Object>();
|
||||
return {};
|
||||
}
|
||||
return value->ToObject(context).ToLocalChecked();
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ namespace electron {
|
||||
|
||||
namespace {
|
||||
|
||||
const char kEmitProcessEventKey[] = "emit-process-event";
|
||||
const char kBindingCacheKey[] = "native-binding-cache";
|
||||
constexpr std::string_view kEmitProcessEventKey = "emit-process-event";
|
||||
constexpr std::string_view kBindingCacheKey = "native-binding-cache";
|
||||
|
||||
v8::Local<v8::Object> GetBindingCache(v8::Isolate* isolate) {
|
||||
auto context = isolate->GetCurrentContext();
|
||||
@@ -86,7 +86,7 @@ v8::Local<v8::Value> CreatePreloadScript(v8::Isolate* isolate,
|
||||
auto maybe_script = v8::Script::Compile(context, source);
|
||||
v8::Local<v8::Script> script;
|
||||
if (!maybe_script.ToLocal(&script))
|
||||
return v8::Local<v8::Value>();
|
||||
return {};
|
||||
return script->Run(context).ToLocalChecked();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ blink::WebElement PrintRenderFrameHelperDelegate::GetPdfElement(
|
||||
return plugin_element;
|
||||
}
|
||||
#endif // BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
||||
return blink::WebElement();
|
||||
return {};
|
||||
}
|
||||
|
||||
bool PrintRenderFrameHelperDelegate::IsPrintPreviewEnabled() {
|
||||
|
||||
@@ -131,7 +131,7 @@ class ChromePdfInternalPluginDelegate final
|
||||
~ChromePdfInternalPluginDelegate() override = default;
|
||||
|
||||
// `pdf::PdfInternalPluginDelegate`:
|
||||
bool IsAllowedOrigin(const url::Origin& origin) const override {
|
||||
[[nodiscard]] bool IsAllowedOrigin(const url::Origin& origin) const override {
|
||||
return origin.scheme() == extensions::kExtensionScheme &&
|
||||
origin.host() == extension_misc::kPdfExtensionId;
|
||||
}
|
||||
@@ -455,7 +455,7 @@ v8::Local<v8::Object> RendererClientBase::GetScriptableObject(
|
||||
if (container_manager)
|
||||
return container_manager->GetScriptableObject(plugin_element, isolate);
|
||||
#endif
|
||||
return v8::Local<v8::Object>();
|
||||
return {};
|
||||
}
|
||||
|
||||
std::unique_ptr<blink::WebPrescientNetworking>
|
||||
|
||||
Reference in New Issue
Block a user