Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: prefer to inherit observer classes privately #41360

Merged
merged 19 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e666109
refactor: use private inheritance in CookieChangeNotifier
ckerr Feb 16, 2024
da069b3
refactor: use private inheritance in WebViewGuestDelegate
ckerr Feb 16, 2024
847db0b
refactor: use private inheritance in UsbChooserController
ckerr Feb 16, 2024
23b8821
refactor: use private inheritance in DesktopCapturer
ckerr Feb 16, 2024
be26419
refactor: use private inheritance in Browser
ckerr Feb 16, 2024
b2b96de
refactor: use private inheritance in WebContentsZoomController
ckerr Feb 16, 2024
480b626
refactor: use private inheritance in FrameSubscriber
ckerr Feb 16, 2024
6fe2a85
refactor: use private inheritance in AutofillAgent
ckerr Feb 16, 2024
2197982
refactor: use private inheritance in HidChooserController
ckerr Feb 16, 2024
895c9ab
refactor: use private inheritance in PepperHelper
ckerr Feb 16, 2024
ee33962
refactor: use private inheritance in AutofillPopup
ckerr Feb 16, 2024
6a6d95c
refactor: use private inheritance in SerialChooserController
ckerr Feb 16, 2024
6a2cc88
refactor: use private inheritance in MediaCaptureDevicesDispatcher
ckerr Feb 16, 2024
21bafdb
refactor: use private inheritance in electron::api::View
ckerr Feb 16, 2024
f0ee36a
refactor: use private inheritance in AutofillDriverFactory
ckerr Feb 16, 2024
6ba7646
refactor: use private inheritance in GPUInfoManager
ckerr Feb 16, 2024
0825cfe
refactor: use private inheritance in SavePageHandler
ckerr Feb 16, 2024
917e245
refactor: use private inheritance in GlobalShortcut
ckerr Feb 16, 2024
499c5f3
refactor: use private inheritance in ElectronRenderFrameObserver
ckerr Feb 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions shell/browser/api/electron_api_desktop_capturer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {}
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/electron_api_global_shortcut.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion shell/browser/api/electron_api_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions shell/browser/api/frame_subscriber.h
Original file line number Diff line number Diff line change
Expand Up @@ -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&)>;
Expand Down
5 changes: 3 additions & 2 deletions shell/browser/api/gpuinfo_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions shell/browser/api/save_page_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/browser.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct LoginItemSettings {
};

