mirror of
https://github.com/electron/electron.git
synced 2026-02-26 03:01:17 -05:00
* chore: bump chromium in DEPS to 110.0.5461.0
* chore: bump chromium in DEPS to 110.0.5463.0
* chore: bump chromium in DEPS to 110.0.5465.0
* chore: bump chromium in DEPS to 110.0.5467.0
* chore: bump chromium in DEPS to 110.0.5469.0
* chore: bump chromium in DEPS to 110.0.5471.0
* chore: bump chromium in DEPS to 110.0.5473.0
* chore: bump chromium in DEPS to 110.0.5475.0
* chore: bump chromium in DEPS to 110.0.5477.0
* chore: bump chromium in DEPS to 110.0.5479.0
* chore: bump chromium in DEPS to 110.0.5481.0
* chore: bump chromium in DEPS to 110.0.5481.4
* chore: bump chromium in DEPS to 110.0.5478.5
* chore: update patches
* 4074449: Add gl::FrameData to software path
https://chromium-review.googlesource.com/c/chromium/src/+/4074449
(cherry picked from commit 1f61be81384b3e22b8af8f9221a7e5ef9a4d95cb)
* fixup! 4074449: Add gl::FrameData to software path
(cherry picked from commit 2316ec931ec9cb1d4ade43df2f3663ef155c5a61)
* 4074449: Add gl::FrameData to software path
This commit also reformatted the two files in this patch. The only
change here is the addition of the |data| arg to |OnSwapBuffers|.
https://chromium-review.googlesource.com/c/chromium/src/+/4074449
(cherry picked from commit aa2504ee6b4e3a2eaf3348eb535ef8121dd6cc3b)
* 4081108: task posting v3: remove task_runner_util{.h,_unittest.cc}
https://chromium-review.googlesource.com/c/chromium/src/+/4081108
(cherry picked from commit fce317513ee15138351f8b1bdf062250d97f57b9)
* 4081108: task posting v3: remove task_runner_util{.h,_unittest.cc}
https://chromium-review.googlesource.com/c/chromium/src/+/4081108
(cherry picked from commit cb14d9f5df300020a3b8d11078656763b428789e)
* chore: add missing RefCountedMemory include
(cherry picked from commit 893a1da1ed5a461e0e46abecab2a2de545ab543b)
* 4025927: [Code Health] Migrate e/c/manifest.cc to base::Value::Dict interface
https://chromium-review.googlesource.com/c/chromium/src/+/4025927
(cherry picked from commit f9e1ce44bdbe1c199881daef2799164737e2d39d)
* 4072471: Rename Mixed Download Blocking to Insecure Download Blocking
https://chromium-review.googlesource.com/c/chromium/src/+/4072471
(cherry picked from commit e191d7526d3821ace54717ce7c8a5e95df542135)
* 4060548: Remove base::Value::GetListDeprecated().
https://chromium-review.googlesource.com/c/chromium/src/+/4060548
(cherry picked from commit f76cb2bcb4d1772c596c7e8dc5be27024e2b9cfe)
* 4032656: hid: Abstract HidSystemTrayIcon class for profiles' HID connections
https://chromium-review.googlesource.com/c/chromium/src/+/4032656
(cherry picked from commit 9737692d016d726f277c7a6ac6ec919b18820cba)
* 3903024: hid: Add connection count tracking methods for HidDelegate
https://chromium-review.googlesource.com/c/chromium/src/+/3903024
(cherry picked from commit a0299046cd3cedb1c84b4ecf867089fce9304861)
* 4076211: Turn FrameTreeNode::frame_tree into raw_ref.
https://chromium-review.googlesource.com/c/chromium/src/+/4076211
(cherry picked from commit 6cca422b421013ce166779cc9687d50301ac3280)
* 4112537: Remove DictionaryPrefUpdate.
https://chromium-review.googlesource.com/c/chromium/src/+/4112537
(cherry picked from commit ec8e8f75deed5da760c75267c5575509923ae7e4)
* 3835037: Add new slides media session actions to Picture-in-Picture window
https://chromium-review.googlesource.com/c/chromium/src/+/3835037
(cherry picked from commit 7dc35729bce450b365b8d211536a275e8e3f0a08)
* 4065264: [Extensions] Add a new side panel view type
https://chromium-review.googlesource.com/c/chromium/src/+/4065264
(cherry picked from commit c6c3c3ff8289c87a6ca831ff23100b3dde74eddf)
* 4085814: [Test Automation] Move NativeWindowTracker to ui/views
https://chromium-review.googlesource.com/c/chromium/src/+/4085814
(cherry picked from commit ffbe5437139752f507bef4c66cc958e6dcef3bce)
* chore: disable Microtask queues per WindowAgent.
see https://chromium-review.googlesource.com/c/chromium/src/+/4003663
(cherry picked from commit 0ffa9df410a27236ed73b07d5b36c84783b0f9d1)
* fixup: disable Microtask queues per WindowAgent.
(cherry picked from commit 438be771dd)
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: Calvin Watford <cwatford@slack-corp.com>
Co-authored-by: clavin <clavin@electronjs.org>
Co-authored-by: Jeremy Rose <jeremya@chromium.org>
230 lines
6.7 KiB
C++
230 lines
6.7 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>
|
|
|
|
#include "base/command_line.h"
|
|
#include "base/environment.h"
|
|
#include "base/process/launch.h"
|
|
#include "electron/electron_version.h"
|
|
#include "shell/browser/native_window.h"
|
|
#include "shell/browser/window_list.h"
|
|
#include "shell/common/application_info.h"
|
|
#include "shell/common/thread_restrictions.h"
|
|
|
|
#if BUILDFLAG(IS_LINUX)
|
|
#include "shell/browser/linux/unity_service.h"
|
|
#include "ui/gtk/gtk_util.h" // nogncheck
|
|
#endif
|
|
|
|
namespace electron {
|
|
|
|
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 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);
|
|
}
|
|
|
|
absl::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 absl::optional<std::string>();
|
|
|
|
return absl::make_optional(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);
|
|
}
|
|
std::string desktop_name;
|
|
if (!env->GetVar("CHROME_DESKTOP", &desktop_name)) {
|
|
return false;
|
|
}
|
|
argv.emplace_back(desktop_name);
|
|
|
|
int exit_code;
|
|
bool ran_ok = LaunchXdgUtility(argv, &exit_code);
|
|
return ran_ok && exit_code == EXIT_SUCCESS;
|
|
}
|
|
|
|
void Browser::AddRecentDocument(const base::FilePath& path) {}
|
|
|
|
void Browser::ClearRecentDocuments() {}
|
|
|
|
bool Browser::SetAsDefaultProtocolClient(const std::string& protocol,
|
|
gin::Arguments* args) {
|
|
return SetDefaultWebClient(protocol);
|
|
}
|
|
|
|
bool Browser::IsDefaultProtocolClient(const std::string& protocol,
|
|
gin::Arguments* args) {
|
|
auto env = base::Environment::Create();
|
|
|
|
if (protocol.empty())
|
|
return false;
|
|
|
|
std::string desktop_name;
|
|
if (!env->GetVar("CHROME_DESKTOP", &desktop_name))
|
|
return false;
|
|
const std::vector<std::string> argv = {kXdgSettings, "check",
|
|
kXdgSettingsDefaultSchemeHandler,
|
|
protocol, desktop_name};
|
|
const auto output = GetXdgAppOutput(argv);
|
|
if (!output)
|
|
return false;
|
|
|
|
// Allow any reply that starts with "yes".
|
|
return base::StartsWith(output.value(), "yes", base::CompareCase::SENSITIVE);
|
|
}
|
|
|
|
// Todo implement
|
|
bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
|
|
gin::Arguments* args) {
|
|
return false;
|
|
}
|
|
|
|
std::u16string Browser::GetApplicationNameForProtocol(const GURL& url) {
|
|
const std::vector<std::string> argv = {
|
|
"xdg-mime", "query", "default",
|
|
std::string("x-scheme-handler/") + url.scheme()};
|
|
|
|
return base::ASCIIToUTF16(GetXdgAppOutput(argv).value_or(std::string()));
|
|
}
|
|
|
|
bool Browser::SetBadgeCount(absl::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) {}
|
|
|
|
Browser::LoginItemSettings Browser::GetLoginItemSettings(
|
|
const LoginItemSettings& options) {
|
|
return LoginItemSettings();
|
|
}
|
|
|
|
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_;
|
|
|
|
if (!opts.is_dict()) {
|
|
LOG(WARNING) << "Called showAboutPanel(), but didn't use "
|
|
"setAboutPanelSettings() first";
|
|
return;
|
|
}
|
|
|
|
GtkWidget* dialogWidget = gtk_about_dialog_new();
|
|
GtkAboutDialog* dialog = GTK_ABOUT_DIALOG(dialogWidget);
|
|
|
|
const std::string* str;
|
|
const base::Value* val;
|
|
|
|
if ((str = opts.FindStringKey("applicationName"))) {
|
|
gtk_about_dialog_set_program_name(dialog, str->c_str());
|
|
}
|
|
if ((str = opts.FindStringKey("applicationVersion"))) {
|
|
gtk_about_dialog_set_version(dialog, str->c_str());
|
|
}
|
|
if ((str = opts.FindStringKey("copyright"))) {
|
|
gtk_about_dialog_set_copyright(dialog, str->c_str());
|
|
}
|
|
if ((str = opts.FindStringKey("website"))) {
|
|
gtk_about_dialog_set_website(dialog, str->c_str());
|
|
}
|
|
if ((str = opts.FindStringKey("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) {
|
|
g_warning("%s", error->message);
|
|
g_clear_error(&error);
|
|
} else {
|
|
gtk_about_dialog_set_logo(dialog, icon);
|
|
g_clear_object(&icon);
|
|
}
|
|
}
|
|
|
|
if ((val = opts.FindListKey("authors"))) {
|
|
std::vector<const char*> cstrs;
|
|
for (const auto& authorVal : val->GetList()) {
|
|
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());
|
|
}
|
|
}
|
|
|
|
gtk_dialog_run(GTK_DIALOG(dialog));
|
|
gtk_widget_destroy(dialogWidget);
|
|
}
|
|
|
|
void Browser::SetAboutPanelOptions(base::Value::Dict options) {
|
|
about_panel_options_ = base::Value(std::move(options));
|
|
}
|
|
|
|
} // namespace electron
|