#ifndef CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_
#define CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_
#include <stddef.h>
#include <memory>
#include <string>
#include <string_view>
#include "base/byte_count.h"
#include "base/supports_user_data.h"
#include "base/task/single_thread_task_runner.h"
#include "content/common/buildflags.h"
#include "content/common/content_export.h"
#include "content/public/common/bindings_policy.h"
#include "services/network/public/cpp/url_loader_completion_status.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "third_party/blink/public/common/subresource_load_metrics.h"
#include "third_party/blink/public/common/use_counter/use_counter_feature.h"
#include "third_party/blink/public/mojom/devtools/console_message.mojom.h"
#include "third_party/blink/public/mojom/frame/triggering_event_info.mojom-shared.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/public/platform/web_url_request.h"
#include "third_party/blink/public/platform/web_url_response.h"
#include "third_party/blink/public/web/web_navigation_policy.h"
#include "ui/accessibility/ax_mode.h"
#include "ui/accessibility/ax_tree_update.h"
#include "arkweb/build/features/features.h"
class GURL;
namespace blink {
namespace scheduler {
class WebAgentGroupScheduler;
}
namespace web_pref {
struct WebPreferences;
}
class AssociatedInterfaceProvider;
class AssociatedInterfaceRegistry;
class BrowserInterfaceBrokerProxy;
class WebElement;
class WebFrame;
class WebLocalFrame;
class WebView;
}
namespace gfx {
class Range;
class Rect;
}
namespace content {
class RenderAccessibility;
struct RenderFrameMediaPlaybackOptions;
class RenderFrameVisitor;
class AXTreeSnapshotter {
public:
AXTreeSnapshotter() = default;
virtual void Snapshot(size_t max_node_count,
base::TimeDelta timeout,
ui::AXTreeUpdate* accessibility_tree) = 0;
virtual ~AXTreeSnapshotter() = default;
};
class CONTENT_EXPORT RenderFrame :
public base::SupportsUserData {
public:
static RenderFrame* FromWebFrame(blink::WebLocalFrame* web_frame);
static void ForEach(RenderFrameVisitor* visitor);
#if BUILDFLAG(ARKWEB_INPUT_EVENTS)
virtual void SetZoomLevel(float magnify_delta, const gfx::Point& anchor) {}
virtual void SetOverscrollMode(int mode) {}
virtual bool IsElementExist(std::string xPath) {
return false;
}
#if BUILDFLAG(ARKWEB_GET_SCROLL_OFFSET)
virtual gfx::Vector2dF GetOverScrollOffset() = 0;
#endif
#endif
virtual RenderFrame* GetMainRenderFrame() = 0;
virtual RenderAccessibility* GetRenderAccessibility() = 0;
virtual std::unique_ptr<AXTreeSnapshotter> CreateAXTreeSnapshotter(
ui::AXMode ax_mode) = 0;
virtual blink::WebView* GetWebView() = 0;
virtual const blink::WebView* GetWebView() const = 0;
virtual blink::WebLocalFrame* GetWebFrame() = 0;
virtual const blink::WebLocalFrame* GetWebFrame() const = 0;
virtual const blink::web_pref::WebPreferences& GetBlinkPreferences() = 0;
virtual void ShowVirtualKeyboard() = 0;
virtual void ExecuteJavaScript(const std::u16string& javascript) = 0;
virtual bool IsMainFrame() = 0;
virtual bool IsInFencedFrameTree() const = 0;
virtual bool IsHidden() = 0;
virtual void BindLocalInterface(
const std::string& interface_name,
mojo::ScopedMessagePipeHandle interface_pipe) = 0;
virtual const blink::BrowserInterfaceBrokerProxy&
GetBrowserInterfaceBroker() = 0;
virtual blink::AssociatedInterfaceRegistry*
GetAssociatedInterfaceRegistry() = 0;
virtual blink::AssociatedInterfaceProvider*
GetRemoteAssociatedInterfaces() = 0;
virtual void SetSelectedText(const std::u16string& selection_text,
size_t offset,
const gfx::Range& range) = 0;
virtual void AddMessageToConsole(blink::mojom::ConsoleMessageLevel level,
const std::string& message) = 0;
virtual bool IsPasting() = 0;
virtual void LoadHTMLStringForTesting(std::string_view html,
const GURL& base_url,
const std::string& text_encoding,
const GURL& unreachable_url,
bool replace_current_item) = 0;
virtual bool IsRequestingNavigation() = 0;
virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner(
blink::TaskType task_type) = 0;
virtual BindingsPolicySet GetEnabledBindings() = 0;
virtual void SetAccessibilityModeForTest(ui::AXMode new_mode) = 0;
virtual const RenderFrameMediaPlaybackOptions&
GetRenderFrameMediaPlaybackOptions() = 0;
virtual void SetRenderFrameMediaPlaybackOptions(
const RenderFrameMediaPlaybackOptions& opts) = 0;
virtual void SetAllowsCrossBrowsingInstanceFrameLookup() = 0;
virtual gfx::RectF ElementBoundsInWindow(
const blink::WebElement& element) = 0;
[[nodiscard]] virtual gfx::Rect ConvertViewportToWindow(
const gfx::Rect& rect) = 0;
virtual float GetDeviceScaleFactor() = 0;
virtual blink::scheduler::WebAgentGroupScheduler&
GetAgentGroupScheduler() = 0;
#if BUILDFLAG(ARKWEB_PDF)
virtual void OnPdfScrollAtBottom(const std::string& url) = 0;
virtual void OnPdfLoadEvent(int32_t result, const std::string& url) = 0;
#endif
#if BUILDFLAG(ARKWEB_ADBLOCK)
virtual bool GetGlobalAdblockEnabled() = 0;
virtual base::WeakPtr<RenderFrame> GetRenderFrameWeakPtr() {
return base::WeakPtr<RenderFrame>();
}
#endif
#if BUILDFLAG(ARKWEB_JS_ON_DOCUMENT_END)
virtual void OnDocumentEndReady() = 0;
#endif
using NewFeatureUsageCallback =
base::RepeatingCallback<void(const blink::UseCounterFeature&)>;
virtual void SetNewFeatureUsageCallback(NewFeatureUsageCallback callback) = 0;
using SubresourceLoadCallback =
base::RepeatingCallback<void(const blink::SubresourceLoadMetrics&)>;
virtual void SetSubresourceLoadCallback(SubresourceLoadCallback callback) = 0;
using LoadFromMemoryCacheCallback =
base::RepeatingCallback<void(const GURL& response_url,
int request_id,
base::ByteCount encoded_body_length,
const std::string& mime_type,
bool from_archive)>;
virtual void SetLoadFromMemoryCacheCallback(
LoadFromMemoryCacheCallback callback) = 0;
using DidStartResponseCallback = base::RepeatingCallback<void(
const url::SchemeHostPort& final_response_url,
int request_id,
const network::mojom::URLResponseHead& response_head,
network::mojom::RequestDestination request_destination,
bool is_ad_resource)>;
using DidCompleteResponseCallback = base::RepeatingCallback<
void(int request_id, const network::URLLoaderCompletionStatus& status)>;
using DidCancelResponseCallback =
base::RepeatingCallback<void(int request_id)>;
virtual void SetDidStartResponseCallback(
DidStartResponseCallback callback) = 0;
virtual void SetDidCompleteResponseCallback(
DidCompleteResponseCallback callback) = 0;
virtual void SetDidCancelResponseCallback(
DidCancelResponseCallback callback) = 0;
protected:
~RenderFrame() override {}
private:
friend class RenderFrameImpl;
RenderFrame() {}
};
}
#endif