electron/shell/renderer/content_settings_observer.h
trop[bot] 46c9ed61da
feat: route deprecated sync clipboard read through permission checks (#45471)
* feat: route deprecated clipboard commands through permission checks

Co-authored-by: deepak1556 <hop2deep@gmail.com>

* docs: address review feedback

Co-authored-by: deepak1556 <hop2deep@gmail.com>

* fix: enable checks for child windows

Co-authored-by: deepak1556 <hop2deep@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
2025-02-05 14:10:43 -05:00

43 lines
1.5 KiB
C++

// Copyright (c) 2016 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_RENDERER_CONTENT_SETTINGS_OBSERVER_H_
#define ELECTRON_SHELL_RENDERER_CONTENT_SETTINGS_OBSERVER_H_
#include "content/public/renderer/render_frame_observer.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "shell/common/web_contents_utility.mojom.h"
#include "third_party/blink/public/platform/web_content_settings_client.h"
#include "url/origin.h"
namespace electron {
class ContentSettingsObserver : public content::RenderFrameObserver,
public blink::WebContentSettingsClient {
public:
explicit ContentSettingsObserver(content::RenderFrame* render_frame);
~ContentSettingsObserver() override;
// disable copy
ContentSettingsObserver(const ContentSettingsObserver&) = delete;
ContentSettingsObserver& operator=(const ContentSettingsObserver&) = delete;
// blink::WebContentSettingsClient implementation.
bool AllowStorageAccessSync(StorageType storage_type) override;
bool AllowReadFromClipboardSync() override;
private:
// content::RenderFrameObserver implementation.
void OnDestruct() override;
// A getter for `content_settings_manager_` that ensures it is bound.
mojom::ElectronWebContentsUtility& GetWebContentsUtility();
mojo::AssociatedRemote<mojom::ElectronWebContentsUtility>
web_contents_utility_;
};
} // namespace electron
#endif // ELECTRON_SHELL_RENDERER_CONTENT_SETTINGS_OBSERVER_H_