// This class is used for control application-wide operations.
class Browser : public WindowListObserver {
class Browser : private WindowListObserver {
public:
Browser();
~Browser() override;
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/cookie_change_notifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace electron {
class ElectronBrowserContext;

// Sends cookie-change notifications on the UI thread.
class CookieChangeNotifier : public network::mojom::CookieChangeListener {
class CookieChangeNotifier : private network::mojom::CookieChangeListener {
public:
explicit CookieChangeNotifier(ElectronBrowserContext* browser_context);
~CookieChangeNotifier() override;
Expand Down
12 changes: 6 additions & 6 deletions shell/browser/electron_autofill_driver_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace electron {
class AutofillDriver;

class AutofillDriverFactory
: public content::WebContentsObserver,
: private content::WebContentsObserver,
public content::WebContentsUserData<AutofillDriverFactory> {
public:
typedef base::OnceCallback<std::unique_ptr<AutofillDriver>()>
Expand All @@ -31,11 +31,6 @@ class AutofillDriverFactory
pending_receiver,
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);
void AddDriverForFrame(content::RenderFrameHost* render_frame_host,
CreationCallback factory_method);
Expand All @@ -46,6 +41,11 @@ class AutofillDriverFactory
WEB_CONTENTS_USER_DATA_KEY_DECL();

private:
// content::WebContentsObserver:
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
void DidFinishNavigation(
content::NavigationHandle* navigation_handle) override;

explicit AutofillDriverFactory(content::WebContents* web_contents);
friend class content::WebContentsUserData<AutofillDriverFactory>;

Expand Down
4 changes: 2 additions & 2 deletions shell/browser/hid/hid_chooser_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class HidChooserContext;

// HidChooserController provides data for the WebHID API permission prompt.
class HidChooserController
: public content::WebContentsObserver,
public electron::HidChooserContext::DeviceObserver {
: private content::WebContentsObserver,
private electron::HidChooserContext::DeviceObserver {
public:
// Construct a chooser controller for Human Interface Devices (HID).
// |render_frame_host| is used to initialize the chooser strings and to access
Expand Down
5 changes: 3 additions & 2 deletions shell/browser/serial/serial_chooser_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ namespace electron {
class ElectronSerialDelegate;

// SerialChooserController provides data for the Serial API permission prompt.
class SerialChooserController final : public SerialChooserContext::PortObserver,
public content::WebContentsObserver {
class SerialChooserController final
: private SerialChooserContext::PortObserver,
private content::WebContentsObserver {
public:
SerialChooserController(
content::RenderFrameHost* render_frame_host,
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/ui/autofill_popup.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace electron {

class AutofillPopupView;

class AutofillPopup : public views::ViewObserver {
class AutofillPopup : private views::ViewObserver {
public:
AutofillPopup();
~AutofillPopup() override;
Expand Down
4 changes: 2 additions & 2 deletions shell/browser/usb/usb_chooser_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class RenderFrameHost;
namespace electron {

// UsbChooserController creates a chooser for WebUSB.
class UsbChooserController final : public UsbChooserContext::DeviceObserver,
public content::WebContentsObserver {
class UsbChooserController final : private UsbChooserContext::DeviceObserver,
private content::WebContentsObserver {
public:
UsbChooserController(
content::RenderFrameHost* render_frame_host,
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/web_contents_zoom_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class WebContentsZoomObserver;

// Manages the zoom changes of WebContents.
class WebContentsZoomController
: public content::WebContentsObserver,
: private content::WebContentsObserver,
public content::WebContentsUserData<WebContentsZoomController> {
public:
// Defines how zoom changes are handled.
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/web_view_guest_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class WebContents;
}

class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate,
public WebContentsZoomObserver {
private WebContentsZoomObserver {
public:
WebViewGuestDelegate(content::WebContents* embedder,
api::WebContents* api_web_contents);
Expand Down
6 changes: 3 additions & 3 deletions shell/renderer/electron_autofill_agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

namespace electron {

class AutofillAgent : public content::RenderFrameObserver,
public blink::WebAutofillClient,
public mojom::ElectronAutofillAgent {
class AutofillAgent : private content::RenderFrameObserver,
private blink::WebAutofillClient,
private mojom::ElectronAutofillAgent {
public:
explicit AutofillAgent(content::RenderFrame* frame,
blink::AssociatedInterfaceRegistry* registry);
Expand Down
4 changes: 2 additions & 2 deletions shell/renderer/electron_render_frame_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace electron {
class RendererClientBase;

// Helper class to forward the messages to the client.
class ElectronRenderFrameObserver : public content::RenderFrameObserver {
class ElectronRenderFrameObserver : private content::RenderFrameObserver {
public:
ElectronRenderFrameObserver(content::RenderFrame* frame,
RendererClientBase* renderer_client);
Expand All @@ -26,6 +26,7 @@ class ElectronRenderFrameObserver : public content::RenderFrameObserver {
ElectronRenderFrameObserver& operator=(const ElectronRenderFrameObserver&) =
delete;

private:
// content::RenderFrameObserver:
void DidClearWindowObject() override;
void DidInstallConditionalFeatures(v8::Handle<v8::Context> context,
Expand All @@ -35,7 +36,6 @@ class ElectronRenderFrameObserver : public content::RenderFrameObserver {
void OnDestruct() override;
void DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) override;

private:
[[nodiscard]] bool ShouldNotifyClient(int world_id) const;

void CreateIsolatedWorldContext();
Expand Down
3 changes: 2 additions & 1 deletion shell/renderer/pepper_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

// This class listens for Pepper creation events from the RenderFrame and
// attaches the parts required for plugin support.
class PepperHelper : public content::RenderFrameObserver {
class PepperHelper : private content::RenderFrameObserver {
public:
explicit PepperHelper(content::RenderFrame* render_frame);
~PepperHelper() override;
Expand All @@ -20,6 +20,7 @@ class PepperHelper : public content::RenderFrameObserver {
PepperHelper(const PepperHelper&) = delete;
PepperHelper& operator=(const PepperHelper&) = delete;

private:
// RenderFrameObserver.
void DidCreatePepperPlugin(content::RendererPpapiHost* host) override;
void OnDestruct() override;
Expand Down