refactor: prefer to inherit observer classes privately (#41360)

* refactor: use private inheritance in CookieChangeNotifier

* refactor: use private inheritance in WebViewGuestDelegate

* refactor: use private inheritance in UsbChooserController

* refactor: use private inheritance in DesktopCapturer

* refactor: use private inheritance in Browser

* refactor: use private inheritance in WebContentsZoomController

* refactor: use private inheritance in FrameSubscriber

* refactor: use private inheritance in AutofillAgent

* refactor: use private inheritance in HidChooserController

* refactor: use private inheritance in PepperHelper

* refactor: use private inheritance in AutofillPopup

* refactor: use private inheritance in SerialChooserController

* refactor: use private inheritance in MediaCaptureDevicesDispatcher

* refactor: use private inheritance in electron::api::View

* refactor: use private inheritance in AutofillDriverFactory

* refactor: use private inheritance in GPUInfoManager

* refactor: use private inheritance in SavePageHandler

* refactor: use private inheritance in GlobalShortcut

* refactor: use private inheritance in ElectronRenderFrameObserver
This commit is contained in:
Charles Kerr 2024-05-21 14:21:31 -05:00 committed by GitHub
parent 23a5d8b64a
commit 752efddf89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 37 additions and 33 deletions

View file

@ -19,7 +19,7 @@ namespace electron::api {
class DesktopCapturer : public gin::Wrappable<DesktopCapturer>,
public gin_helper::Pinnable<DesktopCapturer>,
public DesktopMediaListObserver {
private DesktopMediaListObserver {
public:
struct Source {
DesktopMediaList::Source media_list_source;
@ -51,6 +51,7 @@ class DesktopCapturer : public gin::Wrappable<DesktopCapturer>,
explicit DesktopCapturer(v8::Isolate* isolate);
~DesktopCapturer() override;
private:
// DesktopMediaListObserver:
void OnSourceAdded(int index) override {}
void OnSourceRemoved(int index) override {}
@ -61,7 +62,6 @@ class DesktopCapturer : public gin::Wrappable<DesktopCapturer>,
void OnDelegatedSourceListSelection() override {}
void OnDelegatedSourceListDismissed() override {}
private:
using OnceCallback = base::OnceClosure;
class DesktopListListener : public DesktopMediaListObserver {

View file

@ -16,7 +16,7 @@
namespace electron::api {
class GlobalShortcut : public extensions::GlobalShortcutListener::Observer,
class GlobalShortcut : private extensions::GlobalShortcutListener::Observer,
public gin::Wrappable<GlobalShortcut> {
public:
static gin::Handle<GlobalShortcut> Create(v8::Isolate* isolate);

View file

@ -17,7 +17,8 @@
namespace electron::api {
class View : public gin_helper::EventEmitter<View>, public views::ViewObserver {
class View : public gin_helper::EventEmitter<View>,
private views::ViewObserver {
public:
static gin_helper::WrappableBase* New(gin::Arguments* args);
static gin::Handle<View> Create(v8::Isolate* isolate);

View file

@ -27,8 +27,8 @@ namespace electron::api {
class WebContents;
class FrameSubscriber : public content::WebContentsObserver,
public viz::mojom::FrameSinkVideoConsumer {
class FrameSubscriber : private content::WebContentsObserver,
private viz::mojom::FrameSinkVideoConsumer {
public:
using FrameCaptureCallback =
base::RepeatingCallback<void(const gfx::Image&, const gfx::Rect&)>;

View file

@ -16,7 +16,7 @@
namespace electron {
// GPUInfoManager is a singleton used to manage and fetch GPUInfo
class GPUInfoManager : public content::GpuDataManagerObserver {
class GPUInfoManager : private content::GpuDataManagerObserver {
public:
static GPUInfoManager* GetInstance();
@ -29,9 +29,10 @@ class GPUInfoManager : public content::GpuDataManagerObserver {
void FetchCompleteInfo(gin_helper::Promise<base::Value> promise);
void FetchBasicInfo(gin_helper::Promise<base::Value> promise);
void OnGpuInfoUpdate() override;
private:
void OnGpuInfoUpdate() override;
base::Value::Dict EnumerateGPUInfo(gpu::GPUInfo gpu_info) const;
// These should be posted to the task queue

View file

@ -23,8 +23,8 @@ class WebContents;
namespace electron::api {
// A self-destroyed class for handling save page request.
class SavePageHandler : public content::DownloadManager::Observer,
public download::DownloadItem::Observer {
class SavePageHandler : private content::DownloadManager::Observer,
private download::DownloadItem::Observer {
public:
SavePageHandler(content::WebContents* web_contents,
gin_helper::Promise<void> promise);