[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(
|
||||
blink::WebURLRequest& request,
|
||||
const blink::WebURL& referrer_url) {
|
||||
DCHECK(IsValid());
|
||||
Container()->GetDocument().GetFrame()->SetReferrerForRequest(request,
|
||||
referrer_url);
|
||||
GetValidContainerFrame()->SetReferrerForRequest(request, referrer_url);
|
||||
}
|
||||
|
||||
std::unique_ptr<blink::WebAssociatedURLLoader>
|
||||
PdfViewWebPlugin::CreateAssociatedURLLoader(
|
||||
const blink::WebAssociatedURLLoaderOptions& options) {
|
||||
DCHECK(IsValid());
|
||||
return Container()->GetDocument().GetFrame()->CreateAssociatedURLLoader(
|
||||
options);
|
||||
return GetValidContainerFrame()->CreateAssociatedURLLoader(options);
|
||||
}
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
blink::WebLocalFrame* PdfViewWebPlugin::GetValidContainerFrame() const {
|
||||
DCHECK(IsValid());
|
||||
return Container()->GetDocument().GetFrame();
|
||||
}
|
||||
|
||||
void PdfViewWebPlugin::OnViewportChanged(const gfx::Rect& view_rect,
|
||||
float new_device_scale) {
|
||||
UpdateGeometryOnViewChanged(view_rect, new_device_scale);
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "v8/include/v8.h"
|
||||
|
||||
namespace blink {
|
||||
class WebLocalFrame;
|
||||
class WebPluginContainer;
|
||||
} // namespace blink
|
||||
|
||||
@ -153,6 +154,10 @@ class PdfViewWebPlugin final : public PdfViewPluginBase,
|
||||
|
||||
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);
|
||||
|
||||
// Invalidates the entire web plugin container and schedules a paint of the
|
||||
|
Reference in New Issue
Block a user