#include "components/pdf/renderer/pdf_view_web_plugin_client.h"
#include <memory>
#include <string>
#include <utility>
#include "base/check_op.h"
#include "base/values.h"
#include "components/pdf/renderer/pdf_accessibility_tree.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_thread.h"
#include "content/public/renderer/v8_value_converter.h"
#include "net/cookies/site_for_cookies.h"
#include "printing/buildflags/buildflags.h"
#include "third_party/blink/public/platform/scheduler/web_agent_group_scheduler.h"
#include "third_party/blink/public/platform/web_security_origin.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_url.h"
#include "third_party/blink/public/platform/web_vector.h"
#include "third_party/blink/public/web/web_associated_url_loader.h"
#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_dom_message_event.h"
#include "third_party/blink/public/web/web_element.h"
#include "third_party/blink/public/web/web_frame_widget.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/public/web/web_local_frame_client.h"
#include "third_party/blink/public/web/web_plugin_container.h"
#include "third_party/blink/public/web/web_serialized_script_value.h"
#include "third_party/blink/public/web/web_view.h"
#include "third_party/blink/public/web/web_widget.h"
#include "ui/display/screen_info.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/rect.h"
#include "v8/include/v8-context.h"
#include "v8/include/v8-isolate.h"
#include "v8/include/v8-local-handle.h"
#include "v8/include/v8-value.h"
#if BUILDFLAG(ENABLE_PRINTING)
#include "components/printing/renderer/print_render_frame_helper.h"
#endif
namespace pdf {
PdfViewWebPluginClient::PdfViewWebPluginClient(
content::RenderFrame* render_frame)
: … { … }
PdfViewWebPluginClient::~PdfViewWebPluginClient() = default;
std::unique_ptr<base::Value> PdfViewWebPluginClient::FromV8Value(
v8::Local<v8::Value> value,
v8::Local<v8::Context> context) { … }
base::WeakPtr<chrome_pdf::PdfViewWebPlugin::Client>
PdfViewWebPluginClient::GetWeakPtr() { … }
void PdfViewWebPluginClient::SetPluginContainer(
blink::WebPluginContainer* container) { … }
blink::WebPluginContainer* PdfViewWebPluginClient::PluginContainer() { … }
v8::Isolate* PdfViewWebPluginClient::GetIsolate() { … }
net::SiteForCookies PdfViewWebPluginClient::SiteForCookies() const { … }
blink::WebURL PdfViewWebPluginClient::CompleteURL(
const blink::WebString& partial_url) const { … }
void PdfViewWebPluginClient::PostMessage(base::Value::Dict message) { … }
void PdfViewWebPluginClient::Invalidate() { … }
void PdfViewWebPluginClient::RequestTouchEventType(
blink::WebPluginContainer::TouchEventRequestType request_type) { … }
void PdfViewWebPluginClient::ReportFindInPageMatchCount(int identifier,
int total,
bool final_update) { … }
void PdfViewWebPluginClient::ReportFindInPageSelection(int identifier,
int index,
bool final_update) { … }
void PdfViewWebPluginClient::ReportFindInPageTickmarks(
const std::vector<gfx::Rect>& tickmarks) { … }
float PdfViewWebPluginClient::DeviceScaleFactor() { … }
gfx::PointF PdfViewWebPluginClient::GetScrollPosition() { … }
void PdfViewWebPluginClient::UsePluginAsFindHandler() { … }
void PdfViewWebPluginClient::SetReferrerForRequest(
blink::WebURLRequest& request,
const blink::WebURL& referrer_url) { … }
void PdfViewWebPluginClient::Alert(const blink::WebString& message) { … }
bool PdfViewWebPluginClient::Confirm(const blink::WebString& message) { … }
blink::WebString PdfViewWebPluginClient::Prompt(
const blink::WebString& message,
const blink::WebString& default_value) { … }
void PdfViewWebPluginClient::TextSelectionChanged(
const blink::WebString& selection_text,
uint32_t offset,
const gfx::Range& range) { … }
std::unique_ptr<blink::WebAssociatedURLLoader>
PdfViewWebPluginClient::CreateAssociatedURLLoader(
const blink::WebAssociatedURLLoaderOptions& options) { … }
void PdfViewWebPluginClient::UpdateTextInputState() { … }
void PdfViewWebPluginClient::UpdateSelectionBounds() { … }
std::string PdfViewWebPluginClient::GetEmbedderOriginString() { … }
bool PdfViewWebPluginClient::HasFrame() const { … }
blink::WebLocalFrame* PdfViewWebPluginClient::GetFrame() const { … }
void PdfViewWebPluginClient::DidStartLoading() { … }
void PdfViewWebPluginClient::DidStopLoading() { … }
void PdfViewWebPluginClient::Print() { … }
void PdfViewWebPluginClient::RecordComputedAction(const std::string& action) { … }
std::unique_ptr<chrome_pdf::PdfAccessibilityDataHandler>
PdfViewWebPluginClient::CreateAccessibilityDataHandler(
chrome_pdf::PdfAccessibilityActionHandler* action_handler,
chrome_pdf::PdfAccessibilityImageFetcher* image_fetcher,
blink::WebPluginContainer* plugin_container,
bool print_preview) { … }
}