2014-10-31 18:17:05 +00:00
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
2014-04-25 09:49:37 +00:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-05-02 15:43:23 +00:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/browser.h"
|
2013-05-02 15:43:23 +00:00
|
|
|
|
2020-05-21 15:53:44 +00:00
|
|
|
#include <memory>
|
2019-05-02 12:05:37 +00:00
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
|
2023-10-16 16:25:11 +00:00
|
|
|
#import <ServiceManagement/ServiceManagement.h>
|
|
|
|
|
2023-07-16 14:14:43 +00:00
|
|
|
#include "base/apple/bridging.h"
|
2023-05-23 19:58:58 +00:00
|
|
|
#include "base/apple/bundle_locations.h"
|
chore: bump chromium to 118.0.5975.0 (main) (#39531)
* chore: bump chromium in DEPS to 118.0.5951.0
* chore: update printing.patch
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4727894
No logic changes, but patch needed to be manually re-applied due to upstream code shear
* chore: update port_autofill_colors_to_the_color_pipeline.patch
No manual changes; patch applied with fuzz
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5953.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5955.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5957.0
* chore: update patches
* chore: include path of native_web_keyboard_event.h
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4758689
* chore: remove reference to eextensions/browser/notification-types.h
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4771627
* chore: update references to renamed upstream field NativeWebKeyboardEvent.skip_if_unhandled (formerly known as skip_in_browser
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4758689
Need a second pair of eyes on this commit. In particular the reference in content_converter.cc, skipInBrowser, seems to not be set or documented anywhere? Is this unused/vestigal code?
* chore: sync signature of ElectronExtensionsBrowserClient::IsValidContext() to upstream change
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4784198
* chore: add auto_pip_setting_helper.[cc,h] to chromium_src build
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4688277
Exiting upstream code used by chromium_src now depends on this new upstream class
* chore: bump chromium in DEPS to 118.0.5959.0
* chore: update add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
Xref: add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
manually adjust patch to minor upstream chagnes
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5961.0
* chore: bump chromium in DEPS to 118.0.5963.0
* chore: update patches
* 4780994: Rename various base files to "apple" since iOS uses them too
https://chromium-review.googlesource.com/c/chromium/src/+/4780994
* Many files moved from `mac` -> `apple`
This commit follows a handful of CLs that simply rename files/symbols to change `mac`
to `apple`
to signify their use across both macOS and iOS:
- 4784010: Move scoped_nsautorelease_pool to base/apple, leave a forwarding header
- 4790744: Move foundation_util to base/apple, leave a forwarding header
- 4790741: Move scoped_cftypreref to base/apple, leave a forwarding header
- 4787627: Move and rename macOS+iOS base/ files in PA to "apple"
- 4780399: Move OSStatus logging to base/apple
- 4787387: Remove forwarding headers
- 4781113: Rename message_pump_mac to "apple" because iOS uses it too
* fixup minor patch update error
A function param got dropped from this patch somewhere earlier
* chore: bump chromium in DEPS to 118.0.5965.2
* chore: update patches
* 4799213: Move ScopedTypeRef and ScopedCFTypeRef into base::apple::
https://chromium-review.googlesource.com/c/chromium/src/+/4799213
* Fix removed include to BrowserContext
In crrev.com/c/4767962 an include to BrowserContext was removed,
which was necessary for compilation. This broke only for us because
"chrome/browser/profiles/profile.h" includes that class, but we remove
all references to profiles.
* chore: bump chromium in DEPS to 118.0.5967.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5969.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5971.0
* chore: bump chromium in DEPS to 118.0.5973.0
* chore: update patches
* 4772121: [OOPIF PDF] Replace PDFWebContentsHelper with PDFDocumentHelper
https://chromium-review.googlesource.com/c/chromium/src/+/4772121
* 4811164: [Extensions] Do some cleanup in ChromeManagementAPIDelegate.
https://chromium-review.googlesource.com/c/chromium/src/+/4811164
* 4809488: Remove duplicate dnd functionality between Web and Renderer prefs
https://chromium-review.googlesource.com/c/chromium/src/+/4809488
Given that this is no longer an option of web preferences, we should
consider deprecating this option and then removing it.
* chore: bump chromium in DEPS to 118.0.5975.0
* chore: update patches
* fixup! chore: add auto_pip_settings_helper.{cc|h} to chromium_src build
* Reland "[windows] Remove RegKey::DeleteEmptyKey"
Refs https://chromium-review.googlesource.com/c/chromium/src/+/4813255
* Ensure StrCat means StrCat
Refs https://chromium-review.googlesource.com/c/chromium/src/+/1117180
* fixup! Remove RegKey::DeleteEmptyKey
* Consistently reject large p and large q in DH
Refs https://boringssl-review.googlesource.com/c/boringssl/+/62226
---------
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: clavin <clavin@electronjs.org>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
2023-09-01 06:54:59 +00:00
|
|
|
#include "base/apple/scoped_cftyperef.h"
|
2023-01-10 11:19:00 +00:00
|
|
|
#include "base/i18n/rtl.h"
|
2016-07-06 18:43:44 +00:00
|
|
|
#include "base/mac/mac_util.h"
|
2022-11-17 19:59:23 +00:00
|
|
|
#include "base/mac/mac_util.mm"
|
2016-07-02 01:36:11 +00:00
|
|
|
#include "base/strings/sys_string_conversions.h"
|
2023-01-10 11:19:00 +00:00
|
|
|
#include "chrome/browser/browser_process.h"
|
2024-02-14 17:33:32 +00:00
|
|
|
#include "net/base/apple/url_conversions.h"
|
2021-01-21 05:45:06 +00:00
|
|
|
#include "shell/browser/badging/badge_manager.h"
|
2023-10-16 16:25:11 +00:00
|
|
|
#include "shell/browser/javascript_environment.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/browser/mac/dict_util.h"
|
|
|
|
#include "shell/browser/mac/electron_application.h"
|
|
|
|
#include "shell/browser/mac/electron_application_delegate.h"
|
|
|
|
#include "shell/browser/native_window.h"
|
|
|
|
#include "shell/browser/window_list.h"
|
2021-01-04 20:58:31 +00:00
|
|
|
#include "shell/common/api/electron_api_native_image.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/common/application_info.h"
|
2020-06-30 19:22:30 +00:00
|
|
|
#include "shell/common/gin_converters/image_converter.h"
|
2024-03-22 13:00:21 +00:00
|
|
|
#include "shell/common/gin_converters/login_item_settings_converter.h"
|
2019-10-24 05:47:58 +00:00
|
|
|
#include "shell/common/gin_helper/arguments.h"
|
2020-03-11 16:07:01 +00:00
|
|
|
#include "shell/common/gin_helper/dictionary.h"
|
|
|
|
#include "shell/common/gin_helper/error_thrower.h"
|
2019-11-01 06:10:32 +00:00
|
|
|
#include "shell/common/gin_helper/promise.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/common/platform_util.h"
|
2023-06-20 16:24:03 +00:00
|
|
|
#include "ui/base/resource/resource_scale_factor.h"
|
2018-03-06 07:12:10 +00:00
|
|
|
#include "ui/gfx/image/image.h"
|
2016-05-23 15:49:46 +00:00
|
|
|
#include "url/gurl.h"
|
2013-05-02 15:43:23 +00:00
|
|
|
|
|
|
|
namespace electron {
|
|
|
|
|
2020-06-30 19:22:30 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
NSString* GetAppPathForProtocol(const GURL& url) {
|
|
|
|
NSURL* ns_url = [NSURL
|
|
|
|
URLWithString:base::SysUTF8ToNSString(url.possibly_invalid_spec())];
|
chore: bump chromium to 118.0.5975.0 (main) (#39531)
* chore: bump chromium in DEPS to 118.0.5951.0
* chore: update printing.patch
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4727894
No logic changes, but patch needed to be manually re-applied due to upstream code shear
* chore: update port_autofill_colors_to_the_color_pipeline.patch
No manual changes; patch applied with fuzz
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5953.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5955.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5957.0
* chore: update patches
* chore: include path of native_web_keyboard_event.h
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4758689
* chore: remove reference to eextensions/browser/notification-types.h
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4771627
* chore: update references to renamed upstream field NativeWebKeyboardEvent.skip_if_unhandled (formerly known as skip_in_browser
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4758689
Need a second pair of eyes on this commit. In particular the reference in content_converter.cc, skipInBrowser, seems to not be set or documented anywhere? Is this unused/vestigal code?
* chore: sync signature of ElectronExtensionsBrowserClient::IsValidContext() to upstream change
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4784198
* chore: add auto_pip_setting_helper.[cc,h] to chromium_src build
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4688277
Exiting upstream code used by chromium_src now depends on this new upstream class
* chore: bump chromium in DEPS to 118.0.5959.0
* chore: update add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
Xref: add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
manually adjust patch to minor upstream chagnes
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5961.0
* chore: bump chromium in DEPS to 118.0.5963.0
* chore: update patches
* 4780994: Rename various base files to "apple" since iOS uses them too
https://chromium-review.googlesource.com/c/chromium/src/+/4780994
* Many files moved from `mac` -> `apple`
This commit follows a handful of CLs that simply rename files/symbols to change `mac`
to `apple`
to signify their use across both macOS and iOS:
- 4784010: Move scoped_nsautorelease_pool to base/apple, leave a forwarding header
- 4790744: Move foundation_util to base/apple, leave a forwarding header
- 4790741: Move scoped_cftypreref to base/apple, leave a forwarding header
- 4787627: Move and rename macOS+iOS base/ files in PA to "apple"
- 4780399: Move OSStatus logging to base/apple
- 4787387: Remove forwarding headers
- 4781113: Rename message_pump_mac to "apple" because iOS uses it too
* fixup minor patch update error
A function param got dropped from this patch somewhere earlier
* chore: bump chromium in DEPS to 118.0.5965.2
* chore: update patches
* 4799213: Move ScopedTypeRef and ScopedCFTypeRef into base::apple::
https://chromium-review.googlesource.com/c/chromium/src/+/4799213
* Fix removed include to BrowserContext
In crrev.com/c/4767962 an include to BrowserContext was removed,
which was necessary for compilation. This broke only for us because
"chrome/browser/profiles/profile.h" includes that class, but we remove
all references to profiles.
* chore: bump chromium in DEPS to 118.0.5967.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5969.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5971.0
* chore: bump chromium in DEPS to 118.0.5973.0
* chore: update patches
* 4772121: [OOPIF PDF] Replace PDFWebContentsHelper with PDFDocumentHelper
https://chromium-review.googlesource.com/c/chromium/src/+/4772121
* 4811164: [Extensions] Do some cleanup in ChromeManagementAPIDelegate.
https://chromium-review.googlesource.com/c/chromium/src/+/4811164
* 4809488: Remove duplicate dnd functionality between Web and Renderer prefs
https://chromium-review.googlesource.com/c/chromium/src/+/4809488
Given that this is no longer an option of web preferences, we should
consider deprecating this option and then removing it.
* chore: bump chromium in DEPS to 118.0.5975.0
* chore: update patches
* fixup! chore: add auto_pip_settings_helper.{cc|h} to chromium_src build
* Reland "[windows] Remove RegKey::DeleteEmptyKey"
Refs https://chromium-review.googlesource.com/c/chromium/src/+/4813255
* Ensure StrCat means StrCat
Refs https://chromium-review.googlesource.com/c/chromium/src/+/1117180
* fixup! Remove RegKey::DeleteEmptyKey
* Consistently reject large p and large q in DH
Refs https://boringssl-review.googlesource.com/c/boringssl/+/62226
---------
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: clavin <clavin@electronjs.org>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
2023-09-01 06:54:59 +00:00
|
|
|
base::apple::ScopedCFTypeRef<CFErrorRef> out_err;
|
2020-06-30 19:22:30 +00:00
|
|
|
|
chore: bump chromium to 118.0.5975.0 (main) (#39531)
* chore: bump chromium in DEPS to 118.0.5951.0
* chore: update printing.patch
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4727894
No logic changes, but patch needed to be manually re-applied due to upstream code shear
* chore: update port_autofill_colors_to_the_color_pipeline.patch
No manual changes; patch applied with fuzz
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5953.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5955.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5957.0
* chore: update patches
* chore: include path of native_web_keyboard_event.h
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4758689
* chore: remove reference to eextensions/browser/notification-types.h
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4771627
* chore: update references to renamed upstream field NativeWebKeyboardEvent.skip_if_unhandled (formerly known as skip_in_browser
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4758689
Need a second pair of eyes on this commit. In particular the reference in content_converter.cc, skipInBrowser, seems to not be set or documented anywhere? Is this unused/vestigal code?
* chore: sync signature of ElectronExtensionsBrowserClient::IsValidContext() to upstream change
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4784198
* chore: add auto_pip_setting_helper.[cc,h] to chromium_src build
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4688277
Exiting upstream code used by chromium_src now depends on this new upstream class
* chore: bump chromium in DEPS to 118.0.5959.0
* chore: update add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
Xref: add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
manually adjust patch to minor upstream chagnes
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5961.0
* chore: bump chromium in DEPS to 118.0.5963.0
* chore: update patches
* 4780994: Rename various base files to "apple" since iOS uses them too
https://chromium-review.googlesource.com/c/chromium/src/+/4780994
* Many files moved from `mac` -> `apple`
This commit follows a handful of CLs that simply rename files/symbols to change `mac`
to `apple`
to signify their use across both macOS and iOS:
- 4784010: Move scoped_nsautorelease_pool to base/apple, leave a forwarding header
- 4790744: Move foundation_util to base/apple, leave a forwarding header
- 4790741: Move scoped_cftypreref to base/apple, leave a forwarding header
- 4787627: Move and rename macOS+iOS base/ files in PA to "apple"
- 4780399: Move OSStatus logging to base/apple
- 4787387: Remove forwarding headers
- 4781113: Rename message_pump_mac to "apple" because iOS uses it too
* fixup minor patch update error
A function param got dropped from this patch somewhere earlier
* chore: bump chromium in DEPS to 118.0.5965.2
* chore: update patches
* 4799213: Move ScopedTypeRef and ScopedCFTypeRef into base::apple::
https://chromium-review.googlesource.com/c/chromium/src/+/4799213
* Fix removed include to BrowserContext
In crrev.com/c/4767962 an include to BrowserContext was removed,
which was necessary for compilation. This broke only for us because
"chrome/browser/profiles/profile.h" includes that class, but we remove
all references to profiles.
* chore: bump chromium in DEPS to 118.0.5967.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5969.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5971.0
* chore: bump chromium in DEPS to 118.0.5973.0
* chore: update patches
* 4772121: [OOPIF PDF] Replace PDFWebContentsHelper with PDFDocumentHelper
https://chromium-review.googlesource.com/c/chromium/src/+/4772121
* 4811164: [Extensions] Do some cleanup in ChromeManagementAPIDelegate.
https://chromium-review.googlesource.com/c/chromium/src/+/4811164
* 4809488: Remove duplicate dnd functionality between Web and Renderer prefs
https://chromium-review.googlesource.com/c/chromium/src/+/4809488
Given that this is no longer an option of web preferences, we should
consider deprecating this option and then removing it.
* chore: bump chromium in DEPS to 118.0.5975.0
* chore: update patches
* fixup! chore: add auto_pip_settings_helper.{cc|h} to chromium_src build
* Reland "[windows] Remove RegKey::DeleteEmptyKey"
Refs https://chromium-review.googlesource.com/c/chromium/src/+/4813255
* Ensure StrCat means StrCat
Refs https://chromium-review.googlesource.com/c/chromium/src/+/1117180
* fixup! Remove RegKey::DeleteEmptyKey
* Consistently reject large p and large q in DH
Refs https://boringssl-review.googlesource.com/c/boringssl/+/62226
---------
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: clavin <clavin@electronjs.org>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
2023-09-01 06:54:59 +00:00
|
|
|
base::apple::ScopedCFTypeRef<CFURLRef> openingApp(
|
2023-07-16 14:14:43 +00:00
|
|
|
LSCopyDefaultApplicationURLForURL(base::apple::NSToCFPtrCast(ns_url),
|
|
|
|
kLSRolesAll, out_err.InitializeInto()));
|
2020-06-30 19:22:30 +00:00
|
|
|
|
|
|
|
if (out_err) {
|
|
|
|
// likely kLSApplicationNotFoundErr
|
|
|
|
return nullptr;
|
|
|
|
}
|
2023-07-16 14:14:43 +00:00
|
|
|
NSString* app_path = [base::apple::CFToNSPtrCast(openingApp.get()) path];
|
2020-06-30 19:22:30 +00:00
|
|
|
return app_path;
|
|
|
|
}
|
|
|
|
|
|
|
|
gfx::Image GetApplicationIconForProtocol(NSString* _Nonnull app_path) {
|
|
|
|
NSImage* image = [[NSWorkspace sharedWorkspace] iconForFile:app_path];
|
|
|
|
gfx::Image icon(image);
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
|
2021-03-16 16:18:45 +00:00
|
|
|
std::u16string GetAppDisplayNameForProtocol(NSString* app_path) {
|
2020-06-30 19:22:30 +00:00
|
|
|
NSString* app_display_name =
|
|
|
|
[[NSFileManager defaultManager] displayNameAtPath:app_path];
|
|
|
|
return base::SysNSStringToUTF16(app_display_name);
|
|
|
|
}
|
|
|
|
|
2022-11-17 19:59:23 +00:00
|
|
|
#if !IS_MAS_BUILD()
|
|
|
|
bool CheckLoginItemStatus(bool* is_hidden) {
|
|
|
|
base::mac::LoginItemsFileList login_items;
|
|
|
|
if (!login_items.Initialize())
|
|
|
|
return false;
|
|
|
|
|
chore: bump chromium to 118.0.5975.0 (main) (#39531)
* chore: bump chromium in DEPS to 118.0.5951.0
* chore: update printing.patch
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4727894
No logic changes, but patch needed to be manually re-applied due to upstream code shear
* chore: update port_autofill_colors_to_the_color_pipeline.patch
No manual changes; patch applied with fuzz
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5953.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5955.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5957.0
* chore: update patches
* chore: include path of native_web_keyboard_event.h
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4758689
* chore: remove reference to eextensions/browser/notification-types.h
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4771627
* chore: update references to renamed upstream field NativeWebKeyboardEvent.skip_if_unhandled (formerly known as skip_in_browser
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4758689
Need a second pair of eyes on this commit. In particular the reference in content_converter.cc, skipInBrowser, seems to not be set or documented anywhere? Is this unused/vestigal code?
* chore: sync signature of ElectronExtensionsBrowserClient::IsValidContext() to upstream change
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4784198
* chore: add auto_pip_setting_helper.[cc,h] to chromium_src build
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4688277
Exiting upstream code used by chromium_src now depends on this new upstream class
* chore: bump chromium in DEPS to 118.0.5959.0
* chore: update add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
Xref: add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
manually adjust patch to minor upstream chagnes
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5961.0
* chore: bump chromium in DEPS to 118.0.5963.0
* chore: update patches
* 4780994: Rename various base files to "apple" since iOS uses them too
https://chromium-review.googlesource.com/c/chromium/src/+/4780994
* Many files moved from `mac` -> `apple`
This commit follows a handful of CLs that simply rename files/symbols to change `mac`
to `apple`
to signify their use across both macOS and iOS:
- 4784010: Move scoped_nsautorelease_pool to base/apple, leave a forwarding header
- 4790744: Move foundation_util to base/apple, leave a forwarding header
- 4790741: Move scoped_cftypreref to base/apple, leave a forwarding header
- 4787627: Move and rename macOS+iOS base/ files in PA to "apple"
- 4780399: Move OSStatus logging to base/apple
- 4787387: Remove forwarding headers
- 4781113: Rename message_pump_mac to "apple" because iOS uses it too
* fixup minor patch update error
A function param got dropped from this patch somewhere earlier
* chore: bump chromium in DEPS to 118.0.5965.2
* chore: update patches
* 4799213: Move ScopedTypeRef and ScopedCFTypeRef into base::apple::
https://chromium-review.googlesource.com/c/chromium/src/+/4799213
* Fix removed include to BrowserContext
In crrev.com/c/4767962 an include to BrowserContext was removed,
which was necessary for compilation. This broke only for us because
"chrome/browser/profiles/profile.h" includes that class, but we remove
all references to profiles.
* chore: bump chromium in DEPS to 118.0.5967.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5969.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5971.0
* chore: bump chromium in DEPS to 118.0.5973.0
* chore: update patches
* 4772121: [OOPIF PDF] Replace PDFWebContentsHelper with PDFDocumentHelper
https://chromium-review.googlesource.com/c/chromium/src/+/4772121
* 4811164: [Extensions] Do some cleanup in ChromeManagementAPIDelegate.
https://chromium-review.googlesource.com/c/chromium/src/+/4811164
* 4809488: Remove duplicate dnd functionality between Web and Renderer prefs
https://chromium-review.googlesource.com/c/chromium/src/+/4809488
Given that this is no longer an option of web preferences, we should
consider deprecating this option and then removing it.
* chore: bump chromium in DEPS to 118.0.5975.0
* chore: update patches
* fixup! chore: add auto_pip_settings_helper.{cc|h} to chromium_src build
* Reland "[windows] Remove RegKey::DeleteEmptyKey"
Refs https://chromium-review.googlesource.com/c/chromium/src/+/4813255
* Ensure StrCat means StrCat
Refs https://chromium-review.googlesource.com/c/chromium/src/+/1117180
* fixup! Remove RegKey::DeleteEmptyKey
* Consistently reject large p and large q in DH
Refs https://boringssl-review.googlesource.com/c/boringssl/+/62226
---------
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: clavin <clavin@electronjs.org>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
2023-09-01 06:54:59 +00:00
|
|
|
base::apple::ScopedCFTypeRef<LSSharedFileListItemRef> item(
|
2022-11-17 19:59:23 +00:00
|
|
|
login_items.GetLoginItemForMainApp());
|
|
|
|
if (!item.get())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (is_hidden)
|
2023-11-14 21:21:32 +00:00
|
|
|
*is_hidden = base::mac::IsHiddenLoginItem(item.get());
|
2022-11-17 19:59:23 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2023-10-16 16:25:11 +00:00
|
|
|
|
2024-03-22 13:00:21 +00:00
|
|
|
LoginItemSettings GetLoginItemSettingsDeprecated() {
|
|
|
|
LoginItemSettings settings;
|
2023-10-16 16:25:11 +00:00
|
|
|
settings.open_at_login = CheckLoginItemStatus(&settings.open_as_hidden);
|
|
|
|
settings.restore_state = base::mac::WasLaunchedAsLoginItemRestoreState();
|
|
|
|
settings.opened_at_login = base::mac::WasLaunchedAsLoginOrResumeItem();
|
|
|
|
settings.opened_as_hidden = base::mac::WasLaunchedAsHiddenLoginItem();
|
|
|
|
return settings;
|
|
|
|
}
|
2022-11-17 19:59:23 +00:00
|
|
|
#endif
|
|
|
|
|
2020-06-30 19:22:30 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
v8::Local<v8::Promise> Browser::GetApplicationInfoForProtocol(
|
|
|
|
v8::Isolate* isolate,
|
|
|
|
const GURL& url) {
|
|
|
|
gin_helper::Promise<gin_helper::Dictionary> promise(isolate);
|
|
|
|
v8::Local<v8::Promise> handle = promise.GetHandle();
|
2023-08-21 01:43:41 +00:00
|
|
|
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
|
2020-06-30 19:22:30 +00:00
|
|
|
|
|
|
|
NSString* ns_app_path = GetAppPathForProtocol(url);
|
|
|
|
|
|
|
|
if (!ns_app_path) {
|
|
|
|
promise.RejectWithErrorMessage(
|
|
|
|
"Unable to retrieve installation path to app");
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
2021-03-16 16:18:45 +00:00
|
|
|
std::u16string app_path = base::SysNSStringToUTF16(ns_app_path);
|
|
|
|
std::u16string app_display_name = GetAppDisplayNameForProtocol(ns_app_path);
|
2020-06-30 19:22:30 +00:00
|
|
|
gfx::Image app_icon = GetApplicationIconForProtocol(ns_app_path);
|
|
|
|
|
|
|
|
dict.Set("name", app_display_name);
|
|
|
|
dict.Set("path", app_path);
|
|
|
|
dict.Set("icon", app_icon);
|
|
|
|
|
|
|
|
promise.Resolve(dict);
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
2021-05-06 22:01:04 +00:00
|
|
|
void Browser::SetShutdownHandler(base::RepeatingCallback<bool()> handler) {
|
2020-02-21 19:05:03 +00:00
|
|
|
[[AtomApplication sharedApplication] setShutdownHandler:std::move(handler)];
|
2018-02-05 07:13:35 +00:00
|
|
|
}
|
|
|
|
|
2020-07-28 23:43:43 +00:00
|
|
|
void Browser::Focus(gin::Arguments* args) {
|
2020-03-11 16:07:01 +00:00
|
|
|
gin_helper::Dictionary opts;
|
|
|
|
bool steal_focus = false;
|
|
|
|
|
|
|
|
if (args->GetNext(&opts)) {
|
|
|
|
gin_helper::ErrorThrower thrower(args->isolate());
|
|
|
|
if (!opts.Get("steal", &steal_focus)) {
|
|
|
|
thrower.ThrowError(
|
|
|
|
"Expected options object to contain a 'steal' boolean property");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[[AtomApplication sharedApplication] activateIgnoringOtherApps:steal_focus];
|
2013-05-30 11:24:47 +00:00
|
|
|
}
|
|
|
|
|
2016-01-29 11:30:19 +00:00
|
|
|
void Browser::Hide() {
|
2020-02-21 19:05:03 +00:00
|
|
|
[[AtomApplication sharedApplication] hide:nil];
|
2016-01-29 11:30:19 +00:00
|
|
|
}
|
|
|
|
|
2022-03-30 01:34:07 +00:00
|
|
|
bool Browser::IsHidden() {
|
|
|
|
return [[AtomApplication sharedApplication] isHidden];
|
|
|
|
}
|
|
|
|
|
2016-01-30 20:40:32 +00:00
|
|
|
void Browser::Show() {
|
2020-02-21 19:05:03 +00:00
|
|
|
[[AtomApplication sharedApplication] unhide:nil];
|
2016-01-30 20:40:32 +00:00
|
|
|
}
|
|
|
|
|
2014-11-17 05:05:06 +00:00
|
|
|
void Browser::AddRecentDocument(const base::FilePath& path) {
|
chore: bump chromium to 118.0.5975.0 (main) (#39531)
* chore: bump chromium in DEPS to 118.0.5951.0
* chore: update printing.patch
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4727894
No logic changes, but patch needed to be manually re-applied due to upstream code shear
* chore: update port_autofill_colors_to_the_color_pipeline.patch
No manual changes; patch applied with fuzz
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5953.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5955.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5957.0
* chore: update patches
* chore: include path of native_web_keyboard_event.h
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4758689
* chore: remove reference to eextensions/browser/notification-types.h
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4771627
* chore: update references to renamed upstream field NativeWebKeyboardEvent.skip_if_unhandled (formerly known as skip_in_browser
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4758689
Need a second pair of eyes on this commit. In particular the reference in content_converter.cc, skipInBrowser, seems to not be set or documented anywhere? Is this unused/vestigal code?
* chore: sync signature of ElectronExtensionsBrowserClient::IsValidContext() to upstream change
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4784198
* chore: add auto_pip_setting_helper.[cc,h] to chromium_src build
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4688277
Exiting upstream code used by chromium_src now depends on this new upstream class
* chore: bump chromium in DEPS to 118.0.5959.0
* chore: update add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
Xref: add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
manually adjust patch to minor upstream chagnes
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5961.0
* chore: bump chromium in DEPS to 118.0.5963.0
* chore: update patches
* 4780994: Rename various base files to "apple" since iOS uses them too
https://chromium-review.googlesource.com/c/chromium/src/+/4780994
* Many files moved from `mac` -> `apple`
This commit follows a handful of CLs that simply rename files/symbols to change `mac`
to `apple`
to signify their use across both macOS and iOS:
- 4784010: Move scoped_nsautorelease_pool to base/apple, leave a forwarding header
- 4790744: Move foundation_util to base/apple, leave a forwarding header
- 4790741: Move scoped_cftypreref to base/apple, leave a forwarding header
- 4787627: Move and rename macOS+iOS base/ files in PA to "apple"
- 4780399: Move OSStatus logging to base/apple
- 4787387: Remove forwarding headers
- 4781113: Rename message_pump_mac to "apple" because iOS uses it too
* fixup minor patch update error
A function param got dropped from this patch somewhere earlier
* chore: bump chromium in DEPS to 118.0.5965.2
* chore: update patches
* 4799213: Move ScopedTypeRef and ScopedCFTypeRef into base::apple::
https://chromium-review.googlesource.com/c/chromium/src/+/4799213
* Fix removed include to BrowserContext
In crrev.com/c/4767962 an include to BrowserContext was removed,
which was necessary for compilation. This broke only for us because
"chrome/browser/profiles/profile.h" includes that class, but we remove
all references to profiles.
* chore: bump chromium in DEPS to 118.0.5967.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5969.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5971.0
* chore: bump chromium in DEPS to 118.0.5973.0
* chore: update patches
* 4772121: [OOPIF PDF] Replace PDFWebContentsHelper with PDFDocumentHelper
https://chromium-review.googlesource.com/c/chromium/src/+/4772121
* 4811164: [Extensions] Do some cleanup in ChromeManagementAPIDelegate.
https://chromium-review.googlesource.com/c/chromium/src/+/4811164
* 4809488: Remove duplicate dnd functionality between Web and Renderer prefs
https://chromium-review.googlesource.com/c/chromium/src/+/4809488
Given that this is no longer an option of web preferences, we should
consider deprecating this option and then removing it.
* chore: bump chromium in DEPS to 118.0.5975.0
* chore: update patches
* fixup! chore: add auto_pip_settings_helper.{cc|h} to chromium_src build
* Reland "[windows] Remove RegKey::DeleteEmptyKey"
Refs https://chromium-review.googlesource.com/c/chromium/src/+/4813255
* Ensure StrCat means StrCat
Refs https://chromium-review.googlesource.com/c/chromium/src/+/1117180
* fixup! Remove RegKey::DeleteEmptyKey
* Consistently reject large p and large q in DH
Refs https://boringssl-review.googlesource.com/c/boringssl/+/62226
---------
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: clavin <clavin@electronjs.org>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
2023-09-01 06:54:59 +00:00
|
|
|
NSString* path_string = base::apple::FilePathToNSString(path);
|
2015-12-15 09:17:24 +00:00
|
|
|
if (!path_string)
|
|
|
|
return;
|
|
|
|
NSURL* u = [NSURL fileURLWithPath:path_string];
|
|
|
|
if (!u)
|
|
|
|
return;
|
2014-11-17 05:05:06 +00:00
|
|
|
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:u];
|
|
|
|
}
|
|
|
|
|
2014-11-17 08:13:47 +00:00
|
|
|
void Browser::ClearRecentDocuments() {
|
2015-12-30 00:35:54 +00:00
|
|
|
[[NSDocumentController sharedDocumentController] clearRecentDocuments:nil];
|
2014-11-17 08:13:47 +00:00
|
|
|
}
|
|
|
|
|
2016-08-16 05:54:30 +00:00
|
|
|
bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
|
2020-07-28 23:43:43 +00:00
|
|
|
gin::Arguments* args) {
|
2023-05-23 19:58:58 +00:00
|
|
|
NSString* identifier = [base::apple::MainBundle() bundleIdentifier];
|
2016-05-07 18:07:58 +00:00
|
|
|
if (!identifier)
|
|
|
|
return false;
|
|
|
|
|
2016-08-16 07:40:44 +00:00
|
|
|
if (!Browser::IsDefaultProtocolClient(protocol, args))
|
2016-05-08 17:50:17 +00:00
|
|
|
return false;
|
|
|
|
|
2016-05-07 18:07:58 +00:00
|
|
|
NSString* protocol_ns = [NSString stringWithUTF8String:protocol.c_str()];
|
2023-07-16 14:14:43 +00:00
|
|
|
CFStringRef protocol_cf = base::apple::NSToCFPtrCast(protocol_ns);
|
2023-07-01 20:22:55 +00:00
|
|
|
// TODO(codebytere): Use -[NSWorkspace URLForApplicationToOpenURL:] instead
|
|
|
|
#pragma clang diagnostic push
|
|
|
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
2016-05-07 18:07:58 +00:00
|
|
|
CFArrayRef bundleList = LSCopyAllHandlersForURLScheme(protocol_cf);
|
2023-07-01 20:22:55 +00:00
|
|
|
#pragma clang diagnostic pop
|
2016-05-07 18:07:58 +00:00
|
|
|
if (!bundleList) {
|
|
|
|
return false;
|
|
|
|
}
|
2016-06-18 13:26:26 +00:00
|
|
|
// On macOS, we can't query the default, but the handlers list seems to put
|
2016-05-07 18:07:58 +00:00
|
|
|
// Apple's defaults first, so we'll use the first option that isn't our bundle
|
|
|
|
CFStringRef other = nil;
|
2017-03-30 20:56:21 +00:00
|
|
|
for (CFIndex i = 0; i < CFArrayGetCount(bundleList); ++i) {
|
2018-04-20 18:47:04 +00:00
|
|
|
other =
|
chore: bump chromium to 118.0.5975.0 (main) (#39531)
* chore: bump chromium in DEPS to 118.0.5951.0
* chore: update printing.patch
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4727894
No logic changes, but patch needed to be manually re-applied due to upstream code shear
* chore: update port_autofill_colors_to_the_color_pipeline.patch
No manual changes; patch applied with fuzz
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5953.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5955.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5957.0
* chore: update patches
* chore: include path of native_web_keyboard_event.h
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4758689
* chore: remove reference to eextensions/browser/notification-types.h
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4771627
* chore: update references to renamed upstream field NativeWebKeyboardEvent.skip_if_unhandled (formerly known as skip_in_browser
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4758689
Need a second pair of eyes on this commit. In particular the reference in content_converter.cc, skipInBrowser, seems to not be set or documented anywhere? Is this unused/vestigal code?
* chore: sync signature of ElectronExtensionsBrowserClient::IsValidContext() to upstream change
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4784198
* chore: add auto_pip_setting_helper.[cc,h] to chromium_src build
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4688277
Exiting upstream code used by chromium_src now depends on this new upstream class
* chore: bump chromium in DEPS to 118.0.5959.0
* chore: update add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
Xref: add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
manually adjust patch to minor upstream chagnes
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5961.0
* chore: bump chromium in DEPS to 118.0.5963.0
* chore: update patches
* 4780994: Rename various base files to "apple" since iOS uses them too
https://chromium-review.googlesource.com/c/chromium/src/+/4780994
* Many files moved from `mac` -> `apple`
This commit follows a handful of CLs that simply rename files/symbols to change `mac`
to `apple`
to signify their use across both macOS and iOS:
- 4784010: Move scoped_nsautorelease_pool to base/apple, leave a forwarding header
- 4790744: Move foundation_util to base/apple, leave a forwarding header
- 4790741: Move scoped_cftypreref to base/apple, leave a forwarding header
- 4787627: Move and rename macOS+iOS base/ files in PA to "apple"
- 4780399: Move OSStatus logging to base/apple
- 4787387: Remove forwarding headers
- 4781113: Rename message_pump_mac to "apple" because iOS uses it too
* fixup minor patch update error
A function param got dropped from this patch somewhere earlier
* chore: bump chromium in DEPS to 118.0.5965.2
* chore: update patches
* 4799213: Move ScopedTypeRef and ScopedCFTypeRef into base::apple::
https://chromium-review.googlesource.com/c/chromium/src/+/4799213
* Fix removed include to BrowserContext
In crrev.com/c/4767962 an include to BrowserContext was removed,
which was necessary for compilation. This broke only for us because
"chrome/browser/profiles/profile.h" includes that class, but we remove
all references to profiles.
* chore: bump chromium in DEPS to 118.0.5967.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5969.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5971.0
* chore: bump chromium in DEPS to 118.0.5973.0
* chore: update patches
* 4772121: [OOPIF PDF] Replace PDFWebContentsHelper with PDFDocumentHelper
https://chromium-review.googlesource.com/c/chromium/src/+/4772121
* 4811164: [Extensions] Do some cleanup in ChromeManagementAPIDelegate.
https://chromium-review.googlesource.com/c/chromium/src/+/4811164
* 4809488: Remove duplicate dnd functionality between Web and Renderer prefs
https://chromium-review.googlesource.com/c/chromium/src/+/4809488
Given that this is no longer an option of web preferences, we should
consider deprecating this option and then removing it.
* chore: bump chromium in DEPS to 118.0.5975.0
* chore: update patches
* fixup! chore: add auto_pip_settings_helper.{cc|h} to chromium_src build
* Reland "[windows] Remove RegKey::DeleteEmptyKey"
Refs https://chromium-review.googlesource.com/c/chromium/src/+/4813255
* Ensure StrCat means StrCat
Refs https://chromium-review.googlesource.com/c/chromium/src/+/1117180
* fixup! Remove RegKey::DeleteEmptyKey
* Consistently reject large p and large q in DH
Refs https://boringssl-review.googlesource.com/c/boringssl/+/62226
---------
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: clavin <clavin@electronjs.org>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
2023-09-01 06:54:59 +00:00
|
|
|
base::apple::CFCast<CFStringRef>(CFArrayGetValueAtIndex(bundleList, i));
|
2018-04-20 18:47:04 +00:00
|
|
|
if (![identifier isEqualToString:(__bridge NSString*)other]) {
|
2016-05-07 18:07:58 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-20 03:16:37 +00:00
|
|
|
// No other app was found set it to none instead of setting it back to itself.
|
|
|
|
if ([identifier isEqualToString:(__bridge NSString*)other]) {
|
2023-07-16 14:14:43 +00:00
|
|
|
other = base::apple::NSToCFPtrCast(@"None");
|
2018-06-20 03:16:37 +00:00
|
|
|
}
|
|
|
|
|
2016-05-07 18:07:58 +00:00
|
|
|
OSStatus return_code = LSSetDefaultHandlerForURLScheme(protocol_cf, other);
|
|
|
|
return return_code == noErr;
|
2016-03-24 17:55:09 +00:00
|
|
|
}
|
|
|
|
|
2016-08-16 05:54:30 +00:00
|
|
|
bool Browser::SetAsDefaultProtocolClient(const std::string& protocol,
|
2020-07-28 23:43:43 +00:00
|
|
|
gin::Arguments* args) {
|
2016-03-21 18:24:25 +00:00
|
|
|
if (protocol.empty())
|
|
|
|
return false;
|
|
|
|
|
2023-05-23 19:58:58 +00:00
|
|
|
NSString* identifier = [base::apple::MainBundle() bundleIdentifier];
|
2016-03-21 18:24:25 +00:00
|
|
|
if (!identifier)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
NSString* protocol_ns = [NSString stringWithUTF8String:protocol.c_str()];
|
2023-07-16 14:14:43 +00:00
|
|
|
OSStatus return_code =
|
|
|
|
LSSetDefaultHandlerForURLScheme(base::apple::NSToCFPtrCast(protocol_ns),
|
|
|
|
base::apple::NSToCFPtrCast(identifier));
|
2016-03-21 18:24:25 +00:00
|
|
|
return return_code == noErr;
|
|
|
|
}
|
|
|
|
|
2016-08-16 05:54:30 +00:00
|
|
|
bool Browser::IsDefaultProtocolClient(const std::string& protocol,
|
2020-07-28 23:43:43 +00:00
|
|
|
gin::Arguments* args) {
|
2016-04-25 05:17:01 +00:00
|
|
|
if (protocol.empty())
|
|
|
|
return false;
|
|
|
|
|
2023-05-23 19:58:58 +00:00
|
|
|
NSString* identifier = [base::apple::MainBundle() bundleIdentifier];
|
2016-04-25 05:17:01 +00:00
|
|
|
if (!identifier)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
NSString* protocol_ns = [NSString stringWithUTF8String:protocol.c_str()];
|
2016-04-30 18:17:29 +00:00
|
|
|
|
2023-07-01 20:22:55 +00:00
|
|
|
// TODO(codebytere): Use -[NSWorkspace URLForApplicationToOpenURL:] instead
|
|
|
|
#pragma clang diagnostic push
|
|
|
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
chore: bump chromium to 118.0.5975.0 (main) (#39531)
* chore: bump chromium in DEPS to 118.0.5951.0
* chore: update printing.patch
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4727894
No logic changes, but patch needed to be manually re-applied due to upstream code shear
* chore: update port_autofill_colors_to_the_color_pipeline.patch
No manual changes; patch applied with fuzz
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5953.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5955.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5957.0
* chore: update patches
* chore: include path of native_web_keyboard_event.h
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4758689
* chore: remove reference to eextensions/browser/notification-types.h
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4771627
* chore: update references to renamed upstream field NativeWebKeyboardEvent.skip_if_unhandled (formerly known as skip_in_browser
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4758689
Need a second pair of eyes on this commit. In particular the reference in content_converter.cc, skipInBrowser, seems to not be set or documented anywhere? Is this unused/vestigal code?
* chore: sync signature of ElectronExtensionsBrowserClient::IsValidContext() to upstream change
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4784198
* chore: add auto_pip_setting_helper.[cc,h] to chromium_src build
Xref: https://chromium-review.googlesource.com/c/chromium/src/+/4688277
Exiting upstream code used by chromium_src now depends on this new upstream class
* chore: bump chromium in DEPS to 118.0.5959.0
* chore: update add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
Xref: add_maximized_parameter_to_linuxui_getwindowframeprovider.patch
manually adjust patch to minor upstream chagnes
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5961.0
* chore: bump chromium in DEPS to 118.0.5963.0
* chore: update patches
* 4780994: Rename various base files to "apple" since iOS uses them too
https://chromium-review.googlesource.com/c/chromium/src/+/4780994
* Many files moved from `mac` -> `apple`
This commit follows a handful of CLs that simply rename files/symbols to change `mac`
to `apple`
to signify their use across both macOS and iOS:
- 4784010: Move scoped_nsautorelease_pool to base/apple, leave a forwarding header
- 4790744: Move foundation_util to base/apple, leave a forwarding header
- 4790741: Move scoped_cftypreref to base/apple, leave a forwarding header
- 4787627: Move and rename macOS+iOS base/ files in PA to "apple"
- 4780399: Move OSStatus logging to base/apple
- 4787387: Remove forwarding headers
- 4781113: Rename message_pump_mac to "apple" because iOS uses it too
* fixup minor patch update error
A function param got dropped from this patch somewhere earlier
* chore: bump chromium in DEPS to 118.0.5965.2
* chore: update patches
* 4799213: Move ScopedTypeRef and ScopedCFTypeRef into base::apple::
https://chromium-review.googlesource.com/c/chromium/src/+/4799213
* Fix removed include to BrowserContext
In crrev.com/c/4767962 an include to BrowserContext was removed,
which was necessary for compilation. This broke only for us because
"chrome/browser/profiles/profile.h" includes that class, but we remove
all references to profiles.
* chore: bump chromium in DEPS to 118.0.5967.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5969.0
* chore: update patches
* chore: bump chromium in DEPS to 118.0.5971.0
* chore: bump chromium in DEPS to 118.0.5973.0
* chore: update patches
* 4772121: [OOPIF PDF] Replace PDFWebContentsHelper with PDFDocumentHelper
https://chromium-review.googlesource.com/c/chromium/src/+/4772121
* 4811164: [Extensions] Do some cleanup in ChromeManagementAPIDelegate.
https://chromium-review.googlesource.com/c/chromium/src/+/4811164
* 4809488: Remove duplicate dnd functionality between Web and Renderer prefs
https://chromium-review.googlesource.com/c/chromium/src/+/4809488
Given that this is no longer an option of web preferences, we should
consider deprecating this option and then removing it.
* chore: bump chromium in DEPS to 118.0.5975.0
* chore: update patches
* fixup! chore: add auto_pip_settings_helper.{cc|h} to chromium_src build
* Reland "[windows] Remove RegKey::DeleteEmptyKey"
Refs https://chromium-review.googlesource.com/c/chromium/src/+/4813255
* Ensure StrCat means StrCat
Refs https://chromium-review.googlesource.com/c/chromium/src/+/1117180
* fixup! Remove RegKey::DeleteEmptyKey
* Consistently reject large p and large q in DH
Refs https://boringssl-review.googlesource.com/c/boringssl/+/62226
---------
Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: clavin <clavin@electronjs.org>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
2023-09-01 06:54:59 +00:00
|
|
|
base::apple::ScopedCFTypeRef<CFStringRef> bundleId(
|
|
|
|
LSCopyDefaultHandlerForURLScheme(
|
|
|
|
base::apple::NSToCFPtrCast(protocol_ns)));
|
2023-07-01 20:22:55 +00:00
|
|
|
#pragma clang diagnostic pop
|
2016-04-25 05:17:01 +00:00
|
|
|
if (!bundleId)
|
|
|
|
return false;
|
|
|
|
|
2016-04-30 18:17:29 +00:00
|
|
|
// Ensure the comparison is case-insensitive
|
2016-04-25 05:17:01 +00:00
|
|
|
// as LS does not persist the case of the bundle id.
|
2023-11-14 21:21:32 +00:00
|
|
|
NSComparisonResult result = [base::apple::CFToNSPtrCast(bundleId.get())
|
|
|
|
caseInsensitiveCompare:identifier];
|
2016-04-25 05:17:01 +00:00
|
|
|
return result == NSOrderedSame;
|
|
|
|
}
|
|
|
|
|
2021-03-16 16:18:45 +00:00
|
|
|
std::u16string Browser::GetApplicationNameForProtocol(const GURL& url) {
|
2020-06-30 19:22:30 +00:00
|
|
|
NSString* app_path = GetAppPathForProtocol(url);
|
|
|
|
if (!app_path) {
|
2021-03-16 16:18:45 +00:00
|
|
|
return std::u16string();
|
2019-11-07 01:50:33 +00:00
|
|
|
}
|
2021-03-16 16:18:45 +00:00
|
|
|
std::u16string app_display_name = GetAppDisplayNameForProtocol(app_path);
|
2020-06-30 19:22:30 +00:00
|
|
|
return app_display_name;
|
2019-11-07 01:50:33 +00:00
|
|
|
}
|
|
|
|
|
2024-01-10 22:23:35 +00:00
|
|
|
bool Browser::SetBadgeCount(std::optional<int> count) {
|
2021-01-21 05:45:06 +00:00
|
|
|
DockSetBadgeText(!count.has_value() || count.value() != 0
|
|
|
|
? badging::BadgeManager::GetBadgeString(count)
|
|
|
|
: "");
|
|
|
|
if (count.has_value()) {
|
|
|
|
badge_count_ = count.value();
|
|
|
|
} else {
|
|
|
|
badge_count_ = 0;
|
|
|
|
}
|
2016-07-01 13:18:39 +00:00
|
|
|
return true;
|
2016-07-01 08:39:01 +00:00
|
|
|
}
|
|
|
|
|
2016-05-23 15:49:46 +00:00
|
|
|
void Browser::SetUserActivity(const std::string& type,
|
2022-07-05 15:25:18 +00:00
|
|
|
base::Value::Dict user_info,
|
2020-07-28 23:43:43 +00:00
|
|
|
gin::Arguments* args) {
|
2016-05-23 15:49:46 +00:00
|
|
|
std::string url_string;
|
|
|
|
args->GetNext(&url_string);
|
|
|
|
|
2020-02-21 19:05:03 +00:00
|
|
|
[[AtomApplication sharedApplication]
|
2016-05-05 07:38:47 +00:00
|
|
|
setCurrentActivity:base::SysUTF8ToNSString(type)
|
2022-07-05 15:25:18 +00:00
|
|
|
withUserInfo:DictionaryValueToNSDictionary(std::move(user_info))
|
2016-05-23 15:49:46 +00:00
|
|
|
withWebpageURL:net::NSURLWithGURL(GURL(url_string))];
|
2016-05-03 22:51:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string Browser::GetCurrentActivityType() {
|
2019-02-25 17:21:57 +00:00
|
|
|
NSUserActivity* userActivity =
|
2020-02-21 19:05:03 +00:00
|
|
|
[[AtomApplication sharedApplication] getCurrentActivity];
|
2019-02-25 17:21:57 +00:00
|
|
|
return base::SysNSStringToUTF8(userActivity.activityType);
|
2016-04-30 00:35:07 +00:00
|
|
|
}
|
|
|
|
|
2017-06-26 19:14:44 +00:00
|
|
|
void Browser::InvalidateCurrentActivity() {
|
2020-02-21 19:05:03 +00:00
|
|
|
[[AtomApplication sharedApplication] invalidateCurrentActivity];
|
2017-06-26 19:14:44 +00:00
|
|
|
}
|
|
|
|
|
2019-06-07 05:16:03 +00:00
|
|
|
void Browser::ResignCurrentActivity() {
|
2020-02-21 19:05:03 +00:00
|
|
|
[[AtomApplication sharedApplication] resignCurrentActivity];
|
2019-06-07 05:16:03 +00:00
|
|
|
}
|
|
|
|
|
2017-06-26 19:14:44 +00:00
|
|
|
void Browser::UpdateCurrentActivity(const std::string& type,
|
2022-07-05 15:25:18 +00:00
|
|
|
base::Value::Dict user_info) {
|
2020-02-21 19:05:03 +00:00
|
|
|
[[AtomApplication sharedApplication]
|
2017-06-26 19:14:44 +00:00
|
|
|
updateCurrentActivity:base::SysUTF8ToNSString(type)
|
2022-07-05 15:25:18 +00:00
|
|
|
withUserInfo:DictionaryValueToNSDictionary(
|
|
|
|
std::move(user_info))];
|
2017-06-26 19:14:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Browser::WillContinueUserActivity(const std::string& type) {
|
|
|
|
bool prevent_default = false;
|
2017-09-14 07:12:34 +00:00
|
|
|
for (BrowserObserver& observer : observers_)
|
|
|
|
observer.OnWillContinueUserActivity(&prevent_default, type);
|
2017-06-26 19:14:44 +00:00
|
|
|
return prevent_default;
|
|
|
|
}
|
2017-09-14 07:12:34 +00:00
|
|
|
|
2017-06-26 19:14:44 +00:00
|
|
|
void Browser::DidFailToContinueUserActivity(const std::string& type,
|
|
|
|
const std::string& error) {
|
|
|
|
for (BrowserObserver& observer : observers_)
|
|
|
|
observer.OnDidFailToContinueUserActivity(type, error);
|
|
|
|
}
|
|
|
|
|
2016-05-23 15:49:46 +00:00
|
|
|
bool Browser::ContinueUserActivity(const std::string& type,
|
2022-06-23 06:28:41 +00:00
|
|
|
base::Value::Dict user_info,
|
|
|
|
base::Value::Dict details) {
|
2016-05-05 07:26:44 +00:00
|
|
|
bool prevent_default = false;
|
2017-01-24 03:34:39 +00:00
|
|
|
for (BrowserObserver& observer : observers_)
|
2022-06-23 06:28:41 +00:00
|
|
|
observer.OnContinueUserActivity(&prevent_default, type, user_info.Clone(),
|
|
|
|
details.Clone());
|
2016-05-05 07:26:44 +00:00
|
|
|
return prevent_default;
|
|
|
|
}
|
2017-09-14 07:12:34 +00:00
|
|
|
|
2017-06-26 19:14:44 +00:00
|
|
|
void Browser::UserActivityWasContinued(const std::string& type,
|
2022-06-23 06:28:41 +00:00
|
|
|
base::Value::Dict user_info) {
|
2017-06-26 19:14:44 +00:00
|
|
|
for (BrowserObserver& observer : observers_)
|
2022-06-23 06:28:41 +00:00
|
|
|
observer.OnUserActivityWasContinued(type, user_info.Clone());
|
2017-06-26 19:14:44 +00:00
|
|
|
}
|
|
|
|
|
2017-08-09 15:09:47 +00:00
|
|
|
bool Browser::UpdateUserActivityState(const std::string& type,
|
2022-06-23 06:28:41 +00:00
|
|
|
base::Value::Dict user_info) {
|
2017-08-09 15:09:47 +00:00
|
|
|
bool prevent_default = false;
|
2017-06-26 19:14:44 +00:00
|
|
|
for (BrowserObserver& observer : observers_)
|
2022-06-23 06:28:41 +00:00
|
|
|
observer.OnUpdateUserActivityState(&prevent_default, type,
|
|
|
|
user_info.Clone());
|
2017-08-09 15:09:47 +00:00
|
|
|
return prevent_default;
|
2017-06-26 19:14:44 +00:00
|
|
|
}
|
2016-05-05 07:26:44 +00:00
|
|
|
|
2023-01-10 11:19:00 +00:00
|
|
|
// Modified from chrome/browser/ui/cocoa/l10n_util.mm.
|
|
|
|
void Browser::ApplyForcedRTL() {
|
|
|
|
NSUserDefaults* defaults = NSUserDefaults.standardUserDefaults;
|
|
|
|
|
|
|
|
auto dir = base::i18n::GetForcedTextDirection();
|
|
|
|
|
|
|
|
// An Electron app should respect RTL behavior of application locale over
|
|
|
|
// system locale.
|
|
|
|
auto should_be_rtl = dir == base::i18n::RIGHT_TO_LEFT || IsAppRTL();
|
|
|
|
auto should_be_ltr = dir == base::i18n::LEFT_TO_RIGHT || !IsAppRTL();
|
|
|
|
|
|
|
|
// -registerDefaults: won't do the trick here because these defaults exist
|
|
|
|
// (in the global domain) to reflect the system locale. They need to be set
|
|
|
|
// in Chrome's domain to supersede the system value.
|
|
|
|
if (should_be_rtl) {
|
|
|
|
[defaults setBool:YES forKey:@"AppleTextDirection"];
|
|
|
|
[defaults setBool:YES forKey:@"NSForceRightToLeftWritingDirection"];
|
|
|
|
} else if (should_be_ltr) {
|
|
|
|
[defaults setBool:YES forKey:@"AppleTextDirection"];
|
|
|
|
[defaults setBool:NO forKey:@"NSForceRightToLeftWritingDirection"];
|
|
|
|
} else {
|
|
|
|
[defaults removeObjectForKey:@"AppleTextDirection"];
|
|
|
|
[defaults removeObjectForKey:@"NSForceRightToLeftWritingDirection"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-22 13:00:21 +00:00
|
|
|
v8::Local<v8::Value> Browser::GetLoginItemSettings(
|
2017-03-29 19:29:52 +00:00
|
|
|
const LoginItemSettings& options) {
|
2016-07-07 23:29:09 +00:00
|
|
|
LoginItemSettings settings;
|
2024-03-22 13:00:21 +00:00
|
|
|
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
|
|
|
|
2023-10-16 16:25:11 +00:00
|
|
|
if (options.type != "mainAppService" && options.service_name.empty()) {
|
2024-03-22 13:00:21 +00:00
|
|
|
gin_helper::ErrorThrower(isolate).ThrowTypeError(
|
|
|
|
"'name' is required when type is not mainAppService");
|
|
|
|
return v8::Local<v8::Value>();
|
2023-10-16 16:25:11 +00:00
|
|
|
}
|
|
|
|
|
2022-11-14 20:46:52 +00:00
|
|
|
#if IS_MAS_BUILD()
|
2023-10-16 16:25:11 +00:00
|
|
|
const std::string status =
|
|
|
|
platform_util::GetLoginItemEnabled(options.type, options.service_name);
|
|
|
|
settings.open_at_login =
|
|
|
|
status == "enabled" || status == "enabled-deprecated";
|
|
|
|
if (@available(macOS 13, *))
|
|
|
|
settings.status = status;
|
2017-10-17 07:28:29 +00:00
|
|
|
#else
|
2023-10-16 16:25:11 +00:00
|
|
|
// If the app was previously set as a LoginItem with the deprecated API,
|
|
|
|
// we should report its LoginItemSettings via the old API.
|
|
|
|
LoginItemSettings settings_deprecated = GetLoginItemSettingsDeprecated();
|
|
|
|
if (@available(macOS 13, *)) {
|
|
|
|
const std::string status =
|
|
|
|
platform_util::GetLoginItemEnabled(options.type, options.service_name);
|
|
|
|
if (status == "enabled-deprecated") {
|
|
|
|
settings = settings_deprecated;
|
|
|
|
} else {
|
|
|
|
settings.open_at_login = status == "enabled";
|
|
|
|
settings.status = status;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
settings = settings_deprecated;
|
|
|
|
}
|
2017-10-17 07:28:29 +00:00
|
|
|
#endif
|
2024-03-22 13:00:21 +00:00
|
|
|
return gin::ConvertToV8(isolate, settings);
|
2016-07-06 20:26:16 +00:00
|
|
|
}
|
|
|
|
|
2017-01-30 22:01:40 +00:00
|
|
|
void Browser::SetLoginItemSettings(LoginItemSettings settings) {
|
2023-10-16 16:25:11 +00:00
|
|
|
if (settings.type != "mainAppService" && settings.service_name.empty()) {
|
|
|
|
gin_helper::ErrorThrower(JavascriptEnvironment::GetIsolate())
|
|
|
|
.ThrowTypeError("'name' is required when type is not mainAppService");
|
|
|
|
return;
|
2018-11-28 04:16:53 +00:00
|
|
|
}
|
2023-10-16 16:25:11 +00:00
|
|
|
#if IS_MAS_BUILD()
|
|
|
|
platform_util::SetLoginItemEnabled(settings.type, settings.service_name,
|
|
|
|
settings.open_at_login);
|
2017-10-17 07:28:29 +00:00
|
|
|
#else
|
2023-10-16 16:25:11 +00:00
|
|
|
const base::FilePath bundle_path = base::apple::MainBundlePath();
|
|
|
|
if (@available(macOS 13, *)) {
|
|
|
|
// If the app was previously set as a LoginItem with the old API, remove it
|
|
|
|
// as a LoginItem via the old API before re-enabling with the new API.
|
|
|
|
const std::string status =
|
|
|
|
platform_util::GetLoginItemEnabled("mainAppService", "");
|
|
|
|
if (status == "enabled-deprecated") {
|
|
|
|
base::mac::RemoveFromLoginItems(bundle_path);
|
|
|
|
if (settings.open_at_login) {
|
|
|
|
platform_util::SetLoginItemEnabled(settings.type, settings.service_name,
|
|
|
|
settings.open_at_login);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
platform_util::SetLoginItemEnabled(settings.type, settings.service_name,
|
|
|
|
settings.open_at_login);
|
|
|
|
}
|
2019-05-02 12:05:37 +00:00
|
|
|
} else {
|
2023-10-16 16:25:11 +00:00
|
|
|
if (settings.open_at_login) {
|
|
|
|
base::mac::AddToLoginItems(bundle_path, settings.open_as_hidden);
|
|
|
|
} else {
|
|
|
|
base::mac::RemoveFromLoginItems(bundle_path);
|
|
|
|
}
|
2018-10-12 22:19:27 +00:00
|
|
|
}
|
2017-10-17 07:28:29 +00:00
|
|
|
#endif
|
2016-07-06 20:26:16 +00:00
|
|
|
}
|
|
|
|
|
2013-12-05 02:26:01 +00:00
|
|
|
std::string Browser::GetExecutableFileVersion() const {
|
2018-10-24 10:49:10 +00:00
|
|
|
return GetApplicationVersion();
|
2013-06-19 05:41:54 +00:00
|
|
|
}
|
|
|
|
|
2013-12-05 02:42:04 +00:00
|
|
|
std::string Browser::GetExecutableFileProductName() const {
|
2018-10-24 10:49:10 +00:00
|
|
|
return GetApplicationName();
|
2013-12-05 02:42:04 +00:00
|
|
|
}
|
|
|
|
|
2013-08-06 08:19:56 +00:00
|
|
|
int Browser::DockBounce(BounceType type) {
|
2020-02-21 19:05:03 +00:00
|
|
|
return [[AtomApplication sharedApplication]
|
2017-03-30 21:05:47 +00:00
|
|
|
requestUserAttention:static_cast<NSRequestUserAttentionType>(type)];
|
2013-08-06 08:19:56 +00:00
|
|
|
}
|
|
|
|
|
2016-01-23 13:59:05 +00:00
|
|
|
void Browser::DockCancelBounce(int request_id) {
|
2020-02-21 19:05:03 +00:00
|
|
|
[[AtomApplication sharedApplication] cancelUserAttentionRequest:request_id];
|
2013-08-06 08:19:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Browser::DockSetBadgeText(const std::string& label) {
|
2020-02-21 19:05:03 +00:00
|
|
|
NSDockTile* tile = [[AtomApplication sharedApplication] dockTile];
|
2013-08-06 08:19:56 +00:00
|
|
|
[tile setBadgeLabel:base::SysUTF8ToNSString(label)];
|
|
|
|
}
|
|
|
|
|
2016-05-10 19:02:56 +00:00
|
|
|
void Browser::DockDownloadFinished(const std::string& filePath) {
|
|
|
|
[[NSDistributedNotificationCenter defaultCenter]
|
2018-04-20 18:47:04 +00:00
|
|
|
postNotificationName:@"com.apple.DownloadFileFinished"
|
|
|
|
object:base::SysUTF8ToNSString(filePath)];
|
2016-05-10 19:02:56 +00:00
|
|
|
}
|
|
|
|
|
2013-08-06 08:39:31 +00:00
|
|
|
std::string Browser::DockGetBadgeText() {
|
2020-02-21 19:05:03 +00:00
|
|
|
NSDockTile* tile = [[AtomApplication sharedApplication] dockTile];
|
2013-08-06 08:39:31 +00:00
|
|
|
return base::SysNSStringToUTF8([tile badgeLabel]);
|
|
|
|
}
|
|
|
|
|
2014-06-25 03:55:33 +00:00
|
|
|
void Browser::DockHide() {
|
2020-09-03 11:46:24 +00:00
|
|
|
// Transforming application state from UIElement to Foreground is an
|
2022-02-21 09:27:45 +00:00
|
|
|
// asynchronous operation, and unfortunately there is currently no way to know
|
2020-09-03 11:46:24 +00:00
|
|
|
// when it is finished.
|
|
|
|
// So if we call DockHide => DockShow => DockHide => DockShow in a very short
|
2022-02-21 09:27:45 +00:00
|
|
|
// time, we would trigger a bug of macOS that, there would be multiple dock
|
2020-09-03 11:46:24 +00:00
|
|
|
// icons of the app left in system.
|
|
|
|
// To work around this, we make sure DockHide does nothing if it is called
|
|
|
|
// immediately after DockShow. After some experiments, 1 second seems to be
|
|
|
|
// a proper interval.
|
|
|
|
if (!last_dock_show_.is_null() &&
|
2021-11-24 08:45:59 +00:00
|
|
|
base::Time::Now() - last_dock_show_ < base::Seconds(1)) {
|
2020-09-03 11:46:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-04-17 22:41:47 +00:00
|
|
|
for (auto* const& window : WindowList::GetWindows())
|
2019-01-09 20:25:19 +00:00
|
|
|
[window->GetNativeWindow().GetNativeNSWindow() setCanHide:NO];
|
2014-06-25 03:55:33 +00:00
|
|
|
|
2018-04-20 18:47:04 +00:00
|
|
|
ProcessSerialNumber psn = {0, kCurrentProcess};
|
2014-06-25 03:55:33 +00:00
|
|
|
TransformProcessType(&psn, kProcessTransformToUIElementApplication);
|
|
|
|
}
|
|
|
|
|
2016-08-01 22:22:37 +00:00
|
|
|
bool Browser::DockIsVisible() {
|
|
|
|
// Because DockShow has a slight delay this may not be true immediately
|
|
|
|
// after that call.
|
2018-04-20 18:47:04 +00:00
|
|
|
return ([[NSRunningApplication currentApplication] activationPolicy] ==
|
|
|
|
NSApplicationActivationPolicyRegular);
|
2016-08-01 22:22:37 +00:00
|
|
|
}
|
|
|
|
|
2019-02-13 05:06:33 +00:00
|
|
|
v8::Local<v8::Promise> Browser::DockShow(v8::Isolate* isolate) {
|
2020-09-03 11:46:24 +00:00
|
|
|
last_dock_show_ = base::Time::Now();
|
2019-11-01 06:10:32 +00:00
|
|
|
gin_helper::Promise<void> promise(isolate);
|
2019-02-21 12:32:44 +00:00
|
|
|
v8::Local<v8::Promise> handle = promise.GetHandle();
|
|
|
|
|
2015-12-17 20:00:04 +00:00
|
|
|
BOOL active = [[NSRunningApplication currentApplication] isActive];
|
2018-04-20 18:47:04 +00:00
|
|
|
ProcessSerialNumber psn = {0, kCurrentProcess};
|
2015-12-17 20:00:04 +00:00
|
|
|
if (active) {
|
2015-12-21 02:52:49 +00:00
|
|
|
// Workaround buggy behavior of TransformProcessType.
|
|
|
|
// http://stackoverflow.com/questions/7596643/
|
|
|
|
NSArray* runningApps = [NSRunningApplication
|
|
|
|
runningApplicationsWithBundleIdentifier:@"com.apple.dock"];
|
|
|
|
for (NSRunningApplication* app in runningApps) {
|
2015-12-17 20:00:04 +00:00
|
|
|
[app activateWithOptions:NSApplicationActivateIgnoringOtherApps];
|
|
|
|
break;
|
|
|
|
}
|
2019-11-01 06:10:32 +00:00
|
|
|
__block gin_helper::Promise<void> p = std::move(promise);
|
2015-12-21 02:52:49 +00:00
|
|
|
dispatch_time_t one_ms = dispatch_time(DISPATCH_TIME_NOW, USEC_PER_SEC);
|
|
|
|
dispatch_after(one_ms, dispatch_get_main_queue(), ^{
|
2015-12-17 20:00:04 +00:00
|
|
|
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
2022-10-03 20:21:00 +00:00
|
|
|
dispatch_time_t one_ms_2 = dispatch_time(DISPATCH_TIME_NOW, USEC_PER_SEC);
|
|
|
|
dispatch_after(one_ms_2, dispatch_get_main_queue(), ^{
|
2015-12-21 02:52:49 +00:00
|
|
|
[[NSRunningApplication currentApplication]
|
|
|
|
activateWithOptions:NSApplicationActivateIgnoringOtherApps];
|
2019-02-21 12:32:44 +00:00
|
|
|
p.Resolve();
|
2015-12-21 02:52:49 +00:00
|
|
|
});
|
2015-12-17 20:00:04 +00:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
2019-02-21 12:32:44 +00:00
|
|
|
promise.Resolve();
|
2015-12-17 20:00:04 +00:00
|
|
|
}
|
2019-02-21 12:32:44 +00:00
|
|
|
return handle;
|
2014-06-25 03:55:33 +00:00
|
|
|
}
|
|
|
|
|
2016-07-02 02:47:40 +00:00
|
|
|
void Browser::DockSetMenu(ElectronMenuModel* model) {
|
2018-04-20 18:47:04 +00:00
|
|
|
ElectronApplicationDelegate* delegate =
|
|
|
|
(ElectronApplicationDelegate*)[NSApp delegate];
|
2014-11-16 15:04:31 +00:00
|
|
|
[delegate setApplicationDockMenu:model];
|
|
|
|
}
|
|
|
|
|
2021-01-04 20:58:31 +00:00
|
|
|
void Browser::DockSetIcon(v8::Isolate* isolate, v8::Local<v8::Value> icon) {
|
|
|
|
gfx::Image image;
|
|
|
|
|
|
|
|
if (!icon->IsNull()) {
|
|
|
|
api::NativeImage* native_image = nullptr;
|
|
|
|
if (!api::NativeImage::TryConvertNativeImage(isolate, icon, &native_image))
|
|
|
|
return;
|
|
|
|
image = native_image->image();
|
|
|
|
}
|
|
|
|
|
2023-06-20 16:24:03 +00:00
|
|
|
// This is needed to avoid a hard CHECK when this fn is called
|
|
|
|
// before the browser process is ready, since supported scales
|
|
|
|
// are normally set by ui::ResourceBundle::InitSharedInstance
|
|
|
|
// during browser process startup.
|
|
|
|
if (!is_ready())
|
|
|
|
ui::SetSupportedResourceScaleFactors({ui::k100Percent});
|
2022-11-09 16:13:24 +00:00
|
|
|
|
2020-02-21 19:05:03 +00:00
|
|
|
[[AtomApplication sharedApplication]
|
2016-01-23 23:30:14 +00:00
|
|
|
setApplicationIconImage:image.AsNSImage()];
|
|
|
|
}
|
|
|
|
|
2016-10-10 20:30:58 +00:00
|
|
|
void Browser::ShowAboutPanel() {
|
2023-02-28 22:26:00 +00:00
|
|
|
NSDictionary* options = DictionaryValueToNSDictionary(about_panel_options_);
|
2016-11-15 17:36:23 +00:00
|
|
|
|
|
|
|
// Credits must be a NSAttributedString instead of NSString
|
2020-01-28 04:23:02 +00:00
|
|
|
NSString* credits = (NSString*)options[@"Credits"];
|
2016-11-15 17:36:23 +00:00
|
|
|
if (credits != nil) {
|
2023-07-18 22:26:27 +00:00
|
|
|
NSMutableDictionary* mutable_options = [options mutableCopy];
|
|
|
|
NSAttributedString* creditString = [[NSAttributedString alloc]
|
|
|
|
initWithString:credits
|
|
|
|
attributes:@{NSForegroundColorAttributeName : [NSColor textColor]}];
|
2020-01-28 04:23:02 +00:00
|
|
|
|
|
|
|
[mutable_options setValue:creditString forKey:@"Credits"];
|
2016-11-15 17:36:23 +00:00
|
|
|
options = [NSDictionary dictionaryWithDictionary:mutable_options];
|
|
|
|
}
|
|
|
|
|
2020-02-21 19:05:03 +00:00
|
|
|
[[AtomApplication sharedApplication]
|
2016-10-10 20:30:58 +00:00
|
|
|
orderFrontStandardAboutPanelWithOptions:options];
|
|
|
|
}
|
|
|
|
|
2022-07-05 15:25:18 +00:00
|
|
|
void Browser::SetAboutPanelOptions(base::Value::Dict options) {
|
2023-02-28 22:26:00 +00:00
|
|
|
about_panel_options_.clear();
|
2016-10-12 17:52:59 +00:00
|
|
|
|
2022-07-05 15:25:18 +00:00
|
|
|
for (const auto pair : options) {
|
|
|
|
std::string key = pair.first;
|
2021-05-19 23:15:47 +00:00
|
|
|
if (!key.empty() && pair.second.is_string()) {
|
2016-10-12 17:52:59 +00:00
|
|
|
key[0] = base::ToUpperASCII(key[0]);
|
2023-02-28 22:26:00 +00:00
|
|
|
about_panel_options_.Set(key, pair.second.Clone());
|
2016-10-12 17:52:59 +00:00
|
|
|
}
|
|
|
|
}
|
2016-10-10 20:30:58 +00:00
|
|
|
}
|
|
|
|
|
2019-03-14 20:39:52 +00:00
|
|
|
void Browser::ShowEmojiPanel() {
|
2020-02-21 19:05:03 +00:00
|
|
|
[[AtomApplication sharedApplication] orderFrontCharacterPalette:nil];
|
2019-03-14 20:39:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Browser::IsEmojiPanelSupported() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-05-21 15:53:44 +00:00
|
|
|
bool Browser::IsSecureKeyboardEntryEnabled() {
|
|
|
|
return password_input_enabler_.get() != nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Browser::SetSecureKeyboardEntryEnabled(bool enabled) {
|
|
|
|
if (enabled) {
|
|
|
|
password_input_enabler_ =
|
|
|
|
std::make_unique<ui::ScopedPasswordInputEnabler>();
|
|
|
|
} else {
|
|
|
|
password_input_enabler_.reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-02 15:43:23 +00:00
|
|
|
} // namespace electron
|