[unseasoned-pdf] Add PdfViewWebPlugin::GetValidContainerFrame().
Getting the access to the document's WebLocalFrame is often needed in PdfViewWebPlugin, therefore add a helper function GetValidContainerFrame() which checks for a valid WebLocalFrame and returns it. Change-Id: Ib026b69377ecc0378013677cae44192cec1f7ab4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2870487 Commit-Queue: Hui Yingst <nigi@chromium.org> Reviewed-by: Daniel Hosseinian <dhoss@chromium.org> Cr-Commit-Position: refs/heads/master@{#878750}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
689105e94e
commit
850c537cfc
@@ -394,17 +394,13 @@ net::SiteForCookies PdfViewWebPlugin::SiteForCookies() const {
|
|||||||
void PdfViewWebPlugin::SetReferrerForRequest(
|
void PdfViewWebPlugin::SetReferrerForRequest(
|
||||||
blink::WebURLRequest& request,
|
blink::WebURLRequest& request,
|
||||||
const blink::WebURL& referrer_url) {
|
const blink::WebURL& referrer_url) {
|
||||||
DCHECK(IsValid());
|
GetValidContainerFrame()->SetReferrerForRequest(request, referrer_url);
|
||||||
Container()->GetDocument().GetFrame()->SetReferrerForRequest(request,
|
|
||||||
referrer_url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<blink::WebAssociatedURLLoader>
|
std::unique_ptr<blink::WebAssociatedURLLoader>
|
||||||
PdfViewWebPlugin::CreateAssociatedURLLoader(
|
PdfViewWebPlugin::CreateAssociatedURLLoader(
|
||||||
const blink::WebAssociatedURLLoaderOptions& options) {
|
const blink::WebAssociatedURLLoaderOptions& options) {
|
||||||
DCHECK(IsValid());
|
return GetValidContainerFrame()->CreateAssociatedURLLoader(options);
|
||||||
return Container()->GetDocument().GetFrame()->CreateAssociatedURLLoader(
|
|
||||||
options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdfViewWebPlugin::OnMessage(const base::Value& message) {
|
void PdfViewWebPlugin::OnMessage(const base::Value& message) {
|
||||||
@@ -503,6 +499,11 @@ void PdfViewWebPlugin::UserMetricsRecordAction(const std::string& action) {
|
|||||||
base::RecordAction(base::UserMetricsAction(action.c_str()));
|
base::RecordAction(base::UserMetricsAction(action.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blink::WebLocalFrame* PdfViewWebPlugin::GetValidContainerFrame() const {
|
||||||
|
DCHECK(IsValid());
|
||||||
|
return Container()->GetDocument().GetFrame();
|
||||||
|
}
|
||||||
|
|
||||||
void PdfViewWebPlugin::OnViewportChanged(const gfx::Rect& view_rect,
|
void PdfViewWebPlugin::OnViewportChanged(const gfx::Rect& view_rect,
|
||||||
float new_device_scale) {
|
float new_device_scale) {
|
||||||
UpdateGeometryOnViewChanged(view_rect, new_device_scale);
|
UpdateGeometryOnViewChanged(view_rect, new_device_scale);
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
#include "v8/include/v8.h"
|
#include "v8/include/v8.h"
|
||||||
|
|
||||||
namespace blink {
|
namespace blink {
|
||||||
|
class WebLocalFrame;
|
||||||
class WebPluginContainer;
|
class WebPluginContainer;
|
||||||
} // namespace blink
|
} // namespace blink
|
||||||
|
|
||||||
@@ -153,6 +154,10 @@ class PdfViewWebPlugin final : public PdfViewPluginBase,
|
|||||||
|
|
||||||
bool InitializeCommon(std::unique_ptr<ContainerWrapper> container_wrapper);
|
bool InitializeCommon(std::unique_ptr<ContainerWrapper> container_wrapper);
|
||||||
|
|
||||||
|
// Returns the local frame to which the web plugin container belongs to. May
|
||||||
|
// only be called when the plugin has the container inside a valid frame.
|
||||||
|
blink::WebLocalFrame* GetValidContainerFrame() const;
|
||||||
|
|
||||||
void OnViewportChanged(const gfx::Rect& view_rect, float new_device_scale);
|
void OnViewportChanged(const gfx::Rect& view_rect, float new_device_scale);
|
||||||
|
|
||||||
// Invalidates the entire web plugin container and schedules a paint of the
|
// Invalidates the entire web plugin container and schedules a paint of the
|
||||||
|
Reference in New Issue
Block a user