mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
* chore: bump chromium in DEPS to 149.0.7779.0 * chore: bump chromium in DEPS to 149.0.7781.0 * 7726883: Add secondary label support to SimpleMenuModel and update views_examples Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7726883 Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com> * chore: update patches (trivial only) Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com> * fix: IWYU for base/logging.h Upstream is removing transitive includes of base/logging.h as part of crbug.com/499476145. Several CLs landed in this roll that required adding explicit includes across Electron source and patches. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7732103 Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7735571 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 7732482: [bedrock] Create BrowserProcess setters for system tray icons Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7732482 Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com> * chore: update patches (trivial only) Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com> * 7739543: Add RenderWidgetHostView::HasSavedFrame Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7739543 Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com> * chore: bump chromium in DEPS to 149.0.7783.0 * chore: bump chromium in DEPS to 149.0.7789.0 * chore: update patches (trivial only) * 7703728: DedicatedWorker: Enforce same-origin check for main script fetch. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7703728 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 7720140: Remove GetPrefServiceForContext from ExtensionsBrowserClient Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7720140 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: update patches (trivial only) * 7728375: Disable reentrancy by default except for Android and iOS Upstream changed the default ObserverList reentrancy policy from kAllowReentrancy to kDisallowReentrancy. Electron's observer lists are re-entered when macOS AppKit delivers synchronous window notifications (e.g. windowDidResignMain: during windowDidChangeOcclusionState:) because JS event handlers can trigger window state changes mid-iteration. Explicitly opt into kAllowReentrancy for now. A follow-up should convert synchronous Emit calls in window observer callbacks to EmitEventSoon to eliminate the reentrancy. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7728375 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: bump chromium in DEPS to 149.0.7791.1 * chore: update patches (trivial only) * 7696481: [pdf] Rename PdfViewerStreamManager to MimeHandlerStreamManager Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7696481 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 7745796: Printing: Remove parameter from ShowScriptedPrintPreview() interface Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7745796 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 7688714: [Lens / Cookies] Grant secure cookie exemptions for Lens side panel Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7688714 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 7752609: don't show glic button for non-normal BWIs. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7752609 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * 7749860: [media] Remove VideoFrame::WrapSharedImage with coded_size Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7749860 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: bump chromium in DEPS to 149.0.7793.0 * chore: bump chromium in DEPS to 149.0.7795.0 * chore: bump chromium in DEPS to 149.0.7797.0 * chore: update patches * chore: remove upstreamed patches - fix_pass_trigger_for_global_shortcuts_on_wayland.patch: https://chromium-review.googlesource.com/c/chromium/src/+/7620219 - gin_mark_argumentholder_as_cppgc_stack_allocated.patch: https://chromium-review.googlesource.com/c/chromium/src/+/7728865 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: bump chromium in DEPS to 149.0.7798.0 * chore: update filenames.libcxx.gni * 7760061: Reland Reland Add a client-side decorated frame view for non-browser widgets on Linux Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7760061 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 7760945: Rename WebString::UTF8ConversionMode to Utf8ConversionMode Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7760945 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: update patches * chore: remove upstreamed patches - patches/devtools_frontend/fix_context_selector_not_showing_execution_contexts.patch: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7761316 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 7719004: [extensions] Gate dict-format mime_types_handler parsing Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7719004 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 7716681: [pdf] Introduce MimeHandlerStreamDelegate and plumb ownership Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7716681 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 7725342: Rename WebString::FromUTF8 to FromUtf8 in Blink Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7725342 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 7615475: Add a native frame view for non-browser widgets on Linux Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7615475 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 7735248: Move ManifestV2ExperimentManager to //extensions Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7735248 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 7725187: linux: set env FC_FONTATIONS and EGL_PLATFORM early Move Ozone pre-init from ElectronBrowserMainParts::PreEarlyInitialization() to ElectronMainDelegate::PreSandboxStartup() to match upstream's rename and relocation. The call has to run before threads are created. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7725187 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * 7743280: Introduce client ID for network throttling conditions. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7743280 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore: disable ml-kem node test incompatible with BoringSSL test-crypto-pqc-key-objects-ml-kem: BoringSSL's ML-KEM support is inconsistent with the test's OpenSSL-version-based assumptions. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * test: update V8 serialization wire format version to 16 V8 14.9 (Chromium 149) bumped the serialization wire format from version 15 to 16. Update the hardcoded expected bytes in the test-v8-serdes.js test. Remove this patch once upstream Node.js catches up via its next V8 roll. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Samuel Maddock <samuelmaddock@electronjs.org> Co-authored-by: Claude <svc-devxp-claude@slack-corp.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: clavin <clavin@electronjs.org>
251 lines
7.3 KiB
C++
251 lines
7.3 KiB
C++
// Copyright (c) 2013 GitHub, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "shell/browser/browser.h"
|
|
|
|
#include <fcntl.h>
|
|
#include <stdlib.h>
|
|
|
|
#if BUILDFLAG(IS_LINUX)
|
|
#include <gio/gio.h>
|
|
#include <gtk/gtk.h>
|
|
#endif
|
|
|
|
#include "base/command_line.h"
|
|
#include "base/environment.h"
|
|
#include "base/logging.h"
|
|
#include "base/process/launch.h"
|
|
#include "base/strings/strcat.h"
|
|
#include "base/strings/utf_string_conversions.h"
|
|
#include "electron/electron_version.h"
|
|
#include "shell/browser/javascript_environment.h"
|
|
#include "shell/browser/native_window.h"
|
|
#include "shell/browser/window_list.h"
|
|
#include "shell/common/application_info.h"
|
|
#include "shell/common/gin_converters/login_item_settings_converter.h"
|
|
#include "shell/common/thread_restrictions.h"
|
|
|
|
#if BUILDFLAG(IS_LINUX)
|
|
#include "shell/browser/linux/unity_service.h"
|
|
#endif
|
|
|
|
namespace electron {
|
|
|
|
namespace {
|
|
|
|
const char kXdgSettings[] = "xdg-settings";
|
|
const char kXdgSettingsDefaultSchemeHandler[] = "default-url-scheme-handler";
|
|
|
|
// The use of the ForTesting flavors is a hack workaround to avoid having to
|
|
// patch these as friends into the associated guard classes.
|
|
class [[maybe_unused, nodiscard]] LaunchXdgUtilityScopedAllowBaseSyncPrimitives
|
|
: public base::ScopedAllowBaseSyncPrimitivesForTesting {};
|
|
|
|
bool LaunchXdgUtility(const std::vector<std::string>& argv, int* exit_code) {
|
|
*exit_code = EXIT_FAILURE;
|
|
int devnull = open("/dev/null", O_RDONLY);
|
|
if (devnull < 0)
|
|
return false;
|
|
|
|
base::LaunchOptions options;
|
|
options.fds_to_remap.emplace_back(devnull, STDIN_FILENO);
|
|
|
|
base::Process process = base::LaunchProcess(argv, options);
|
|
close(devnull);
|
|
|
|
if (!process.IsValid())
|
|
return false;
|
|
LaunchXdgUtilityScopedAllowBaseSyncPrimitives allow_base_sync_primitives;
|
|
return process.WaitForExit(exit_code);
|
|
}
|
|
|
|
std::optional<std::string> GetXdgAppOutput(
|
|
const std::vector<std::string>& argv) {
|
|
std::string reply;
|
|
int success_code;
|
|
ScopedAllowBlockingForElectron allow_blocking;
|
|
bool ran_ok = base::GetAppOutputWithExitCode(base::CommandLine(argv), &reply,
|
|
&success_code);
|
|
|
|
if (!ran_ok || success_code != EXIT_SUCCESS)
|
|
return {};
|
|
|
|
return reply;
|
|
}
|
|
|
|
bool SetDefaultWebClient(const std::string& protocol) {
|
|
auto env = base::Environment::Create();
|
|
|
|
std::vector<std::string> argv = {kXdgSettings, "set"};
|
|
if (!protocol.empty()) {
|
|
argv.emplace_back(kXdgSettingsDefaultSchemeHandler);
|
|
argv.emplace_back(protocol);
|
|
}
|
|
|
|
if (std::optional<std::string> desktop_name = env->GetVar("CHROME_DESKTOP")) {
|
|
argv.emplace_back(desktop_name.value());
|
|
} else {
|
|
return false;
|
|
}
|
|
|
|
int exit_code;
|
|
bool ran_ok = LaunchXdgUtility(argv, &exit_code);
|
|
return ran_ok && exit_code == EXIT_SUCCESS;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
void Browser::AddRecentDocument(const base::FilePath& path) {}
|
|
|
|
std::vector<std::string> Browser::GetRecentDocuments() {
|
|
return std::vector<std::string>();
|
|
}
|
|
|
|
void Browser::ClearRecentDocuments() {}
|
|
|
|
bool Browser::SetAsDefaultProtocolClient(const std::string& protocol,
|
|
gin::Arguments* args) {
|
|
if (!IsValidProtocolScheme(protocol))
|
|
return false;
|
|
|
|
return SetDefaultWebClient(protocol);
|
|
}
|
|
|
|
bool Browser::IsDefaultProtocolClient(const std::string& protocol,
|
|
gin::Arguments* args) {
|
|
if (!IsValidProtocolScheme(protocol))
|
|
return false;
|
|
|
|
auto env = base::Environment::Create();
|
|
|
|
std::vector<std::string> argv = {kXdgSettings, "check",
|
|
kXdgSettingsDefaultSchemeHandler, protocol};
|
|
if (std::optional<std::string> desktop_name = env->GetVar("CHROME_DESKTOP")) {
|
|
argv.emplace_back(desktop_name.value());
|
|
} else {
|
|
return false;
|
|
}
|
|
// Allow any reply that starts with "yes".
|
|
const std::optional<std::string> output = GetXdgAppOutput(argv);
|
|
return output && output->starts_with("yes");
|
|
}
|
|
|
|
// Todo implement
|
|
bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
|
|
gin::Arguments* args) {
|
|
return false;
|
|
}
|
|
|
|
std::u16string Browser::GetApplicationNameForProtocol(const GURL& url) {
|
|
const auto scheme = std::string{url.scheme()}; // gio can't use string_view
|
|
auto* app_info = g_app_info_get_default_for_uri_scheme(scheme.c_str());
|
|
if (!app_info)
|
|
return {};
|
|
|
|
const char* const name = g_app_info_get_display_name(app_info);
|
|
const std::u16string u16name = base::UTF8ToUTF16(name);
|
|
g_object_unref(app_info);
|
|
return u16name;
|
|
}
|
|
|
|
bool Browser::SetBadgeCount(std::optional<int> count) {
|
|
if (IsUnityRunning() && count.has_value()) {
|
|
unity::SetDownloadCount(count.value());
|
|
badge_count_ = count.value();
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
void Browser::SetLoginItemSettings(LoginItemSettings settings) {}
|
|
|
|
v8::Local<v8::Value> Browser::GetLoginItemSettings(
|
|
const LoginItemSettings& options) {
|
|
LoginItemSettings settings;
|
|
return gin::ConvertToV8(JavascriptEnvironment::GetIsolate(), settings);
|
|
}
|
|
|
|
std::string Browser::GetExecutableFileVersion() const {
|
|
return GetApplicationVersion();
|
|
}
|
|
|
|
std::string Browser::GetExecutableFileProductName() const {
|
|
return GetApplicationName();
|
|
}
|
|
|
|
bool Browser::IsUnityRunning() {
|
|
return unity::IsRunning();
|
|
}
|
|
|
|
bool Browser::IsEmojiPanelSupported() {
|
|
return false;
|
|
}
|
|
|
|
void Browser::ShowAboutPanel() {
|
|
const auto& opts = about_panel_options_;
|
|
|
|
GtkWidget* dialogWidget = gtk_about_dialog_new();
|
|
GtkAboutDialog* dialog = GTK_ABOUT_DIALOG(dialogWidget);
|
|
|
|
const std::string* str;
|
|
const base::ListValue* list;
|
|
|
|
if ((str = opts.FindString("applicationName"))) {
|
|
gtk_about_dialog_set_program_name(dialog, str->c_str());
|
|
}
|
|
if ((str = opts.FindString("applicationVersion"))) {
|
|
gtk_about_dialog_set_version(dialog, str->c_str());
|
|
}
|
|
if ((str = opts.FindString("copyright"))) {
|
|
gtk_about_dialog_set_copyright(dialog, str->c_str());
|
|
}
|
|
if ((str = opts.FindString("website"))) {
|
|
gtk_about_dialog_set_website(dialog, str->c_str());
|
|
}
|
|
if ((str = opts.FindString("iconPath"))) {
|
|
GError* error = nullptr;
|
|
constexpr int width = 64; // width of about panel icon in pixels
|
|
constexpr int height = 64; // height of about panel icon in pixels
|
|
|
|
// set preserve_aspect_ratio to true
|
|
GdkPixbuf* icon =
|
|
gdk_pixbuf_new_from_file_at_size(str->c_str(), width, height, &error);
|
|
if (error != nullptr) {
|
|
LOG(INFO) << error->message;
|
|
g_clear_error(&error);
|
|
} else {
|
|
gtk_about_dialog_set_logo(dialog, icon);
|
|
g_clear_object(&icon);
|
|
}
|
|
}
|
|
|
|
if ((list = opts.FindList("authors"))) {
|
|
std::vector<const char*> cstrs;
|
|
for (const auto& authorVal : *list) {
|
|
if (authorVal.is_string()) {
|
|
cstrs.push_back(authorVal.GetString().c_str());
|
|
}
|
|
}
|
|
if (cstrs.empty()) {
|
|
LOG(WARNING) << "No author strings found in 'authors' array";
|
|
} else {
|
|
cstrs.push_back(nullptr); // null-terminated char* array
|
|
gtk_about_dialog_set_authors(dialog, cstrs.data());
|
|
}
|
|
}
|
|
|
|
// destroy the widget when it closes
|
|
g_signal_connect_swapped(dialogWidget, "response",
|
|
G_CALLBACK(gtk_widget_destroy), dialogWidget);
|
|
|
|
gtk_widget_show_all(dialogWidget);
|
|
}
|
|
|
|
void Browser::SetAboutPanelOptions(base::DictValue options) {
|
|
about_panel_options_ = std::move(options);
|
|
}
|
|
|
|
} // namespace electron
|