#include "components/optimization_guide/content/renderer/page_text_agent.h"
#include "base/functional/callback_helpers.h"
#include "content/public/renderer/render_frame.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/web/web_frame_content_dumper.h"
namespace optimization_guide {
namespace {
constexpr size_t kChunkSize = …;
std::optional<mojom::TextDumpEvent> LayoutEventAsMojoEvent(
blink::WebMeaningfulLayout layout_event) { … }
}
PageTextAgent::PageTextAgent(content::RenderFrame* frame)
: … { … }
PageTextAgent::~PageTextAgent() = default;
void PageTextAgent::Bind(
mojo::PendingAssociatedReceiver<mojom::PageTextService> receiver) { … }
base::OnceCallback<void(scoped_refptr<const base::RefCountedString16>)>
PageTextAgent::MaybeRequestTextDumpOnLayoutEvent(
blink::WebMeaningfulLayout event,
uint32_t* max_size) { … }
void PageTextAgent::OnPageTextDump(
mojo::PendingRemote<mojom::PageTextConsumer> pending_consumer,
scoped_refptr<const base::RefCountedString16> content) { … }
void PageTextAgent::DidFinishLoad() { … }
void PageTextAgent::DidStartNavigation(
const GURL& url,
std::optional<blink::WebNavigationType> navigation_type) { … }
void PageTextAgent::DidObserveLoadingBehavior(
blink::LoadingBehaviorFlag behavior) { … }
void PageTextAgent::RequestPageTextDump(
mojom::PageTextDumpRequestPtr request,
mojo::PendingRemote<mojom::PageTextConsumer> consumer) { … }
}