mirror of
https://github.com/electron/electron.git
synced 2026-01-08 07:04:01 -05:00
* chore: bump chromium in DEPS to 144.0.7543.0 * Pass PipScreenCaptureCoordinatorProxy to ScreenCaptureKitDeviceMac https://chromium-review.googlesource.com/c/chromium/src/+/7157590 * chore: update patches * chore: update filenames.libcxx.gni * 7142359: Spanification of process_singleton_posix.cc https: //chromium-review.googlesource.com/c/chromium/src/+/7142359 Co-Authored-By: Charles Kerr <70381+ckerr@users.noreply.github.com> * Move logging::LoggingSettings to base/logging/logging_settings.h https://chromium-review.googlesource.com/c/chromium/src/+/7173024 * chore: bump chromium in DEPS to 144.0.7545.0 * 7159368: update PluginService API for sync GetPlugins Upstream removed async PluginService APIs: - GetPluginsAsync() removed, use synchronous GetPlugins() - RegisterInternalPlugin() now takes single argument (remove add_at_beginning) - RefreshPlugins() removed entirely Updated ElectronPluginInfoHostImpl to use synchronous plugin loading and simplified ElectronBrowserMainParts internal plugin registration. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7159368 Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7159328 Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7159056 (cherry picked from commit88cdf50b0a) * 7159184: add missing base/files/file_path.h include Add explicit include for base/files/file_path.h in electron_browser_context.h. After removal of superfluous Mojo includes from content headers, base::FilePath is no longer transitively included via content/public/browser/browser_context.h. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7159184 (cherry picked from commit6ca8ea03ec) * 7126479: add ShouldForceRefreshTextCheckService parameter to SpellCheckClient Upstream added a force-refresh parameter to WebTextCheckClient::RequestCheckingOfText to bypass spell check cache. Add the new ShouldForceRefreshTextCheckService parameter to SpellCheckClient's override (currently unused in Electron). Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7126479 (cherry picked from commit879c0401c4) * 7083663: remove fingerprinting_protection_ruleset_service override Upstream deleted external references to Fingerprinting Protection Filter (FPF) component. Remove the fingerprinting_protection_ruleset_service() override from BrowserProcessImpl as the method no longer exists in the base class. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7083663 (cherry picked from commit8350d152f9) * 7155287: implement WebContentsView::GetSize and Resize Upstream delegated WebContents::GetSize() and Resize() to WebContentsView, making them pure virtual. Add const qualifier to GetSize() and implement the Resize() override in OffScreenWebContentsView (no-op for offscreen). Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7155287 (cherry picked from commit084eaa568e) * 7184238: add OnUnconfirmedTapConvertedToTap override Upstream added OnUnconfirmedTapConvertedToTap as a pure virtual method to RenderWidgetHostViewBase to inform root view when child frame converts an unconfirmed tap. Add empty override for offscreen rendering. Ref: https://chromium-review.googlesource.com/c/chromium/src/+/7184238 (cherry picked from commitef03400d9a) * 7143586: add widget parameter to OnCommandsChanged GlobalAcceleratorListener::OnCommandsChanged gained a gfx::AcceleratedWidget parameter for window association in the GlobalShortcutListenerLinux implementation. Pass gfx::kNullAcceleratedWidget for Electron's usage. Ref: : Pass parent handle to GlobalAcceleratorListenerLinux::BindShortcuts | https://chromium-review.googlesource.com/c/chromium/src/+/7143586 (cherry picked from commit38306e2bfc) Co-Authored-By: Samuel Attard <MarshallOfSound@users.noreply.github.com> * chore: update patches Co-Authored-By: Samuel Attard <MarshallOfSound@users.noreply.github.com> * chore: bump chromium in DEPS to 144.0.7547.0 * chore: update patches * 7189232: Add support for UnownedUserData in GlobalFeatures https: //chromium-review.googlesource.com/c/chromium/src/+/7189232 * Refactor: Use std::u16string for extension load error messages https://chromium-review.googlesource.com/c/chromium/src/+/7185844 * fixup Add support for UnownedUserData in GlobalFeatures * 7165650: Remove ResourceContext https://chromium-review.googlesource.com/c/chromium/src/+/7165650 * fixup BUILD.gn for lint * 7202164: Reland "Reland "Remove GenericScopedHandle:IsValid"" https://chromium-review.googlesource.com/c/chromium/src/+/7202164 * advance deprecation of v8::ReturnValue<void>::Set(Local<S>). 7168624: [runtime][api] Relax requirements for setter/definer/deleter callbacks | https://chromium-review.googlesource.com/c/v8/v8/+/7168624 * fixup advance deprecation of v8::ReturnValue<void>::Set(Local<S>) * chore: skip setting LPAC ACLs * Revert "chore: skip setting LPAC ACLs" This reverts commite187aec488. * chore: revert Convert to UNSAFE_TODO in sandbox revert https://chromium-review.googlesource.com/c/chromium/src/+/7131661 to see if it fixes the Windows sandbox issue. * Revert "chore: revert Convert to UNSAFE_TODO in sandbox" This reverts commit57afbfefe5. * chore: Revert "Enable network sandbox by default on Windows" see if this fixes the Windows sandbox issue * Enable network sandbox by default on Windows https://chromium-review.googlesource.com/c/chromium/src/+/7204292 * Revert "chore: Revert "Enable network sandbox by default on Windows"" This reverts commit530ab6af82. * fixup! Enable network sandbox by default on Windows | https://chromium-review.googlesource.com/c/chromium/src/+/7204292 * fixup!: Correct flag name, add kLocalNetworkAccessChecks to all platforms --------- 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: Charles Kerr <70381+ckerr@users.noreply.github.com> Co-authored-by: Samuel Attard <sattard@anthropic.com> Co-authored-by: Samuel Attard <MarshallOfSound@users.noreply.github.com> Co-authored-by: John Kleinschmidt <kleinschmidtorama@gmail.com> Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
222 lines
8.2 KiB
C++
222 lines
8.2 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.
|
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_ELECTRON_BROWSER_CONTEXT_H_
|
|
#define ELECTRON_SHELL_BROWSER_ELECTRON_BROWSER_CONTEXT_H_
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <variant>
|
|
#include <vector>
|
|
|
|
#include "base/files/file_path.h"
|
|
#include "content/public/browser/browser_context.h"
|
|
#include "content/public/browser/media_stream_request.h"
|
|
#include "mojo/public/cpp/bindings/remote.h"
|
|
#include "services/network/public/mojom/ssl_config.mojom.h"
|
|
#include "third_party/blink/public/common/permissions/permission_utils.h"
|
|
|
|
class PrefService;
|
|
class ValueMapPrefStore;
|
|
|
|
namespace content {
|
|
class PreconnectManager;
|
|
} // namespace content
|
|
|
|
namespace gin {
|
|
class Arguments;
|
|
}
|
|
|
|
namespace network {
|
|
class SharedURLLoaderFactory;
|
|
}
|
|
|
|
namespace storage {
|
|
class SpecialStoragePolicy;
|
|
}
|
|
|
|
namespace electron {
|
|
|
|
class CookieChangeNotifier;
|
|
class ElectronDownloadManagerDelegate;
|
|
class ElectronPermissionManager;
|
|
class ElectronPreconnectManagerDelegate;
|
|
class MediaDeviceIDSalt;
|
|
class ProtocolRegistry;
|
|
class ResolveProxyHelper;
|
|
class WebViewManager;
|
|
|
|
using DisplayMediaResponseCallbackJs =
|
|
base::OnceCallback<void(gin::Arguments* args)>;
|
|
using DisplayMediaRequestHandler =
|
|
base::RepeatingCallback<void(const content::MediaStreamRequest&,
|
|
DisplayMediaResponseCallbackJs)>;
|
|
class ElectronBrowserContext : public content::BrowserContext {
|
|
public:
|
|
// disable copy
|
|
ElectronBrowserContext(const ElectronBrowserContext&) = delete;
|
|
ElectronBrowserContext& operator=(const ElectronBrowserContext&) = delete;
|
|
|
|
[[nodiscard]] static std::vector<ElectronBrowserContext*> BrowserContexts();
|
|
|
|
[[nodiscard]] static bool IsValidContext(const void* context);
|
|
|
|
// Get or create the default BrowserContext.
|
|
static ElectronBrowserContext* GetDefaultBrowserContext(
|
|
base::Value::Dict options = {});
|
|
|
|
// Get or create the BrowserContext according to its |partition| and
|
|
// |in_memory|. The |options| will be passed to constructor when there is no
|
|
// existing BrowserContext.
|
|
static ElectronBrowserContext* From(const std::string& partition,
|
|
bool in_memory,
|
|
base::Value::Dict options = {});
|
|
|
|
// Get or create the BrowserContext using the |path|.
|
|
// The |options| will be passed to constructor when there is no
|
|
// existing BrowserContext.
|
|
static ElectronBrowserContext* FromPath(const base::FilePath& path,
|
|
base::Value::Dict options = {});
|
|
|
|
static void DestroyAllContexts();
|
|
|
|
void SetUserAgent(const std::string& user_agent);
|
|
std::string GetUserAgent() const;
|
|
bool can_use_http_cache() const { return use_cache_; }
|
|
int max_cache_size() const { return max_cache_size_; }
|
|
ResolveProxyHelper* GetResolveProxyHelper();
|
|
content::PreconnectManager* GetPreconnectManager();
|
|
scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory();
|
|
|
|
std::string GetMediaDeviceIDSalt();
|
|
|
|
// content::BrowserContext:
|
|
base::FilePath GetPath() const override;
|
|
bool IsOffTheRecord() override;
|
|
std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(
|
|
const base::FilePath& partition_path) override;
|
|
content::PushMessagingService* GetPushMessagingService() override;
|
|
content::SSLHostStateDelegate* GetSSLHostStateDelegate() override;
|
|
content::BackgroundFetchDelegate* GetBackgroundFetchDelegate() override;
|
|
content::BackgroundSyncController* GetBackgroundSyncController() override;
|
|
content::BrowsingDataRemoverDelegate* GetBrowsingDataRemoverDelegate()
|
|
override;
|
|
content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
|
|
content::BrowserPluginGuestManager* GetGuestManager() override;
|
|
content::PlatformNotificationService* GetPlatformNotificationService()
|
|
override;
|
|
content::PermissionControllerDelegate* GetPermissionControllerDelegate()
|
|
override;
|
|
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
|
|
content::ClientHintsControllerDelegate* GetClientHintsControllerDelegate()
|
|
override;
|
|
content::StorageNotificationService* GetStorageNotificationService() override;
|
|
content::ReduceAcceptLanguageControllerDelegate*
|
|
GetReduceAcceptLanguageControllerDelegate() override;
|
|
content::FileSystemAccessPermissionContext*
|
|
GetFileSystemAccessPermissionContext() override;
|
|
|
|
CookieChangeNotifier* cookie_change_notifier() const {
|
|
return cookie_change_notifier_.get();
|
|
}
|
|
PrefService* prefs() const { return prefs_.get(); }
|
|
ValueMapPrefStore* in_memory_pref_store() const {
|
|
return in_memory_pref_store_.get();
|
|
}
|
|
|
|
ProtocolRegistry* protocol_registry() const {
|
|
return protocol_registry_.get();
|
|
}
|
|
|
|
void SetSSLConfig(network::mojom::SSLConfigPtr config);
|
|
network::mojom::SSLConfigPtr GetSSLConfig();
|
|
void SetSSLConfigClient(mojo::Remote<network::mojom::SSLConfigClient> client);
|
|
|
|
bool ChooseDisplayMediaDevice(const content::MediaStreamRequest& request,
|
|
content::MediaResponseCallback callback);
|
|
void SetDisplayMediaRequestHandler(DisplayMediaRequestHandler handler);
|
|
|
|
~ElectronBrowserContext() override;
|
|
|
|
// Grants |origin| access to |device|.
|
|
// To be used in place of ObjectPermissionContextBase::GrantObjectPermission.
|
|
void GrantDevicePermission(const url::Origin& origin,
|
|
const base::Value& device,
|
|
blink::PermissionType permissionType);
|
|
|
|
// Revokes |origin| access to |device|.
|
|
// To be used in place of ObjectPermissionContextBase::RevokeObjectPermission.
|
|
void RevokeDevicePermission(const url::Origin& origin,
|
|
const base::Value& device,
|
|
blink::PermissionType permission_type);
|
|
|
|
// Returns the list of devices that |origin| has been granted permission to
|
|
// access. To be used in place of
|
|
// ObjectPermissionContextBase::GetGrantedObjects.
|
|
bool CheckDevicePermission(const url::Origin& origin,
|
|
const base::Value& device,
|
|
blink::PermissionType permissionType);
|
|
|
|
private:
|
|
using DevicePermissionMap = std::map<
|
|
blink::PermissionType,
|
|
std::map<url::Origin, std::vector<std::unique_ptr<base::Value>>>>;
|
|
|
|
using PartitionOrPath =
|
|
std::variant<std::reference_wrapper<const std::string>,
|
|
std::reference_wrapper<const base::FilePath>>;
|
|
|
|
ElectronBrowserContext(const PartitionOrPath partition_location,
|
|
bool in_memory,
|
|
base::Value::Dict options);
|
|
|
|
ElectronBrowserContext(base::FilePath partition, base::Value::Dict options);
|
|
|
|
static void DisplayMediaDeviceChosen(
|
|
const content::MediaStreamRequest& request,
|
|
content::MediaResponseCallback callback,
|
|
gin::Arguments* args);
|
|
|
|
// Initialize pref registry.
|
|
void InitPrefs();
|
|
|
|
scoped_refptr<ValueMapPrefStore> in_memory_pref_store_;
|
|
std::unique_ptr<CookieChangeNotifier> cookie_change_notifier_;
|
|
std::unique_ptr<PrefService> prefs_;
|
|
std::unique_ptr<ElectronDownloadManagerDelegate> download_manager_delegate_;
|
|
std::unique_ptr<WebViewManager> guest_manager_;
|
|
std::unique_ptr<ElectronPermissionManager> permission_manager_;
|
|
std::unique_ptr<MediaDeviceIDSalt> media_device_id_salt_;
|
|
scoped_refptr<ResolveProxyHelper> resolve_proxy_helper_;
|
|
scoped_refptr<storage::SpecialStoragePolicy> storage_policy_;
|
|
std::unique_ptr<content::PreconnectManager> preconnect_manager_;
|
|
std::unique_ptr<ElectronPreconnectManagerDelegate>
|
|
preconnect_manager_delegate_;
|
|
std::unique_ptr<ProtocolRegistry> protocol_registry_;
|
|
|
|
std::optional<std::string> user_agent_;
|
|
base::FilePath path_;
|
|
bool in_memory_ = false;
|
|
bool use_cache_ = true;
|
|
int max_cache_size_ = 0;
|
|
|
|
// Shared URLLoaderFactory.
|
|
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_;
|
|
|
|
network::mojom::SSLConfigPtr ssl_config_;
|
|
mojo::Remote<network::mojom::SSLConfigClient> ssl_config_client_;
|
|
|
|
DisplayMediaRequestHandler display_media_request_handler_;
|
|
|
|
// In-memory cache that holds objects that have been granted permissions.
|
|
DevicePermissionMap granted_devices_;
|
|
};
|
|
|
|
} // namespace electron
|
|
|
|
#endif // ELECTRON_SHELL_BROWSER_ELECTRON_BROWSER_CONTEXT_H_
|