refactor: minor electron browser context cleanup (#42815)
* refactor: make DevicePermissionMap private to electron::ElectronBrowserContext refactor: make PartitionPath private to electron::ElectronBrowserContext Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: remove unused forward declarations of v8 classes Co-authored-by: Charles Kerr <charles@charleskerr.com> * chore: forward declare gin::Arguments Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: use unique_ptr operator bool Co-authored-by: Charles Kerr <charles@charleskerr.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
parent
50864bcd08
commit
7353fa88cd
2 changed files with 17 additions and 22 deletions
|
@ -401,7 +401,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();
|
||||
}
|
||||
|
@ -417,10 +417,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();
|
||||
}
|
||||
|
@ -438,7 +437,7 @@ ElectronBrowserContext::GetPlatformNotificationService() {
|
|||
|
||||
content::PermissionControllerDelegate*
|
||||
ElectronBrowserContext::GetPermissionControllerDelegate() {
|
||||
if (!permission_manager_.get())
|
||||
if (!permission_manager_)
|
||||
permission_manager_ = std::make_unique<ElectronPermissionManager>();
|
||||
return permission_manager_.get();
|
||||
}
|
||||
|
@ -453,7 +452,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);
|
||||
|
|
Loading…
Reference in a new issue