refactor: minor electron browser context cleanup (#42789)

* refactor: make DevicePermissionMap private to electron::ElectronBrowserContext

refactor: make PartitionPath private to electron::ElectronBrowserContext

* refactor: remove unused forward declarations of v8 classes

* chore: forward declare gin::Arguments

* refactor: use unique_ptr operator bool
This commit is contained in:
Charles Kerr 2024-07-08 09:49:41 -05:00 коммит произвёл GitHub
Родитель e99e554655
Коммит 27e3273f0a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 17 добавлений и 22 удалений

Просмотреть файл

@ -467,7 +467,7 @@ bool ElectronBrowserContext::IsOffTheRecord() {
}
std::string ElectronBrowserContext::GetMediaDeviceIDSalt() {
if (!media_device_id_salt_.get())
if (!media_device_id_salt_)
media_device_id_salt_ = std::make_unique<MediaDeviceIDSalt>(prefs_.get());
return media_device_id_salt_->GetSalt();
}
@ -483,10 +483,9 @@ ElectronBrowserContext::CreateZoomLevelDelegate(
content::DownloadManagerDelegate*
ElectronBrowserContext::GetDownloadManagerDelegate() {
if (!download_manager_delegate_.get()) {
auto* download_manager = this->GetDownloadManager();
if (!download_manager_delegate_) {
download_manager_delegate_ =
std::make_unique<ElectronDownloadManagerDelegate>(download_manager);
std::make_unique<ElectronDownloadManagerDelegate>(GetDownloadManager());
}
return download_manager_delegate_.get();
}
@ -504,7 +503,7 @@ ElectronBrowserContext::GetPlatformNotificationService() {
content::PermissionControllerDelegate*
ElectronBrowserContext::GetPermissionControllerDelegate() {
if (!permission_manager_.get())
if (!permission_manager_)
permission_manager_ = std::make_unique<ElectronPermissionManager>();
return permission_manager_.get();
}
@ -519,7 +518,7 @@ std::string ElectronBrowserContext::GetUserAgent() const {
}
predictors::PreconnectManager* ElectronBrowserContext::GetPreconnectManager() {
if (!preconnect_manager_.get()) {
if (!preconnect_manager_) {
preconnect_manager_ =
std::make_unique<predictors::PreconnectManager>(nullptr, this);
}

Просмотреть файл

@ -21,7 +21,6 @@
#include "content/public/browser/resource_context.h"
#include "electron/buildflags/buildflags.h"
#include "electron/shell/browser/media/media_device_id_salt.h"
#include "gin/arguments.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/network/public/mojom/network_context.mojom.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
@ -30,6 +29,10 @@
class PrefService;
class ValueMapPrefStore;
namespace gin {
class Arguments;
}
namespace network {
class SharedURLLoaderFactory;
}
@ -44,19 +47,8 @@ class ElectronExtensionSystem;
}
#endif
namespace v8 {
template <typename T>
class Local;
class Isolate;
class Value;
} // namespace v8
namespace electron {
using DevicePermissionMap =
std::map<blink::PermissionType,
std::map<url::Origin, std::vector<std::unique_ptr<base::Value>>>>;
class ElectronDownloadManagerDelegate;
class ElectronPermissionManager;
class CookieChangeNotifier;
@ -69,10 +61,6 @@ using DisplayMediaResponseCallbackJs =
using DisplayMediaRequestHandler =
base::RepeatingCallback<void(const content::MediaStreamRequest&,
DisplayMediaResponseCallbackJs)>;
using PartitionOrPath =
std::variant<std::reference_wrapper<const std::string>,
std::reference_wrapper<const base::FilePath>>;
class ElectronBrowserContext : public content::BrowserContext {
public:
// disable copy
@ -207,6 +195,14 @@ class ElectronBrowserContext : public content::BrowserContext {
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);