зеркало из https://github.com/electron/electron.git
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:
Родитель
23a5d8b64a
Коммит
752efddf89
|
@ -19,7 +19,7 @@ namespace electron::api {
|
||||||
|
|
||||||
class DesktopCapturer : public gin::Wrappable<DesktopCapturer>,
|
class DesktopCapturer : public gin::Wrappable<DesktopCapturer>,
|
||||||
public gin_helper::Pinnable<DesktopCapturer>,
|
public gin_helper::Pinnable<DesktopCapturer>,
|
||||||
public DesktopMediaListObserver {
|
private DesktopMediaListObserver {
|
||||||
public:
|
public:
|
||||||
struct Source {
|
struct Source {
|
||||||
DesktopMediaList::Source media_list_source;
|
DesktopMediaList::Source media_list_source;
|
||||||
|
@ -51,6 +51,7 @@ class DesktopCapturer : public gin::Wrappable<DesktopCapturer>,
|
||||||
explicit DesktopCapturer(v8::Isolate* isolate);
|
explicit DesktopCapturer(v8::Isolate* isolate);
|
||||||
~DesktopCapturer() override;
|
~DesktopCapturer() override;
|
||||||
|
|
||||||
|
private:
|
||||||
// DesktopMediaListObserver:
|
// DesktopMediaListObserver:
|
||||||
void OnSourceAdded(int index) override {}
|
void OnSourceAdded(int index) override {}
|
||||||
void OnSourceRemoved(int index) override {}
|
void OnSourceRemoved(int index) override {}
|
||||||
|
@ -61,7 +62,6 @@ class DesktopCapturer : public gin::Wrappable<DesktopCapturer>,
|
||||||
void OnDelegatedSourceListSelection() override {}
|
void OnDelegatedSourceListSelection() override {}
|
||||||
void OnDelegatedSourceListDismissed() override {}
|
void OnDelegatedSourceListDismissed() override {}
|
||||||
|
|
||||||
private:
|
|
||||||
using OnceCallback = base::OnceClosure;
|
using OnceCallback = base::OnceClosure;
|
||||||
|
|
||||||
class DesktopListListener : public DesktopMediaListObserver {
|
class DesktopListListener : public DesktopMediaListObserver {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
namespace electron::api {
|
namespace electron::api {
|
||||||
|
|
||||||
class GlobalShortcut : public extensions::GlobalShortcutListener::Observer,
|
class GlobalShortcut : private extensions::GlobalShortcutListener::Observer,
|
||||||
public gin::Wrappable<GlobalShortcut> {
|
public gin::Wrappable<GlobalShortcut> {
|
||||||
public:
|
public:
|
||||||
static gin::Handle<GlobalShortcut> Create(v8::Isolate* isolate);
|
static gin::Handle<GlobalShortcut> Create(v8::Isolate* isolate);
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
|
|
||||||
namespace electron::api {
|
namespace electron::api {
|
||||||
|
|
||||||
class View : public gin_helper::EventEmitter<View>, public views::ViewObserver {
|
class View : public gin_helper::EventEmitter<View>,
|
||||||
|
private views::ViewObserver {
|
||||||
public:
|
public:
|
||||||
static gin_helper::WrappableBase* New(gin::Arguments* args);
|
static gin_helper::WrappableBase* New(gin::Arguments* args);
|
||||||
static gin::Handle<View> Create(v8::Isolate* isolate);
|
static gin::Handle<View> Create(v8::Isolate* isolate);
|
||||||
|
|
|
@ -27,8 +27,8 @@ namespace electron::api {
|
||||||
|
|
||||||
class WebContents;
|
class WebContents;
|
||||||
|
|
||||||
class FrameSubscriber : public content::WebContentsObserver,
|
class FrameSubscriber : private content::WebContentsObserver,
|
||||||
public viz::mojom::FrameSinkVideoConsumer {
|
private viz::mojom::FrameSinkVideoConsumer {
|
||||||
public:
|
public:
|
||||||
using FrameCaptureCallback =
|
using FrameCaptureCallback =
|
||||||
base::RepeatingCallback<void(const gfx::Image&, const gfx::Rect&)>;
|
base::RepeatingCallback<void(const gfx::Image&, const gfx::Rect&)>;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
namespace electron {
|
namespace electron {
|
||||||
|
|
||||||
// GPUInfoManager is a singleton used to manage and fetch GPUInfo
|
// GPUInfoManager is a singleton used to manage and fetch GPUInfo
|
||||||
class GPUInfoManager : public content::GpuDataManagerObserver {
|
class GPUInfoManager : private content::GpuDataManagerObserver {
|
||||||
public:
|
public:
|
||||||
static GPUInfoManager* GetInstance();
|
static GPUInfoManager* GetInstance();
|
||||||
|
|
||||||
|
@ -29,9 +29,10 @@ class GPUInfoManager : public content::GpuDataManagerObserver {
|
||||||
|
|
||||||
void FetchCompleteInfo(gin_helper::Promise<base::Value> promise);
|
void FetchCompleteInfo(gin_helper::Promise<base::Value> promise);
|
||||||
void FetchBasicInfo(gin_helper::Promise<base::Value> promise);
|
void FetchBasicInfo(gin_helper::Promise<base::Value> promise);
|
||||||
void OnGpuInfoUpdate() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void OnGpuInfoUpdate() override;
|
||||||
|
|
||||||
base::Value::Dict EnumerateGPUInfo(gpu::GPUInfo gpu_info) const;
|
base::Value::Dict EnumerateGPUInfo(gpu::GPUInfo gpu_info) const;
|
||||||
|
|
||||||
// These should be posted to the task queue
|
// These should be posted to the task queue
|
||||||
|
|
|
@ -23,8 +23,8 @@ class WebContents;
|
||||||
namespace electron::api {
|
namespace electron::api {
|
||||||
|
|
||||||
// A self-destroyed class for handling save page request.
|
// A self-destroyed class for handling save page request.
|
||||||
class SavePageHandler : public content::DownloadManager::Observer,
|
class SavePageHandler : private content::DownloadManager::Observer,
|
||||||
public download::DownloadItem::Observer {
|
private download::DownloadItem::Observer {
|
||||||
public:
|
public:
|
||||||
SavePageHandler(content::WebContents* web_contents,
|
SavePageHandler(content::WebContents* web_contents,
|
||||||
gin_helper::Promise<void> promise);
|
gin_helper::Promise<void> promise);
|
||||||
|
|
|
@ -85,7 +85,7 @@ struct LoginItemSettings {
|
||||||
};
|
};
|
||||||
|
|
||||||
// This class is used for control application-wide operations.
|
// This class is used for control application-wide operations.
|
||||||
class Browser : public WindowListObserver {
|
class Browser : private WindowListObserver {
|
||||||
public:
|
public:
|
||||||
Browser();
|
Browser();
|
||||||
~Browser() override;
|
~Browser() override;
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace electron {
|
||||||
class ElectronBrowserContext;
|
class ElectronBrowserContext;
|
||||||
|
|
||||||
// Sends cookie-change notifications on the UI thread.
|
// Sends cookie-change notifications on the UI thread.
|
||||||
class CookieChangeNotifier : public network::mojom::CookieChangeListener {
|
class CookieChangeNotifier : private network::mojom::CookieChangeListener {
|
||||||
public:
|
public:
|
||||||
explicit CookieChangeNotifier(ElectronBrowserContext* browser_context);
|
explicit CookieChangeNotifier(ElectronBrowserContext* browser_context);
|
||||||
~CookieChangeNotifier() override;
|
~CookieChangeNotifier() override;
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace electron {
|
||||||
class AutofillDriver;
|
class AutofillDriver;
|
||||||
|
|
||||||
class AutofillDriverFactory
|
class AutofillDriverFactory
|
||||||
: public content::WebContentsObserver,
|
: private content::WebContentsObserver,
|
||||||
public content::WebContentsUserData<AutofillDriverFactory> {
|
public content::WebContentsUserData<AutofillDriverFactory> {
|
||||||
public:
|
public:
|
||||||
typedef base::OnceCallback<std::unique_ptr<AutofillDriver>()>
|
typedef base::OnceCallback<std::unique_ptr<AutofillDriver>()>
|
||||||
|
@ -31,11 +31,6 @@ class AutofillDriverFactory
|
||||||
pending_receiver,
|
pending_receiver,
|
||||||
content::RenderFrameHost* render_frame_host);
|
content::RenderFrameHost* render_frame_host);
|
||||||
|
|
||||||
// content::WebContentsObserver:
|
|
||||||
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
|
|
||||||
void DidFinishNavigation(
|
|
||||||
content::NavigationHandle* navigation_handle) override;
|
|
||||||
|
|
||||||
AutofillDriver* DriverForFrame(content::RenderFrameHost* render_frame_host);
|
AutofillDriver* DriverForFrame(content::RenderFrameHost* render_frame_host);
|
||||||
void AddDriverForFrame(content::RenderFrameHost* render_frame_host,
|
void AddDriverForFrame(content::RenderFrameHost* render_frame_host,
|
||||||
CreationCallback factory_method);
|
CreationCallback factory_method);
|
||||||
|
@ -46,6 +41,11 @@ class AutofillDriverFactory
|
||||||
WEB_CONTENTS_USER_DATA_KEY_DECL();
|
WEB_CONTENTS_USER_DATA_KEY_DECL();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// content::WebContentsObserver:
|
||||||
|
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
|
||||||
|
void DidFinishNavigation(
|
||||||
|
content::NavigationHandle* navigation_handle) override;
|
||||||
|
|
||||||
explicit AutofillDriverFactory(content::WebContents* web_contents);
|
explicit AutofillDriverFactory(content::WebContents* web_contents);
|
||||||
friend class content::WebContentsUserData<AutofillDriverFactory>;
|
friend class content::WebContentsUserData<AutofillDriverFactory>;
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ class HidChooserContext;
|
||||||
|
|
||||||
// HidChooserController provides data for the WebHID API permission prompt.
|
// HidChooserController provides data for the WebHID API permission prompt.
|
||||||
class HidChooserController
|
class HidChooserController
|
||||||
: public content::WebContentsObserver,
|
: private content::WebContentsObserver,
|
||||||
public electron::HidChooserContext::DeviceObserver {
|
private electron::HidChooserContext::DeviceObserver {
|
||||||
public:
|
public:
|
||||||
// Construct a chooser controller for Human Interface Devices (HID).
|
// Construct a chooser controller for Human Interface Devices (HID).
|
||||||
// |render_frame_host| is used to initialize the chooser strings and to access
|
// |render_frame_host| is used to initialize the chooser strings and to access
|
||||||
|
|
|
@ -28,8 +28,9 @@ namespace electron {
|
||||||
class ElectronSerialDelegate;
|
class ElectronSerialDelegate;
|
||||||
|
|
||||||
// SerialChooserController provides data for the Serial API permission prompt.
|
// SerialChooserController provides data for the Serial API permission prompt.
|
||||||
class SerialChooserController final : public SerialChooserContext::PortObserver,
|
class SerialChooserController final
|
||||||
public content::WebContentsObserver {
|
: private SerialChooserContext::PortObserver,
|
||||||
|
private content::WebContentsObserver {
|
||||||
public:
|
public:
|
||||||
SerialChooserController(
|
SerialChooserController(
|
||||||
content::RenderFrameHost* render_frame_host,
|
content::RenderFrameHost* render_frame_host,
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace electron {
|
||||||
|
|
||||||
class AutofillPopupView;
|
class AutofillPopupView;
|
||||||
|
|
||||||
class AutofillPopup : public views::ViewObserver {
|
class AutofillPopup : private views::ViewObserver {
|
||||||
public:
|
public:
|
||||||
AutofillPopup();
|
AutofillPopup();
|
||||||
~AutofillPopup() override;
|
~AutofillPopup() override;
|
||||||
|
|
|
@ -27,8 +27,8 @@ class RenderFrameHost;
|
||||||
namespace electron {
|
namespace electron {
|
||||||
|
|
||||||
// UsbChooserController creates a chooser for WebUSB.
|
// UsbChooserController creates a chooser for WebUSB.
|
||||||
class UsbChooserController final : public UsbChooserContext::DeviceObserver,
|
class UsbChooserController final : private UsbChooserContext::DeviceObserver,
|
||||||
public content::WebContentsObserver {
|
private content::WebContentsObserver {
|
||||||
public:
|
public:
|
||||||
UsbChooserController(
|
UsbChooserController(
|
||||||
content::RenderFrameHost* render_frame_host,
|
content::RenderFrameHost* render_frame_host,
|
||||||
|
|
|
@ -18,7 +18,7 @@ class WebContentsZoomObserver;
|
||||||
|
|
||||||
// Manages the zoom changes of WebContents.
|
// Manages the zoom changes of WebContents.
|
||||||
class WebContentsZoomController
|
class WebContentsZoomController
|
||||||
: public content::WebContentsObserver,
|
: private content::WebContentsObserver,
|
||||||
public content::WebContentsUserData<WebContentsZoomController> {
|
public content::WebContentsUserData<WebContentsZoomController> {
|
||||||
public:
|
public:
|
||||||
// Defines how zoom changes are handled.
|
// Defines how zoom changes are handled.
|
||||||
|
|
|
@ -19,7 +19,7 @@ class WebContents;
|
||||||
}
|
}
|
||||||
|
|
||||||
class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate,
|
class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate,
|
||||||
public WebContentsZoomObserver {
|
private WebContentsZoomObserver {
|
||||||
public:
|
public:
|
||||||
WebViewGuestDelegate(content::WebContents* embedder,
|
WebViewGuestDelegate(content::WebContents* embedder,
|
||||||
api::WebContents* api_web_contents);
|
api::WebContents* api_web_contents);
|
||||||
|
|
|
@ -21,9 +21,9 @@
|
||||||
|
|
||||||
namespace electron {
|
namespace electron {
|
||||||
|
|
||||||
class AutofillAgent : public content::RenderFrameObserver,
|
class AutofillAgent : private content::RenderFrameObserver,
|
||||||
public blink::WebAutofillClient,
|
private blink::WebAutofillClient,
|
||||||
public mojom::ElectronAutofillAgent {
|
private mojom::ElectronAutofillAgent {
|
||||||
public:
|
public:
|
||||||
explicit AutofillAgent(content::RenderFrame* frame,
|
explicit AutofillAgent(content::RenderFrame* frame,
|
||||||
blink::AssociatedInterfaceRegistry* registry);
|
blink::AssociatedInterfaceRegistry* registry);
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace electron {
|
||||||
class RendererClientBase;
|
class RendererClientBase;
|
||||||
|
|
||||||
// Helper class to forward the messages to the client.
|
// Helper class to forward the messages to the client.
|
||||||
class ElectronRenderFrameObserver : public content::RenderFrameObserver {
|
class ElectronRenderFrameObserver : private content::RenderFrameObserver {
|
||||||
public:
|
public:
|
||||||
ElectronRenderFrameObserver(content::RenderFrame* frame,
|
ElectronRenderFrameObserver(content::RenderFrame* frame,
|
||||||
RendererClientBase* renderer_client);
|
RendererClientBase* renderer_client);
|
||||||
|
@ -26,6 +26,7 @@ class ElectronRenderFrameObserver : public content::RenderFrameObserver {
|
||||||
ElectronRenderFrameObserver& operator=(const ElectronRenderFrameObserver&) =
|
ElectronRenderFrameObserver& operator=(const ElectronRenderFrameObserver&) =
|
||||||
delete;
|
delete;
|
||||||
|
|
||||||
|
private:
|
||||||
// content::RenderFrameObserver:
|
// content::RenderFrameObserver:
|
||||||
void DidClearWindowObject() override;
|
void DidClearWindowObject() override;
|
||||||
void DidInstallConditionalFeatures(v8::Handle<v8::Context> context,
|
void DidInstallConditionalFeatures(v8::Handle<v8::Context> context,
|
||||||
|
@ -35,7 +36,6 @@ class ElectronRenderFrameObserver : public content::RenderFrameObserver {
|
||||||
void OnDestruct() override;
|
void OnDestruct() override;
|
||||||
void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override;
|
void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override;
|
||||||
|
|
||||||
private:
|
|
||||||
[[nodiscard]] bool ShouldNotifyClient(int world_id) const;
|
[[nodiscard]] bool ShouldNotifyClient(int world_id) const;
|
||||||
|
|
||||||
void CreateIsolatedWorldContext();
|
void CreateIsolatedWorldContext();
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
// This class listens for Pepper creation events from the RenderFrame and
|
// This class listens for Pepper creation events from the RenderFrame and
|
||||||
// attaches the parts required for plugin support.
|
// attaches the parts required for plugin support.
|
||||||
class PepperHelper : public content::RenderFrameObserver {
|
class PepperHelper : private content::RenderFrameObserver {
|
||||||
public:
|
public:
|
||||||
explicit PepperHelper(content::RenderFrame* render_frame);
|
explicit PepperHelper(content::RenderFrame* render_frame);
|
||||||
~PepperHelper() override;
|
~PepperHelper() override;
|
||||||
|
@ -20,6 +20,7 @@ class PepperHelper : public content::RenderFrameObserver {
|
||||||
PepperHelper(const PepperHelper&) = delete;
|
PepperHelper(const PepperHelper&) = delete;
|
||||||
PepperHelper& operator=(const PepperHelper&) = delete;
|
PepperHelper& operator=(const PepperHelper&) = delete;
|
||||||
|
|
||||||
|
private:
|
||||||
// RenderFrameObserver.
|
// RenderFrameObserver.
|
||||||
void DidCreatePepperPlugin(content::RendererPpapiHost* host) override;
|
void DidCreatePepperPlugin(content::RendererPpapiHost* host) override;
|
||||||
void OnDestruct() override;
|
void OnDestruct() override;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче